ciyidogan commited on
Commit
2c24799
·
verified ·
1 Parent(s): 913182c

Update chat_session/state_orchestrator.py

Browse files
Files changed (1) hide show
  1. chat_session/state_orchestrator.py +11 -31
chat_session/state_orchestrator.py CHANGED
@@ -283,21 +283,10 @@ class StateOrchestrator:
283
 
284
  current_state = context.state
285
  result_data = event.data
286
- is_final = result_data.get("is_final", False)
287
-
288
- # Interim result'ları websocket'e gönder ama state değiştirme
289
- if not is_final:
290
- # Sadece log, state değişikliği yok
291
- text = result_data.get("text", "").strip()
292
- if text:
293
- log_debug(f"📝 Interim transcription: '{text}'", session_id=session_id)
294
- return
295
-
296
- # Final result işleme
297
  text = result_data.get("text", "").strip()
298
- if not text:
299
- log_warning(f"⚠️ Empty final transcription", session_id=session_id)
300
-
301
  if current_state != ConversationState.LISTENING:
302
  log_warning(
303
  f"⚠️ STT result in unexpected state",
@@ -306,27 +295,18 @@ class StateOrchestrator:
306
  )
307
  return
308
 
309
- # Text boş olsa bile log at
310
  if text:
311
- log_info(f"💬 Final transcription: '{text}'", session_id=session_id)
312
  else:
313
- log_info(f"💬 Final transcription: (silence detected)", session_id=session_id)
314
-
315
- # ✅ Boş transcript'te STT'yi yeniden başlatmaya gerek yok
316
- # ✅ Deepgram zaten continuous listening modunda çalışıyor
317
- if not text:
318
- # Sadece log at ve devam et
319
- log_debug(f"🔄 Continuing to listen after silence", session_id=session_id)
320
  return
321
 
322
- # ✅ Sadece gerçek text varsa STT'yi durdur ve LLM'e gönder
323
- # STT'yi durdur
324
- await self.event_bus.publish(Event(
325
- type=EventType.STT_STOPPED,
326
- session_id=session_id,
327
- data={"reason": "utterance_completed"}
328
- ))
329
-
330
  # Transition to processing
331
  await self.transition_to(session_id, ConversationState.PROCESSING_SPEECH)
332
 
 
283
 
284
  current_state = context.state
285
  result_data = event.data
286
+
287
+ # Batch mode'da her zaman final result gelir
 
 
 
 
 
 
 
 
 
288
  text = result_data.get("text", "").strip()
289
+
 
 
290
  if current_state != ConversationState.LISTENING:
291
  log_warning(
292
  f"⚠️ STT result in unexpected state",
 
295
  )
296
  return
297
 
 
298
  if text:
299
+ log_info(f"💬 Transcription: '{text}'", session_id=session_id)
300
  else:
301
+ log_info(f"💬 No speech detected", session_id=session_id)
302
+ # Boş transcript'te STT'yi yeniden başlat
303
+ await self.event_bus.publish(Event(
304
+ type=EventType.STT_STARTED,
305
+ session_id=session_id,
306
+ data={}
307
+ ))
308
  return
309
 
 
 
 
 
 
 
 
 
310
  # Transition to processing
311
  await self.transition_to(session_id, ConversationState.PROCESSING_SPEECH)
312