Add diagnostic logging to streaming TTS
This commit is contained in:
parent
46048a3251
commit
8dffac24f9
1 changed files with 5 additions and 0 deletions
|
|
@ -154,6 +154,7 @@ export async function speakTextStreaming(text, voice = "alloy", rate = 0.9, mode
|
|||
|
||||
console.log(`TTS streaming: canStream=${canStream}, format=${requestFormat}, mseMime=${mseMime}`);
|
||||
|
||||
console.log("TTS streaming: fetching audio...");
|
||||
const response = await fetch(TTS_API_URL, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
|
|
@ -168,6 +169,8 @@ export async function speakTextStreaming(text, voice = "alloy", rate = 0.9, mode
|
|||
}),
|
||||
});
|
||||
|
||||
console.log(`TTS streaming: fetch response ${response.status}`);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
|
|
@ -187,6 +190,7 @@ export async function speakTextStreaming(text, voice = "alloy", rate = 0.9, mode
|
|||
const audioUrl = URL.createObjectURL(mediaSource);
|
||||
const audio = new Audio(audioUrl);
|
||||
audio.playbackRate = rate;
|
||||
console.log(`TTS streaming: MediaSource created, readyState=${mediaSource.readyState}`);
|
||||
|
||||
// Collect all chunks for download later
|
||||
const chunks = [];
|
||||
|
|
@ -194,6 +198,7 @@ export async function speakTextStreaming(text, voice = "alloy", rate = 0.9, mode
|
|||
// done resolves when the full stream has been received and appended
|
||||
const done = new Promise((resolve, reject) => {
|
||||
mediaSource.addEventListener('sourceopen', async () => {
|
||||
console.log("TTS streaming: sourceopen fired");
|
||||
let sourceBuffer;
|
||||
try {
|
||||
sourceBuffer = mediaSource.addSourceBuffer(mseMime);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue