-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
34 lines (29 loc) · 923 Bytes
/
test.js
File metadata and controls
34 lines (29 loc) · 923 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { TextToSpeechApi, Configuration } from "./dist/index.js"
import fs from "fs"
console.assert(process.env.SOME_SECRET)
const apiConfig = new Configuration({
apiKey: process.env.SOME_SECRET,
})
const tts = new TextToSpeechApi(apiConfig)
const res = await tts.textToSpeechV1TextToSpeechVoiceIdPost(
{
voiceId: "21m00Tcm4TlvDq8ikWAM",
// voiceId: "M4S31aOB9yV0JSy1XX3B",
optimizeStreamingLatency: 0,
bodyTextToSpeechV1TextToSpeechVoiceIdPost: {
text: "helllo babeee",
modelId: "eleven_multilingual_v2",
voice_settings: {
stability: 0.35,
similarity_boost: 0.75, // clarity
style: 0.25,
use_speaker_boost: true,
},
}
},
{
responseType: "arraybuffer",
}
)
console.log(res.statusText)
fs.writeFileSync("output.mp3", Buffer.from(res.data))