Checkpoint current interactive fiction state
This commit is contained in:
@@ -185,15 +185,21 @@
|
||||
window.KokoroLoader.instance.generate(data.text, { voice: data.voice, speed: data.speed })
|
||||
.then(result => {
|
||||
log(`Generation successful for request ${data.id}`, 'success');
|
||||
|
||||
// Convert the result to a proper format for the parent window
|
||||
const audio = new Uint8Array(result.buffer);
|
||||
|
||||
|
||||
// Kokoro returns a Uint8Array directly, not an object with .buffer
|
||||
const audio = result instanceof Uint8Array ? result : new Uint8Array(result.buffer || result);
|
||||
log(`Audio data: ${audio.length} bytes (Uint8Array)`);
|
||||
|
||||
// Create a copy of the underlying ArrayBuffer
|
||||
const bufferCopy = audio.buffer.slice(0);
|
||||
log(`Sending audio buffer: ${bufferCopy.byteLength} bytes`);
|
||||
|
||||
window.parent.postMessage({
|
||||
type: 'kokoro-generated',
|
||||
id: data.id,
|
||||
success: true,
|
||||
result: { buffer: audio.buffer }
|
||||
result: { buffer: bufferCopy },
|
||||
duration: 0 // Duration not provided by Kokoro, will be estimated
|
||||
}, '*');
|
||||
})
|
||||
.catch(error => {
|
||||
|
||||
Reference in New Issue
Block a user