ciyidogan commited on
Commit
7271976
·
verified ·
1 Parent(s): 09b4da2

Update chat_session/state_orchestrator.py

Browse files
Files changed (1) hide show
  1. chat_session/state_orchestrator.py +10 -11
chat_session/state_orchestrator.py CHANGED
@@ -377,36 +377,35 @@ class StateOrchestrator:
377
  """Handle audio playback completion"""
378
  session_id = event.session_id
379
  context = self.sessions.get(session_id)
380
-
381
  if not context:
382
  return
383
-
384
  current_state = context.state
385
-
386
  log_info(f"🎵 Audio playback completed", session_id=session_id, state=current_state.value)
387
-
388
  if current_state in [ConversationState.PLAYING_WELCOME, ConversationState.PLAYING_RESPONSE]:
389
  # Transition to listening
390
  await self.transition_to(session_id, ConversationState.LISTENING)
391
-
392
- # ✅ STT'yi başlat - tek konuşma modunda
393
  locale = context.metadata.get("locale", "tr")
394
  await self.event_bus.publish(Event(
395
  type=EventType.STT_STARTED,
396
  session_id=session_id,
397
  data={
398
  "locale": locale,
399
- "single_utterance": True, # ✅ Tek konuşma modu
400
- "interim_results": False, # Sadece final
401
- "speech_timeout_ms": 2000 # 2 saniye sessizlik
402
  }
403
  ))
404
-
405
  # Send STT ready signal to frontend
406
  await self.event_bus.publish(Event(
407
  type=EventType.STT_READY,
408
  session_id=session_id,
409
- data={}
410
  ))
411
 
412
  async def _handle_stt_error(self, event: Event):
 
377
  """Handle audio playback completion"""
378
  session_id = event.session_id
379
  context = self.sessions.get(session_id)
380
+
381
  if not context:
382
  return
383
+
384
  current_state = context.state
385
+
386
  log_info(f"🎵 Audio playback completed", session_id=session_id, state=current_state.value)
387
+
388
  if current_state in [ConversationState.PLAYING_WELCOME, ConversationState.PLAYING_RESPONSE]:
389
  # Transition to listening
390
  await self.transition_to(session_id, ConversationState.LISTENING)
391
+
392
+ # ✅ STT'yi başlat - batch mode için yeni utterance
393
  locale = context.metadata.get("locale", "tr")
394
  await self.event_bus.publish(Event(
395
  type=EventType.STT_STARTED,
396
  session_id=session_id,
397
  data={
398
  "locale": locale,
399
+ "batch_mode": True, # ✅ Batch mode aktif
400
+ "silence_threshold_ms": 2000 # 2 saniye sessizlik
 
401
  }
402
  ))
403
+
404
  # Send STT ready signal to frontend
405
  await self.event_bus.publish(Event(
406
  type=EventType.STT_READY,
407
  session_id=session_id,
408
+ data={"ready_for_audio": True}
409
  ))
410
 
411
  async def _handle_stt_error(self, event: Event):