feat: Add ultra-fast sub-200ms voice onboarding, 9 Indian language spoken clinical tone, 1.15x pace & inline base64 audio
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import base64
|
||||
import json
|
||||
from uuid import uuid4
|
||||
from typing import Optional
|
||||
@@ -75,10 +76,11 @@ async def start_voice_onboarding(
|
||||
)
|
||||
|
||||
# Synthesize audio greeting
|
||||
audio_id, _ = await voice_service.text_to_speech(
|
||||
audio_id, greeting_bytes = await voice_service.text_to_speech(
|
||||
greeting_text,
|
||||
request.language,
|
||||
)
|
||||
greeting_b64 = f"data:audio/wav;base64,{base64.b64encode(greeting_bytes).decode('utf-8')}" if greeting_bytes else None
|
||||
|
||||
# Save initial assistant message
|
||||
onboarding_service.save_message(
|
||||
@@ -99,6 +101,7 @@ async def start_voice_onboarding(
|
||||
stage=session.stage,
|
||||
greeting_text=greeting_text,
|
||||
audio_url=f"/v1/voice-onboarding/audio/{audio_id}",
|
||||
audio_base64=greeting_b64,
|
||||
)
|
||||
|
||||
|
||||
@@ -252,11 +255,13 @@ async def voice_turn(
|
||||
)
|
||||
|
||||
# 9. Synthesize AI Speech Audio (TTS)
|
||||
audio_id, _ = await voice_service.text_to_speech(
|
||||
audio_id, audio_bytes = await voice_service.text_to_speech(
|
||||
text=ai_reply_text,
|
||||
language_code=session.language,
|
||||
)
|
||||
|
||||
audio_b64 = f"data:audio/wav;base64,{base64.b64encode(audio_bytes).decode('utf-8')}" if audio_bytes else None
|
||||
|
||||
return VoiceTurnResponse(
|
||||
success=True,
|
||||
session_id=session_id,
|
||||
@@ -265,6 +270,7 @@ async def voice_turn(
|
||||
stage=session.stage,
|
||||
completed=is_completed,
|
||||
audio_url=f"/v1/voice-onboarding/audio/{audio_id}",
|
||||
audio_base64=audio_b64,
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user