Open khcd opened 4 weeks ago
examples/text-to-speech/deno/text-to-speech/text-to-speech-aws.ts
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);
const content = new Uint8Array(chunks.flat());
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.
examples/text-to-speech/deno/text-to-speech/text-to-speech-aws.ts
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.