ciyidogan commited on
Commit
9c4de2d
·
verified ·
1 Parent(s): 61eaacc

Update websocket_handler.py

Browse files
Files changed (1) hide show
  1. websocket_handler.py +6 -9
websocket_handler.py CHANGED
@@ -491,7 +491,7 @@ async def handle_audio_chunk(websocket: WebSocket, session: RealtimeSession, mes
491
  # Decode for processing
492
  decoded_audio = base64.b64decode(audio_data)
493
 
494
- # Check silence - LOGLAMA YAPMA
495
  silence_duration = session.silence_detector.update(decoded_audio)
496
 
497
  # Stream to STT if available
@@ -510,7 +510,7 @@ async def handle_audio_chunk(websocket: WebSocket, session: RealtimeSession, mes
510
  return
511
 
512
  try:
513
- # Chunk counter - sadece önemli milestone'larda logla
514
  if not hasattr(session, 'chunk_counter'):
515
  session.chunk_counter = 0
516
  session.chunk_counter += 1
@@ -522,7 +522,7 @@ async def handle_audio_chunk(websocket: WebSocket, session: RealtimeSession, mes
522
 
523
  # STT'ye gönder ve sonuçları bekle
524
  async for result in session.stt_manager.stream_audio(decoded_audio):
525
- # SADECE FINAL RESULT'LARI LOGLA VE GÖNDER
526
  if result.is_final:
527
  log_info(f"✅ FINAL TRANSCRIPTION: '{result.text}'", session_id=session.session.session_id)
528
 
@@ -549,14 +549,11 @@ async def handle_audio_chunk(websocket: WebSocket, session: RealtimeSession, mes
549
  # Process user input
550
  await process_user_input(websocket, session)
551
 
552
- # STT'den final result geldiğinde audio buffer'ı ve transcription'ı resetle
553
  await session.reset_for_new_utterance()
554
- return # Bu audio chunk için işlem tamamlandı
555
 
556
- # Interim result'ları SADECE ilk kelimede logla (konuşma başlangıcı)
557
- elif result.text.strip() and not hasattr(session, 'speech_started'):
558
- session.speech_started = True
559
- log_info(f"🎤 User started speaking", session_id=session.session.session_id)
560
 
561
  except Exception as e:
562
  log_error(f"❌ STT streaming error", error=str(e), traceback=traceback.format_exc(), session_id=session.session.session_id)
 
491
  # Decode for processing
492
  decoded_audio = base64.b64decode(audio_data)
493
 
494
+ # Check silence
495
  silence_duration = session.silence_detector.update(decoded_audio)
496
 
497
  # Stream to STT if available
 
510
  return
511
 
512
  try:
513
+ # Chunk counter
514
  if not hasattr(session, 'chunk_counter'):
515
  session.chunk_counter = 0
516
  session.chunk_counter += 1
 
522
 
523
  # STT'ye gönder ve sonuçları bekle
524
  async for result in session.stt_manager.stream_audio(decoded_audio):
525
+ # SADECE FINAL RESULT'LARI İŞLE
526
  if result.is_final:
527
  log_info(f"✅ FINAL TRANSCRIPTION: '{result.text}'", session_id=session.session.session_id)
528
 
 
549
  # Process user input
550
  await process_user_input(websocket, session)
551
 
552
+ # Reset for new utterance
553
  await session.reset_for_new_utterance()
554
+ return
555
 
556
+ # Interim result'ları artık göndermiyoruz ve loglama yapmıyoruz
 
 
 
557
 
558
  except Exception as e:
559
  log_error(f"❌ STT streaming error", error=str(e), traceback=traceback.format_exc(), session_id=session.session.session_id)