Skip to content

Commit 92a32dd

Browse files
skip tts phrase when lang switches
1 parent 7881485 commit 92a32dd

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

wavefront/server/apps/call_processing/call_processing/services/pipecat_service.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -523,10 +523,15 @@ async def run_conversation(
523523
# Register event handlers
524524
@llm.event_handler('on_function_calls_started')
525525
async def on_function_calls_started(service, function_calls):
526+
# Skip filler phrase when language is switching — the TTS service's language
527+
# may change before the queued frame is processed, causing a language mismatch error.
528+
call_names = [fc.function_name for fc in function_calls]
529+
if 'detect_and_switch_language' in call_names:
530+
return
526531
current_lang = language_state.get('current_language', 'en')
527-
phrases = FILLER_PHRASES.get(
528-
current_lang, FILLER_PHRASES.get('en', ['Please wait a moment'])
529-
)
532+
phrases = FILLER_PHRASES.get(current_lang)
533+
if not phrases:
534+
return
530535
phrase = random.choice(phrases)
531536
await task.queue_frame(TTSSpeakFrame(phrase))
532537

0 commit comments

Comments
 (0)