feat: add language option

This commit is contained in:
Abhishek Kumar 2026-03-31 18:17:44 +05:30
parent 4a73de152d
commit 526d5439f3
2 changed files with 20 additions and 6 deletions

View file

@ -318,6 +318,9 @@ OPENAI_REALTIME_VOICES = [
GOOGLE_REALTIME_MODELS = ["gemini-3.1-flash-live-preview"]
GOOGLE_REALTIME_VOICES = ["Puck", "Charon", "Kore", "Fenrir", "Aoede"]
GOOGLE_REALTIME_LANGUAGES = [
"en"
]
@register_service(ServiceType.REALTIME)
@ -326,7 +329,7 @@ class GoogleRealtimeLLMConfiguration(BaseLLMConfiguration):
ServiceProviders.GOOGLE_REALTIME
)
model: str = Field(
default="gemini-2.0-flash-live-001",
default="gemini-3.1-flash-live-preview",
json_schema_extra={
"examples": GOOGLE_REALTIME_MODELS,
"allow_custom_input": True,
@ -339,6 +342,13 @@ class GoogleRealtimeLLMConfiguration(BaseLLMConfiguration):
"allow_custom_input": True,
},
)
language: str = Field(
default="en",
json_schema_extra={
"examples": GOOGLE_REALTIME_LANGUAGES,
"allow_custom_input": True,
},
)
REALTIME_PROVIDERS = {

View file

@ -415,9 +415,10 @@ def create_realtime_llm_service(user_config, audio_config: "AudioConfig"):
model = realtime_config.model
api_key = realtime_config.api_key
voice = getattr(realtime_config, "voice", None)
language = getattr(realtime_config, "language", None)
logger.info(
f"Creating realtime LLM service: provider={provider}, model={model}, voice={voice}"
f"Creating realtime LLM service: provider={provider}, model={model}, voice={voice}, language={language}"
)
if provider == ServiceProviders.OPENAI_REALTIME.value:
@ -451,12 +452,15 @@ def create_realtime_llm_service(user_config, audio_config: "AudioConfig"):
# Gemini Live enables input/output audio transcription by default
# in its _connect() method — no need to configure it explicitly.
settings_kwargs = {
"model": model,
"voice": voice or "Puck",
}
if language:
settings_kwargs["language"] = language
return GeminiLiveLLMService(
api_key=api_key,
settings=GeminiLiveLLMService.Settings(
model=model,
voice=voice or "Puck", # vad=GeminiVADParams(disabled=True)
),
settings=GeminiLiveLLMService.Settings(**settings_kwargs),
)
else:
raise HTTPException(