PARAS MADAN
All writing

Latest in AI

How to detect spoken languages in Pipecat with AWS Transcribe

Pipecat 1.17 adds AWS Transcribe language detection. Configure candidate languages, test language switching, and handle missing language labels.

A voice app that serves English and Spanish speakers has two different problems. It might need to choose a language at the start of a session, or it might need to follow someone who switches languages halfway through. Pipecat 1.17.0, released November 22 UTC, adds both modes to its AWS Transcribe integration.

Start by checking whether the transcript itself follows the speaker. You can test the speech-to-text step with recorded samples before asking a language model or a speech synthesizer to react to it.

Configure the languages AWS can choose from

Pass language_options to AWSTranscribeSTTService.Settings in your existing Pipecat AWS Transcribe pipeline. With a non-empty candidate list, Pipecat uses automatic detection instead of sending the fixed language setting. If you want to pick the dominant language for the stream, leave identify_multiple_languages off. If a speaker can switch between languages in the same stream, enable it:

from pipecat.services.aws.stt import AWSTranscribeSTTService
from pipecat.transcriptions.language import Language

stt_settings = AWSTranscribeSTTService.Settings(
    language_options=[Language.EN_US, Language.ES_US],
    identify_multiple_languages=True,
)

Use stt_settings as the service's settings argument. The Pipecat implementation validates that there are at least two distinct AWS language codes. Aliases can resolve to the same code, and AWS also allows only one dialect per language in a stream. Start with the languages your users actually speak rather than a broad list.

For single-language detection, you can try preferred_language using one of the listed codes. AWS documents it as a hint that can speed up identification, not as a way to force that result. Leave the hint out of the initial multi-language test.

Check the audio and service constraints

Use PCM for a multi-language stream. AWS's streaming language guide says detection needs at least one second of speech and doesn't support redaction or custom language models in this mode. If your existing pipeline depends on an incompatible feature, keep its current path while you evaluate detection separately.

When no candidate matches, AWS can pick the closest option from the list anyway. A returned language code doesn't prove that the user was speaking that language. Test an out-of-list clip before using the label for any automated routing.

Compare final transcript frames

Use a synthetic or consented recording with three clips: English only, Spanish only, and an English sentence followed by a Spanish sentence. Run the same clips with dominant-language detection and with multi-language detection. For each final TranscriptionFrame, record whether the text matches the clip and whether frame.language matches the spoken segment. The tagged Pipecat tests cover the propagation of AWS language codes into both interim and final frames.

For downstream routing, start with final frames. If AWS omits the language code, Pipecat can leave the field unset. Keep an explicit unknown case rather than assigning the first candidate. Compare interim labels separately if you display live captions.

Avoid updating settings mid-utterance

Changing the detection options while connected causes Pipecat to reconnect its AWS stream. Decide whether you need that at all: if the candidate list stays fixed, multi-language mode can follow a speaker without your app changing settings after each turn. If you do change the list, test it between utterances and check that the new stream delivers a final transcript before relying on its labels.

Need help documenting a voice integration?

I'm Paras Madan. I help AI teams turn product releases into technical guides developers can use to test their own applications. Book a 30-minute call.