randomize voice
This commit is contained in:
parent
b64bd58c29
commit
4b57345117
2 changed files with 22 additions and 2 deletions
|
@ -45,9 +45,19 @@ export class UserCommand extends Command {
|
||||||
: await interactionOrMessage.reply({ content: '🤔 Thinking... 🤔', fetchReply: true });
|
: await interactionOrMessage.reply({ content: '🤔 Thinking... 🤔', fetchReply: true });
|
||||||
|
|
||||||
try {
|
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({
|
const mp3 = await openai.audio.speech.create({
|
||||||
model: 'tts-1-hd',
|
model: 'tts-1-hd',
|
||||||
voice: 'shimmer',
|
voice: voices[Math.floor(Math.random() * voices.length)],
|
||||||
input: prompt
|
input: prompt
|
||||||
});
|
});
|
||||||
const mp3Buffer = Buffer.from(await mp3.arrayBuffer());
|
const mp3Buffer = Buffer.from(await mp3.arrayBuffer());
|
||||||
|
|
|
@ -45,9 +45,19 @@ export class UserCommand extends Command {
|
||||||
: await interactionOrMessage.reply({ content: '🤔 Thinking... 🤔', fetchReply: true });
|
: await interactionOrMessage.reply({ content: '🤔 Thinking... 🤔', fetchReply: true });
|
||||||
|
|
||||||
try {
|
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({
|
const mp3 = await openai.audio.speech.create({
|
||||||
model: 'tts-1',
|
model: 'tts-1',
|
||||||
voice: 'shimmer',
|
voice: voices[Math.floor(Math.random() * voices.length)],
|
||||||
input: prompt
|
input: prompt
|
||||||
});
|
});
|
||||||
const mp3Buffer = Buffer.from(await mp3.arrayBuffer());
|
const mp3Buffer = Buffer.from(await mp3.arrayBuffer());
|
||||||
|
|
Loading…
Add table
Reference in a new issue