Spaces:
Running
Running
Update websocket_handler.py
Browse files- websocket_handler.py +4 -3
websocket_handler.py
CHANGED
@@ -648,6 +648,8 @@ async def handle_audio_chunk(websocket: WebSocket, session: RealtimeSession, mes
|
|
648 |
else:
|
649 |
log_warning(f"⚠️ Unknown audio format, first 4 bytes: {decoded_audio[:4].hex()}", session_id=session.session.session_id)
|
650 |
# Format hatalıysa buffer'ı temizle ve chunk counter'ı resetle
|
|
|
|
|
651 |
await session.stop_stt_streaming()
|
652 |
await session.restart_stt_if_needed()
|
653 |
return
|
@@ -685,9 +687,6 @@ async def handle_audio_chunk(websocket: WebSocket, session: RealtimeSession, mes
|
|
685 |
|
686 |
# Process user input
|
687 |
await process_user_input(websocket, session)
|
688 |
-
|
689 |
-
# Reset for new utterance
|
690 |
-
await session.reset_for_new_utterance()
|
691 |
return
|
692 |
|
693 |
except Exception as e:
|
@@ -791,6 +790,8 @@ async def process_user_input(websocket: WebSocket, session: RealtimeSession):
|
|
791 |
log_warning(f"⚠️ Empty transcription, returning to listening", session_id=session.session.session_id)
|
792 |
# Boş transcription durumunda listening'e dön ve STT'yi yeniden başlat
|
793 |
await session.change_state(ConversationState.LISTENING)
|
|
|
|
|
794 |
await session.restart_stt_if_needed()
|
795 |
return
|
796 |
|
|
|
648 |
else:
|
649 |
log_warning(f"⚠️ Unknown audio format, first 4 bytes: {decoded_audio[:4].hex()}", session_id=session.session.session_id)
|
650 |
# Format hatalıysa buffer'ı temizle ve chunk counter'ı resetle
|
651 |
+
await session.audio_buffer.clear()
|
652 |
+
session.chunk_counter = 0
|
653 |
await session.stop_stt_streaming()
|
654 |
await session.restart_stt_if_needed()
|
655 |
return
|
|
|
687 |
|
688 |
# Process user input
|
689 |
await process_user_input(websocket, session)
|
|
|
|
|
|
|
690 |
return
|
691 |
|
692 |
except Exception as e:
|
|
|
790 |
log_warning(f"⚠️ Empty transcription, returning to listening", session_id=session.session.session_id)
|
791 |
# Boş transcription durumunda listening'e dön ve STT'yi yeniden başlat
|
792 |
await session.change_state(ConversationState.LISTENING)
|
793 |
+
await session.audio_buffer.clear()
|
794 |
+
await session.reset_for_new_utterance()
|
795 |
await session.restart_stt_if_needed()
|
796 |
return
|
797 |
|