From 6097695561a03382d4d9f64a17318791646bdd54 Mon Sep 17 00:00:00 2001 From: derpystuff <3515180-derpystuff@users.noreply.gitlab.com> Date: Thu, 6 Oct 2022 21:56:35 +0200 Subject: [PATCH] new tts funny gauzi voice --- commands/interaction/tts/texttospeech2.js | 44 +++++++++++++++++++++++ labscore/api/endpoints.js | 1 + labscore/api/index.js | 7 ++++ labscore/constants.js | 7 ++++ 4 files changed, 59 insertions(+) create mode 100644 commands/interaction/tts/texttospeech2.js diff --git a/commands/interaction/tts/texttospeech2.js b/commands/interaction/tts/texttospeech2.js new file mode 100644 index 0000000..1967cbe --- /dev/null +++ b/commands/interaction/tts/texttospeech2.js @@ -0,0 +1,44 @@ +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: 'more text to speech', + name: 'tts2', + 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.wav" } + }) + }catch(e){ + console.log(e) + await context.editOrRespond({ + embeds: [createEmbed("error", context, "Unable to generate audio file.")] + }) + } + }, +}; \ No newline at end of file diff --git a/labscore/api/endpoints.js b/labscore/api/endpoints.js index af0cfd9..255a5d6 100644 --- a/labscore/api/endpoints.js +++ b/labscore/api/endpoints.js @@ -40,6 +40,7 @@ const Api = Object.freeze({ SEARCH_YOUTUBE: '/search/youtube', TTS_IMTRANSLATOR: '/tts/imtranslator', + TTS_PLAYHT: '/tts/playht', TTS_POLLY: '/tts/polly', TTS_TIKTOK: '/tts/tiktok', TTS_VOICEFORGE: '/tts/voiceforge', diff --git a/labscore/api/index.js b/labscore/api/index.js index da78ffb..93dc8b6 100644 --- a/labscore/api/index.js +++ b/labscore/api/index.js @@ -229,6 +229,13 @@ module.exports.imtranslator = async function(context, text, voice){ }) } +module.exports.playht = async function(context, text, voice){ + return await request(Api.TTS_PLAYHT, "GET", {}, { + text: text, + voice: voice + }) +} + module.exports.polly = async function(context, text, voice){ return await request(Api.TTS_POLLY, "GET", {}, { text: text, diff --git a/labscore/constants.js b/labscore/constants.js index 487f458..6918524 100644 --- a/labscore/constants.js +++ b/labscore/constants.js @@ -410,6 +410,13 @@ module.exports.TIKTOK_VOICES = [ } ] +module.exports.PLAYHT_VOICES = [ + { + "name": "Conrad (German)", + "value": "de-DE-ConradNeural" + } +] + module.exports.IMTRANSLATOR_VOICES = [ { "name": "English (Male)",