randomize voice

This commit is contained in:
Atridad Lahiji 2023-11-12 22:36:54 -07:00
parent b64bd58c29
commit 4b57345117
No known key found for this signature in database
2 changed files with 22 additions and 2 deletions

View file

@ -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());

View file

@ -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());