mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-07 21:53:07 -04:00
- make tts use subcommands
- add moonbase
This commit is contained in:
parent
5c4a02f08f
commit
cc37d5f50b
9 changed files with 87 additions and 32 deletions
45
commands/interaction/subcommands/tts/imtranslator.js
Normal file
45
commands/interaction/subcommands/tts/imtranslator.js
Normal file
|
@ -0,0 +1,45 @@
|
|||
const { Constants } = require('detritus-client');
|
||||
const { InteractionCallbackTypes, ApplicationCommandOptionTypes } = Constants;
|
||||
|
||||
const { imtranslator } = require('../../../../labscore/api');
|
||||
const { IMTRANSLATOR_VOICES } = require('../../../../labscore/constants');
|
||||
|
||||
const { createEmbed } = require('../../../../labscore/utils/embed');
|
||||
const { icon, highlight } = require('../../../../labscore/utils/markdown');
|
||||
|
||||
module.exports = {
|
||||
description: 'Text to Speech with imtranslator voices',
|
||||
name: 'imtranslator',
|
||||
type: ApplicationCommandOptionTypes.SUB_COMMAND,
|
||||
options: [
|
||||
{
|
||||
name: 'voice',
|
||||
description: 'TTS Voice to use',
|
||||
choices: IMTRANSLATOR_VOICES,
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
name: 'text',
|
||||
description: 'Text',
|
||||
type: ApplicationCommandOptionTypes.STRING,
|
||||
required: true,
|
||||
maxLength: 256
|
||||
}
|
||||
],
|
||||
run: async (context, args) => {
|
||||
try{
|
||||
let s = Date.now()
|
||||
await context.respond({data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE})
|
||||
let audio = await imtranslator(context, args.text, args.voice)
|
||||
let diff = (Date.now() - s)
|
||||
await context.editOrRespond({
|
||||
embeds: [createEmbed("defaultNoFooter", context, { description: `${icon("audio")} Audio Generated in ${highlight(audio.timings + "s")}.` })],
|
||||
file: { value: audio.response.body, filename: "tts.wav" }
|
||||
})
|
||||
}catch(e){
|
||||
await context.editOrRespond({
|
||||
embeds: [createEmbed("error", context, "Unable to generate audio file.")]
|
||||
})
|
||||
}
|
||||
},
|
||||
};
|
43
commands/interaction/subcommands/tts/microsoft.js
Normal file
43
commands/interaction/subcommands/tts/microsoft.js
Normal file
|
@ -0,0 +1,43 @@
|
|||
const { Constants } = require('detritus-client');
|
||||
const { InteractionCallbackTypes, ApplicationCommandOptionTypes } = Constants;
|
||||
|
||||
const { sapi4 } = require('../../../../labscore/api');
|
||||
const { MICROSOFT_VOICES, MICROSOFT_VOICE_CONFIG } = require('../../../../labscore/constants');
|
||||
|
||||
const { createEmbed } = require('../../../../labscore/utils/embed');
|
||||
const { icon, highlight } = require('../../../../labscore/utils/markdown');
|
||||
|
||||
module.exports = {
|
||||
description: 'Text to Speech with microsoft voices',
|
||||
name: 'microsoft',
|
||||
type: ApplicationCommandOptionTypes.SUB_COMMAND,
|
||||
options: [
|
||||
{
|
||||
name: 'voice',
|
||||
description: 'TTS Voice to use',
|
||||
choices: MICROSOFT_VOICES,
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
name: 'text',
|
||||
description: 'Text',
|
||||
type: ApplicationCommandOptionTypes.STRING,
|
||||
required: true,
|
||||
maxLength: 256
|
||||
}
|
||||
],
|
||||
run: async (context, args) => {
|
||||
try{
|
||||
await context.respond({data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE})
|
||||
let audio = await sapi4(context, args.text, args.voice, MICROSOFT_VOICE_CONFIG[args.voice].pitch, MICROSOFT_VOICE_CONFIG[args.voice].speed)
|
||||
await context.editOrRespond({
|
||||
embeds: [createEmbed("defaultNoFooter", context, { description: `${icon("audio")} Audio Generated in ${highlight(audio.timings + "s")}.` })],
|
||||
file: { value: audio.response.body, filename: "tts.wav" }
|
||||
})
|
||||
}catch(e){
|
||||
await context.editOrRespond({
|
||||
embeds: [createEmbed("error", context, "Unable to generate audio file.")]
|
||||
})
|
||||
}
|
||||
},
|
||||
};
|
40
commands/interaction/subcommands/tts/moonbase.js
Normal file
40
commands/interaction/subcommands/tts/moonbase.js
Normal file
|
@ -0,0 +1,40 @@
|
|||
const { Constants } = require('detritus-client');
|
||||
const { InteractionCallbackTypes, ApplicationCommandOptionTypes } = Constants;
|
||||
|
||||
const { moonbase } = require('../../../../labscore/api');
|
||||
|
||||
const { createEmbed } = require('../../../../labscore/utils/embed');
|
||||
const { icon, highlight } = require('../../../../labscore/utils/markdown');
|
||||
|
||||
module.exports = {
|
||||
description: 'Moonbase Alpha text to speech voices',
|
||||
name: 'moonbase',
|
||||
type: ApplicationCommandOptionTypes.SUB_COMMAND,
|
||||
options: [
|
||||
{
|
||||
name: 'text',
|
||||
description: 'Text',
|
||||
type: ApplicationCommandOptionTypes.STRING,
|
||||
required: true,
|
||||
maxLength: 1024
|
||||
}
|
||||
],
|
||||
run: async (context, args) => {
|
||||
try {
|
||||
await context.respond({ data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE })
|
||||
|
||||
let audio = await moonbase(context, args.text, args.voice)
|
||||
|
||||
await context.editOrRespond({
|
||||
embeds: [createEmbed("defaultNoFooter", context, { description: `${icon("audio")} Audio Generated in ${highlight(audio.timings + "s")}.` })],
|
||||
file: { value: audio.response.body, filename: "moonbase.wav" }
|
||||
})
|
||||
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
await context.editOrRespond({
|
||||
embeds: [createEmbed("error", context, "Unable to generate audio file.")]
|
||||
})
|
||||
}
|
||||
},
|
||||
};
|
45
commands/interaction/subcommands/tts/playht.js
Normal file
45
commands/interaction/subcommands/tts/playht.js
Normal file
|
@ -0,0 +1,45 @@
|
|||
const { Constants } = require('detritus-client');
|
||||
const { InteractionCallbackTypes, ApplicationCommandOptionTypes } = Constants;
|
||||
|
||||
const { playht } = require('../../../../labscore/api');
|
||||
const { PLAYHT_VOICES } = require('../../../../labscore/constants');
|
||||
|
||||
const { createEmbed } = require('../../../../labscore/utils/embed');
|
||||
const { icon, highlight } = require('../../../../labscore/utils/markdown');
|
||||
|
||||
module.exports = {
|
||||
description: 'Text to Speech with playht voices',
|
||||
name: 'playht',
|
||||
type: ApplicationCommandOptionTypes.SUB_COMMAND,
|
||||
options: [
|
||||
{
|
||||
name: 'voice',
|
||||
description: 'Voice to use',
|
||||
choices: PLAYHT_VOICES,
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
name: 'text',
|
||||
description: 'Spoken Text',
|
||||
type: ApplicationCommandOptionTypes.STRING,
|
||||
required: true,
|
||||
maxLength: 256
|
||||
}
|
||||
],
|
||||
run: async (context, args) => {
|
||||
try{
|
||||
await context.respond({data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE})
|
||||
let audio = await playht(context, args.text, args.voice)
|
||||
|
||||
await context.editOrRespond({
|
||||
embeds: [createEmbed("defaultNoFooter", context, { description: `${icon("audio")} Audio Generated in ${highlight(audio.timings + "s")}.` })],
|
||||
file: { value: audio.response.body, filename: "tts.mp3" }
|
||||
})
|
||||
}catch(e){
|
||||
console.log(e)
|
||||
await context.editOrRespond({
|
||||
embeds: [createEmbed("error", context, "Unable to generate audio file.")]
|
||||
})
|
||||
}
|
||||
},
|
||||
};
|
47
commands/interaction/subcommands/tts/tiktok.js
Normal file
47
commands/interaction/subcommands/tts/tiktok.js
Normal file
|
@ -0,0 +1,47 @@
|
|||
const { Constants } = require('detritus-client');
|
||||
const { InteractionCallbackTypes, ApplicationCommandOptionTypes } = Constants;
|
||||
|
||||
const { tiktok } = require('../../../../labscore/api');
|
||||
const { TIKTOK_VOICES } = require('../../../../labscore/constants');
|
||||
|
||||
const { createEmbed } = require('../../../../labscore/utils/embed');
|
||||
const { icon, highlight } = require('../../../../labscore/utils/markdown');
|
||||
|
||||
module.exports = {
|
||||
description: 'TikTok text to speech voices',
|
||||
name: 'tiktok',
|
||||
type: ApplicationCommandOptionTypes.SUB_COMMAND,
|
||||
options: [
|
||||
{
|
||||
name: 'voice',
|
||||
description: 'TTS Voice to use',
|
||||
choices: TIKTOK_VOICES,
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
name: 'text',
|
||||
description: 'Text',
|
||||
type: ApplicationCommandOptionTypes.STRING,
|
||||
required: true,
|
||||
maxLength: 256
|
||||
}
|
||||
],
|
||||
run: async (context, args) => {
|
||||
try {
|
||||
await context.respond({ data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE })
|
||||
|
||||
let audio = await tiktok(context, args.text, args.voice)
|
||||
|
||||
await context.editOrRespond({
|
||||
embeds: [createEmbed("defaultNoFooter", context, { description: `${icon("audio")} Audio Generated in ${highlight(audio.timings + "s")}.` })],
|
||||
file: { value: audio.response.body, filename: "tiktok.mp3" }
|
||||
})
|
||||
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
await context.editOrRespond({
|
||||
embeds: [createEmbed("error", context, "Unable to generate audio file.")]
|
||||
})
|
||||
}
|
||||
},
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue