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

Setup

Install the package:
npm2yarn

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 SonioxAudioTranscriptLoader and generate the summary with an LLM.
You can also transcribe audio from binary data:

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. Learn more about Soniox translation.

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:
For more details, see the Soniox context documentation.

API reference

Constructor parameters

SonioxLoaderParams (required)

SonioxLoaderOptions (optional)

Browse the documentation for a full list of supported options.

Supported audio formats

  • aac - Advanced Audio Coding
  • aiff - Audio Interchange File Format
  • amr - Adaptive Multi-Rate
  • asf - Advanced Systems Format
  • flac - Free Lossless Audio Codec
  • mp3 - MPEG Audio Layer III
  • ogg - Ogg Vorbis
  • wav - Waveform Audio File Format
  • webm - WebM Audio

Return value

The load() method returns an array containing a single Document object:
The metadata includes transcribed text, speaker information (if diarization enabled), language information (if identification enabled), translation data (if translation enabled), and timing information.
Token type:
You can learn more about the SonioxTranscriptResponse type in the Soniox REST API Reference.