Spaces:
Running
Running
Update flare-ui/src/app/services/conversation-manager.service.ts
Browse files
flare-ui/src/app/services/conversation-manager.service.ts
CHANGED
@@ -113,13 +113,6 @@ export class ConversationManagerService implements OnDestroy {
|
|
113 |
continuous_listening: true
|
114 |
});
|
115 |
|
116 |
-
// Start audio recording for continuous listening
|
117 |
-
await this.audioService.startRecording().catch(error => {
|
118 |
-
// Disconnect WebSocket if audio fails
|
119 |
-
this.wsService.disconnect();
|
120 |
-
throw new Error(`Audio recording failed: ${error.message}`);
|
121 |
-
});
|
122 |
-
|
123 |
console.log('✅ Conversation started with continuous listening enabled');
|
124 |
|
125 |
} catch (error: any) {
|
@@ -323,15 +316,6 @@ export class ConversationManagerService implements OnDestroy {
|
|
323 |
this.transcriptionSubject.next('');
|
324 |
}
|
325 |
|
326 |
-
// listening state'ine geçerken audio recording'in açık olduğundan emin ol
|
327 |
-
if (to === 'listening' && !this.audioService.isRecording()) {
|
328 |
-
console.log('⚠️ Entered listening state but audio not recording, starting...');
|
329 |
-
this.audioService.startRecording().catch(error => {
|
330 |
-
console.error('Failed to start audio recording in listening state:', error);
|
331 |
-
this.handleAudioError(error);
|
332 |
-
});
|
333 |
-
}
|
334 |
-
|
335 |
// Log state changes for debugging
|
336 |
console.log(`🎤 Continuous listening mode - state: ${to}`);
|
337 |
}
|
@@ -390,18 +374,23 @@ export class ConversationManagerService implements OnDestroy {
|
|
390 |
this.wsService.sendControl('audio_ended');
|
391 |
}
|
392 |
|
393 |
-
//
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
|
|
|
|
|
|
|
|
|
|
405 |
|
406 |
} catch (error) {
|
407 |
console.error('❌ Failed to restart audio recording after TTS:', error);
|
|
|
113 |
continuous_listening: true
|
114 |
});
|
115 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
console.log('✅ Conversation started with continuous listening enabled');
|
117 |
|
118 |
} catch (error: any) {
|
|
|
316 |
this.transcriptionSubject.next('');
|
317 |
}
|
318 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
319 |
// Log state changes for debugging
|
320 |
console.log(`🎤 Continuous listening mode - state: ${to}`);
|
321 |
}
|
|
|
374 |
this.wsService.sendControl('audio_ended');
|
375 |
}
|
376 |
|
377 |
+
// Sadece listening state'indeyken recording başlat
|
378 |
+
if (this.currentStateSubject.value === 'listening' ||
|
379 |
+
this.currentStateSubject.value === 'playing_audio') {
|
380 |
+
|
381 |
+
console.log('🔄 Starting audio recording after TTS...');
|
382 |
+
|
383 |
+
// İlk kez mi başlatıyoruz kontrol et
|
384 |
+
if (this.audioService.isRecording()) {
|
385 |
+
// Zaten recording varsa, önce durdur
|
386 |
+
this.audioService.stopRecording();
|
387 |
+
await new Promise(resolve => setTimeout(resolve, 500));
|
388 |
+
}
|
389 |
+
|
390 |
+
// Recording başlat
|
391 |
+
await this.audioService.startRecording();
|
392 |
+
console.log('✅ Audio recording started successfully');
|
393 |
+
}
|
394 |
|
395 |
} catch (error) {
|
396 |
console.error('❌ Failed to restart audio recording after TTS:', error);
|