From 4b573451172d73af65a422d2ad7ed5b59a567a3a Mon Sep 17 00:00:00 2001 From: atridadl Date: Sun, 12 Nov 2023 22:36:54 -0700 Subject: [PATCH] randomize voice --- src/commands/fancytts.ts | 12 +++++++++++- src/commands/tts.ts | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/commands/fancytts.ts b/src/commands/fancytts.ts index 3e49d8a..5833033 100644 --- a/src/commands/fancytts.ts +++ b/src/commands/fancytts.ts @@ -45,9 +45,19 @@ export class UserCommand extends Command { : await interactionOrMessage.reply({ content: '🤔 Thinking... 🤔', fetchReply: true }); try { + enum voice { + alloy = 'alloy', + echo = 'echo', + fable = 'fable', + onyx = 'onyx', + nova = 'nova', + shimmer = 'shimmer' + } + + const voices = [voice.alloy, voice.echo, voice.fable, voice.onyx, voice.nova, voice.shimmer]; const mp3 = await openai.audio.speech.create({ model: 'tts-1-hd', - voice: 'shimmer', + voice: voices[Math.floor(Math.random() * voices.length)], input: prompt }); const mp3Buffer = Buffer.from(await mp3.arrayBuffer()); diff --git a/src/commands/tts.ts b/src/commands/tts.ts index b8fbf74..afe55a9 100644 --- a/src/commands/tts.ts +++ b/src/commands/tts.ts @@ -45,9 +45,19 @@ export class UserCommand extends Command { : await interactionOrMessage.reply({ content: '🤔 Thinking... 🤔', fetchReply: true }); try { + enum voice { + alloy = 'alloy', + echo = 'echo', + fable = 'fable', + onyx = 'onyx', + nova = 'nova', + shimmer = 'shimmer' + } + + const voices = [voice.alloy, voice.echo, voice.fable, voice.onyx, voice.nova, voice.shimmer]; const mp3 = await openai.audio.speech.create({ model: 'tts-1', - voice: 'shimmer', + voice: voices[Math.floor(Math.random() * voices.length)], input: prompt }); const mp3Buffer = Buffer.from(await mp3.arrayBuffer());