Address review feedback

- Fall back to Language.EN in _primary_detected_language when model is
  flux-general-en, preserving prior behavior on the default model.
- Standardize example on DeepgramFluxSTTService.Settings and drop the
  now-redundant DeepgramFluxSTTSettings import.
- Narrow the changed-behavior changelog to reflect that flux-general-en
  frames still carry Language.EN.
This commit is contained in:
Mark Backman
2026-04-17 15:38:14 -04:00
parent af861b7975
commit 42a6fc703c
3 changed files with 13 additions and 8 deletions

View File

@@ -1 +1 @@
- `TranscriptionFrame.language` and `InterimTranscriptionFrame.language` emitted by `DeepgramFluxSTTService` now reflect the language Deepgram detected for each turn (read from the `languages` field on Flux's `TurnInfo` event) instead of a statically configured value. On `flux-general-multi` this means per-turn accuracy for downstream consumers (e.g. TTS voice selection). On `flux-general-en` the field is absent in Flux responses, so emitted frames now carry `language=None` instead of the previously hardcoded `Language.EN`. - `TranscriptionFrame.language` and `InterimTranscriptionFrame.language` emitted by `DeepgramFluxSTTService` now reflect the language Deepgram detected for each turn (read from the `languages` field on Flux's `TurnInfo` event). On `flux-general-multi` this gives per-turn accuracy for downstream consumers (e.g. TTS voice selection). `flux-general-en` continues to emit `Language.EN`.

View File

@@ -23,7 +23,6 @@ from pipecat.processors.aggregators.llm_response_universal import (
from pipecat.runner.types import RunnerArguments from pipecat.runner.types import RunnerArguments
from pipecat.runner.utils import create_transport from pipecat.runner.utils import create_transport
from pipecat.services.cartesia.tts import CartesiaTTSService 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.deepgram.flux.stt import DeepgramFluxSTTService
from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.openai.llm import OpenAILLMService
from pipecat.transcriptions.language import Language from pipecat.transcriptions.language import Language
@@ -118,7 +117,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
logger.info("Updating Deepgram Flux STT settings: eot_threshold, keyterm") logger.info("Updating Deepgram Flux STT settings: eot_threshold, keyterm")
await task.queue_frame( await task.queue_frame(
STTUpdateSettingsFrame( STTUpdateSettingsFrame(
delta=DeepgramFluxSTTSettings( delta=DeepgramFluxSTTService.Settings(
eot_threshold=0.8, eot_threshold=0.8,
keyterm=["Pipecat", "Deepgram"], keyterm=["Pipecat", "Deepgram"],
) )
@@ -130,7 +129,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
await asyncio.sleep(10) await asyncio.sleep(10)
logger.info("Updating Deepgram Flux STT settings: language_hints=[es]") logger.info("Updating Deepgram Flux STT settings: language_hints=[es]")
await task.queue_frame( await task.queue_frame(
STTUpdateSettingsFrame(delta=DeepgramFluxSTTSettings(language_hints=[Language.ES])) STTUpdateSettingsFrame(
delta=DeepgramFluxSTTService.Settings(language_hints=[Language.ES])
)
) )
@transport.event_handler("on_client_disconnected") @transport.event_handler("on_client_disconnected")

View File

@@ -611,12 +611,16 @@ class DeepgramFluxSTTBase(STTService):
def _primary_detected_language(self, data: dict[str, Any]) -> Language | None: def _primary_detected_language(self, data: dict[str, Any]) -> Language | None:
"""Extract the primary detected language from a TurnInfo payload. """Extract the primary detected language from a TurnInfo payload.
Only populated by ``flux-general-multi``; returns ``None`` otherwise. On ``flux-general-multi`` the language is read from TurnInfo's
``languages`` field. On ``flux-general-en`` the field is absent, so we
fall back to ``Language.EN`` to match the model's fixed language.
""" """
codes = data.get("languages") or [] codes = data.get("languages") or []
if not codes: if codes:
return None return _code_to_pipecat_language(codes[0])
return _code_to_pipecat_language(codes[0]) if self._settings.model == "flux-general-en":
return Language.EN
return None
async def _handle_end_of_turn(self, transcript: str, data: dict[str, Any]): async def _handle_end_of_turn(self, transcript: str, data: dict[str, Any]):
"""Handle EndOfTurn events from Deepgram Flux. """Handle EndOfTurn events from Deepgram Flux.