Spaces:
No application file
No application file
Commit ·
084172c
1
Parent(s): 2debebe
render wav
Browse files
main.js
CHANGED
|
@@ -436,6 +436,7 @@ async function generate(userMessage) {
|
|
| 436 |
if (result.audioCodes && result.audioCodes.length > 0) {
|
| 437 |
updateSpinner('Decoding audio...', `${result.audioCodes.length} frames`);
|
| 438 |
const waveform = await audioModel.decodeAudioCodes(result.audioCodes);
|
|
|
|
| 439 |
|
| 440 |
if (waveform.length > 0) {
|
| 441 |
generatedText = result.textOutput || `Generated ${result.audioCodes.length} audio frames (${(waveform.length / 24000).toFixed(2)}s)`;
|
|
@@ -444,15 +445,21 @@ async function generate(userMessage) {
|
|
| 444 |
const audioMsgEl = document.createElement('div');
|
| 445 |
audioMsgEl.className = 'message assistant';
|
| 446 |
const wavBlob = createWavBlob(waveform, 24000);
|
|
|
|
| 447 |
const audioUrl = URL.createObjectURL(wavBlob);
|
| 448 |
const audioEl = document.createElement('audio');
|
| 449 |
audioEl.src = audioUrl;
|
| 450 |
audioEl.controls = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 451 |
audioMsgEl.appendChild(audioEl);
|
| 452 |
chatContainer.appendChild(audioMsgEl);
|
| 453 |
chatContainer.scrollTop = chatContainer.scrollHeight;
|
| 454 |
} else {
|
| 455 |
generatedText = '[Audio decoding failed - no waveform generated]';
|
|
|
|
| 456 |
}
|
| 457 |
} else {
|
| 458 |
generatedText = result.textOutput || '[No audio generated]';
|
|
@@ -488,6 +495,7 @@ async function generate(userMessage) {
|
|
| 488 |
if (result.audioCodes && result.audioCodes.length > 0) {
|
| 489 |
updateSpinner('Decoding audio...', `${result.audioCodes.length} frames`);
|
| 490 |
const waveform = await audioModel.decodeAudioCodes(result.audioCodes);
|
|
|
|
| 491 |
|
| 492 |
if (waveform.length > 0) {
|
| 493 |
if (!generatedText) {
|
|
@@ -498,13 +506,20 @@ async function generate(userMessage) {
|
|
| 498 |
const audioMsgEl = document.createElement('div');
|
| 499 |
audioMsgEl.className = 'message assistant';
|
| 500 |
const wavBlob = createWavBlob(waveform, 24000);
|
|
|
|
| 501 |
const audioUrl = URL.createObjectURL(wavBlob);
|
| 502 |
const audioEl = document.createElement('audio');
|
| 503 |
audioEl.src = audioUrl;
|
| 504 |
audioEl.controls = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 505 |
audioMsgEl.appendChild(audioEl);
|
| 506 |
chatContainer.appendChild(audioMsgEl);
|
| 507 |
chatContainer.scrollTop = chatContainer.scrollHeight;
|
|
|
|
|
|
|
| 508 |
}
|
| 509 |
}
|
| 510 |
|
|
|
|
| 436 |
if (result.audioCodes && result.audioCodes.length > 0) {
|
| 437 |
updateSpinner('Decoding audio...', `${result.audioCodes.length} frames`);
|
| 438 |
const waveform = await audioModel.decodeAudioCodes(result.audioCodes);
|
| 439 |
+
console.log('TTS waveform decoded:', waveform.length, 'samples');
|
| 440 |
|
| 441 |
if (waveform.length > 0) {
|
| 442 |
generatedText = result.textOutput || `Generated ${result.audioCodes.length} audio frames (${(waveform.length / 24000).toFixed(2)}s)`;
|
|
|
|
| 445 |
const audioMsgEl = document.createElement('div');
|
| 446 |
audioMsgEl.className = 'message assistant';
|
| 447 |
const wavBlob = createWavBlob(waveform, 24000);
|
| 448 |
+
console.log('TTS WAV blob created:', wavBlob.size, 'bytes');
|
| 449 |
const audioUrl = URL.createObjectURL(wavBlob);
|
| 450 |
const audioEl = document.createElement('audio');
|
| 451 |
audioEl.src = audioUrl;
|
| 452 |
audioEl.controls = true;
|
| 453 |
+
audioEl.preload = 'auto';
|
| 454 |
+
audioEl.style.display = 'block';
|
| 455 |
+
audioEl.style.width = '100%';
|
| 456 |
+
audioEl.style.maxWidth = '360px';
|
| 457 |
audioMsgEl.appendChild(audioEl);
|
| 458 |
chatContainer.appendChild(audioMsgEl);
|
| 459 |
chatContainer.scrollTop = chatContainer.scrollHeight;
|
| 460 |
} else {
|
| 461 |
generatedText = '[Audio decoding failed - no waveform generated]';
|
| 462 |
+
console.warn('TTS waveform decoding returned empty result');
|
| 463 |
}
|
| 464 |
} else {
|
| 465 |
generatedText = result.textOutput || '[No audio generated]';
|
|
|
|
| 495 |
if (result.audioCodes && result.audioCodes.length > 0) {
|
| 496 |
updateSpinner('Decoding audio...', `${result.audioCodes.length} frames`);
|
| 497 |
const waveform = await audioModel.decodeAudioCodes(result.audioCodes);
|
| 498 |
+
console.log('Waveform decoded:', waveform.length, 'samples');
|
| 499 |
|
| 500 |
if (waveform.length > 0) {
|
| 501 |
if (!generatedText) {
|
|
|
|
| 506 |
const audioMsgEl = document.createElement('div');
|
| 507 |
audioMsgEl.className = 'message assistant';
|
| 508 |
const wavBlob = createWavBlob(waveform, 24000);
|
| 509 |
+
console.log('WAV blob created:', wavBlob.size, 'bytes');
|
| 510 |
const audioUrl = URL.createObjectURL(wavBlob);
|
| 511 |
const audioEl = document.createElement('audio');
|
| 512 |
audioEl.src = audioUrl;
|
| 513 |
audioEl.controls = true;
|
| 514 |
+
audioEl.preload = 'auto';
|
| 515 |
+
audioEl.style.display = 'block';
|
| 516 |
+
audioEl.style.width = '100%';
|
| 517 |
+
audioEl.style.maxWidth = '360px';
|
| 518 |
audioMsgEl.appendChild(audioEl);
|
| 519 |
chatContainer.appendChild(audioMsgEl);
|
| 520 |
chatContainer.scrollTop = chatContainer.scrollHeight;
|
| 521 |
+
} else {
|
| 522 |
+
console.warn('Waveform decoding returned empty result');
|
| 523 |
}
|
| 524 |
}
|
| 525 |
|