Skip to main content
Get started using the Soniox audio transcription loader in LangChain.

Setup

Install the package:

Credentials

Get your Soniox API key from the Soniox Console and set it as an environment variable:

Usage

Basic transcription

Example how to transcribe audio file using the SonioxDocumentLoader and generate the summary with an LLM.
You can also load audio from a local file or from bytes:

Async transcription

For async operations, use aload() or alazy_load():

Advanced usage

Language hints

Soniox automatically detects and transcribes speech in 60+ languages. When you know which languages are likely to appear in your audio, provide language_hints to improve accuracy by biasing recognition toward those languages. Language hints do not restrict recognition—they only bias the model toward the specified languages, while still allowing other languages to be detected if present.
For more details, see the Soniox language hints documentation.

Speaker diarization

Enable speaker identification to distinguish between different speakers:

Language identification

Enable automatic language detection and identification:

Context for improved accuracy

Provide domain-specific context to improve transcription accuracy. Context helps the model understand your domain, recognize important terms, and apply custom vocabulary. The context object supports four optional sections:
For more details, see the Soniox context documentation.

Translation

Translate from any detected language to a target language:
You can also transcribe and translate between two languages simultaneously using two_way translation type. For more information, see async translation.

API reference

Constructor parameters

* You must specify exactly one of: file_path, file_data, or file_url.

Transcription options

The SonioxTranscriptionOptions class supports these parameters: Browse the API documentation for a full list of supported options.

Return value

The lazy_load() and alazy_load() methods yield a single Document object:
The tokens array in metadata includes detailed information for each transcribed word:
  • text: The transcribed text
  • start_ms: Start time in milliseconds
  • end_ms: End time in milliseconds
  • speaker: Speaker ID (if diarization enabled), for example "1", "2", etc.
  • language: Detected language (if identification enabled), for example "en", "fr", etc.
  • translation_status: Translation status ("original", "translated" or "none")
Learn more about the Soniox API reference.