Spaces:
Building
Building
Update flare-ui/src/app/services/conversation-manager.service.ts
Browse files
flare-ui/src/app/services/conversation-manager.service.ts
CHANGED
@@ -444,6 +444,14 @@ export class ConversationManagerService implements OnDestroy {
|
|
444 |
return;
|
445 |
}
|
446 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
447 |
// Check if we need to accumulate chunks
|
448 |
if (!message['is_last']) {
|
449 |
// Accumulate audio chunks
|
@@ -455,6 +463,12 @@ export class ConversationManagerService implements OnDestroy {
|
|
455 |
this.audioQueue.push(message['data']); // Add last chunk
|
456 |
const audioData = this.audioQueue.join('');
|
457 |
|
|
|
|
|
|
|
|
|
|
|
|
|
458 |
try {
|
459 |
// Default to MP3 if mime_type not provided
|
460 |
const mimeType = message['mime_type'] || 'audio/mpeg';
|
@@ -479,20 +493,6 @@ export class ConversationManagerService implements OnDestroy {
|
|
479 |
} catch (error) {
|
480 |
console.error('Error creating audio blob:', error);
|
481 |
this.audioQueue = []; // Clear queue on error
|
482 |
-
|
483 |
-
// Try direct blob creation as fallback
|
484 |
-
try {
|
485 |
-
const fallbackBlob = new Blob([atob(audioData)], { type: 'audio/mpeg' });
|
486 |
-
const audioUrl = URL.createObjectURL(fallbackBlob);
|
487 |
-
|
488 |
-
const messages = this.messagesSubject.value;
|
489 |
-
if (messages.length > 0 && messages[messages.length - 1].role === 'assistant') {
|
490 |
-
messages[messages.length - 1].audioUrl = audioUrl;
|
491 |
-
this.messagesSubject.next([...messages]);
|
492 |
-
}
|
493 |
-
} catch (fallbackError) {
|
494 |
-
console.error('Fallback audio creation also failed:', fallbackError);
|
495 |
-
}
|
496 |
}
|
497 |
} catch (error) {
|
498 |
console.error('Error handling TTS audio:', error);
|
|
|
444 |
return;
|
445 |
}
|
446 |
|
447 |
+
// Debug log
|
448 |
+
console.log('TTS chunk received:', {
|
449 |
+
dataLength: message['data'].length,
|
450 |
+
dataPreview: message['data'].substring(0, 50),
|
451 |
+
isLast: message['is_last'],
|
452 |
+
mimeType: message['mime_type']
|
453 |
+
});
|
454 |
+
|
455 |
// Check if we need to accumulate chunks
|
456 |
if (!message['is_last']) {
|
457 |
// Accumulate audio chunks
|
|
|
463 |
this.audioQueue.push(message['data']); // Add last chunk
|
464 |
const audioData = this.audioQueue.join('');
|
465 |
|
466 |
+
// Debug combined data
|
467 |
+
console.log('Combined audio data:', {
|
468 |
+
totalLength: audioData.length,
|
469 |
+
preview: audioData.substring(0, 50)
|
470 |
+
});
|
471 |
+
|
472 |
try {
|
473 |
// Default to MP3 if mime_type not provided
|
474 |
const mimeType = message['mime_type'] || 'audio/mpeg';
|
|
|
493 |
} catch (error) {
|
494 |
console.error('Error creating audio blob:', error);
|
495 |
this.audioQueue = []; // Clear queue on error
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
496 |
}
|
497 |
} catch (error) {
|
498 |
console.error('Error handling TTS audio:', error);
|