elevenlabs / elevenlabs-examples

https://elevenlabs.io/docs/api-reference/getting-started
MIT License
173 stars 50 forks source link

deno TTS aws s3 example is broken #57

Open khcd opened 4 weeks ago

khcd commented 4 weeks ago

examples/text-to-speech/deno/text-to-speech/text-to-speech-aws.ts

Screenshot 2024-10-18 at 11 00 30 am

current code results in data loss you can see via the files only sized in bytes

modified code to prevent data loss:

replace: const content = new Uint8Array(chunks.flat()); with: ` const totalLength = chunks.reduce((acc, chunk) => acc + chunk.length, 0); const content = new Uint8Array(totalLength);

let offset = 0; for (const chunk of chunks) { content.set(chunk, offset); offset += chunk.length; } `

above code is LLM suggested but I have functionally tested it.

Can submit PR if allowed.