Add multilingual support for Deepgram Flux STT

Enables the flux-general-multi model with one or more language_hints.
Hints are sent as repeatable URL params at connect time and via a
Configure control message when updated mid-stream (detect-then-lock).
TranscriptionFrame.language now reflects the language Flux detected
for each turn via the TurnInfo `languages` field.
This commit is contained in:
Mark Backman
2026-04-17 10:30:45 -04:00
parent 4c19f5584c
commit 6bb4e8295f
4 changed files with 141 additions and 14 deletions

View File

@@ -23,6 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import (
from pipecat.runner.types import RunnerArguments
from pipecat.runner.utils import create_transport
from pipecat.services.cartesia.tts import CartesiaTTSService
from pipecat.services.deepgram.flux.base import DeepgramFluxSTTSettings
from pipecat.services.deepgram.flux.stt import DeepgramFluxSTTService
from pipecat.services.openai.llm import OpenAILLMService
from pipecat.transcriptions.language import Language
@@ -51,7 +52,16 @@ transport_params = {
async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
logger.info(f"Starting bot")
stt = DeepgramFluxSTTService(api_key=os.getenv("DEEPGRAM_API_KEY"))
# Start with the multilingual model and broad hints so Flux can auto-detect
# across English and Spanish. TranscriptionFrame.language will reflect
# whichever language Flux detected for each turn.
stt = DeepgramFluxSTTService(
api_key=os.getenv("DEEPGRAM_API_KEY"),
settings=DeepgramFluxSTTService.Settings(
model="flux-general-multi",
language_hints=[Language.EN, Language.ES],
),
)
tts = CartesiaTTSService(
api_key=os.getenv("CARTESIA_API_KEY"),
@@ -115,10 +125,12 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
)
)
# Detect-then-lock: narrow the hints to a single language mid-stream.
# Sent as a Configure message — no reconnect needed.
await asyncio.sleep(10)
logger.info("Updating Deepgram Flux STT settings: language=es")
logger.info("Updating Deepgram Flux STT settings: language_hints=[es]")
await task.queue_frame(
STTUpdateSettingsFrame(delta=DeepgramFluxSTTService.Settings(language=Language.ES))
STTUpdateSettingsFrame(delta=DeepgramFluxSTTSettings(language_hints=[Language.ES]))
)
@transport.event_handler("on_client_disconnected")