Skip to content

Commit

Permalink
Fix Neets TTS
Browse files Browse the repository at this point in the history
  • Loading branch information
alamshafil committed Aug 1, 2024
1 parent f527a82 commit 6d3731e
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/tts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,15 @@ export class NeetsTTSVoice extends VoiceGen {
(options.neetsTTSOptions?.maleVoice ?? "us-male-2") :
(options.neetsTTSOptions?.femaleVoice ?? "us-female-2");

const data = JSON.stringify({
text: options.text,
voice_id: voiceModel,
fmt: "wav",
params: {
model: options.neetsTTSOptions?.voiceModel ?? "style-diff-500"
}
});

const response = await fetch(
'https://api.neets.ai/v1/tts',
{
Expand All @@ -151,16 +160,14 @@ export class NeetsTTSVoice extends VoiceGen {
'Content-Type': 'application/json',
'X-API-Key': apiKey
},
body: JSON.stringify({
text: options.text,
voice_id: voiceModel,
params: {
model: options.neetsTTSOptions?.voiceModel ?? "style-diff-500"
}
})
body: data,
}
);

if (!response.ok) {
throw new Error(`NeetsTTS API error: ${response.statusText}.`);
}

const buffer = await response.arrayBuffer();
fs.writeFileSync(options.filename, Buffer.from(buffer));

Expand Down

0 comments on commit 6d3731e

Please sign in to comment.