chore: fix

Signed-off-by: Neko Ayaka <neko@ayaka.moe>
This commit is contained in:
Neko Ayaka
2024-12-02 21:09:19 +08:00
parent 8b1338c123
commit 87e8413fa0
3 changed files with 29 additions and 29 deletions
+26 -26
View File
@@ -1,30 +1,30 @@
import { ElevenLabsClient } from 'elevenlabs'
// import { ElevenLabsClient } from 'elevenlabs'
export default defineEventHandler(async (event) => {
const body = await readBody<{ text: string, apiKey: string }>(event)
const client = new ElevenLabsClient({
apiKey: body.apiKey,
})
// export default defineEventHandler(async (event) => {
// const body = await readBody<{ text: string, apiKey: string }>(event)
// const client = new ElevenLabsClient({
// apiKey: body.apiKey,
// })
const res = await client.generate({
// voice: 'ShanShan',
// Quite good for English
voice: 'Myriam',
// Beatrice is not 'childish' like the others
// voice: 'Beatrice',
text: body.text,
stream: true,
model_id: 'eleven_multilingual_v2',
voice_settings: {
stability: 0.4,
similarity_boost: 0.5,
},
})
// const res = await client.generate({
// // voice: 'ShanShan',
// // Quite good for English
// voice: 'Myriam',
// // Beatrice is not 'childish' like the others
// // voice: 'Beatrice',
// text: body.text,
// stream: true,
// model_id: 'eleven_multilingual_v2',
// voice_settings: {
// stability: 0.4,
// similarity_boost: 0.5,
// },
// })
// Set headers for streaming
event.node.res.setHeader('Content-Type', 'audio/mpeg')
event.node.res.setHeader('Transfer-Encoding', 'chunked')
// // Set headers for streaming
// event.node.res.setHeader('Content-Type', 'audio/mpeg')
// event.node.res.setHeader('Transfer-Encoding', 'chunked')
// res is NodeJS.ReadableStream
return sendStream(event, res)
})
// // res is NodeJS.ReadableStream
// return sendStream(event, res)
// })