mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-10 07:03:08 -04:00
microsoft sam tts
This commit is contained in:
parent
cc972e985b
commit
23fc15fccf
4 changed files with 72 additions and 0 deletions
42
commands/interaction/tts/microsoft.js
Normal file
42
commands/interaction/tts/microsoft.js
Normal file
|
@ -0,0 +1,42 @@
|
|||
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: 'Microsoft Sam Text to Speech',
|
||||
name: 'mstts',
|
||||
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.")]
|
||||
})
|
||||
}
|
||||
},
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue