How to use SpeechAnalyzer

Asked on 06/11/2025

1 search

To use the SpeechAnalyzer, you can follow these steps as outlined in the session "Bring advanced speech-to-text to your app with SpeechAnalyzer":

  1. Initialize the SpeechAnalyzer: The SpeechAnalyzer API consists of the SpeechAnalyzer class, which manages an analysis session. You can add a module class to the session to perform specific types of analysis, such as transcription.

  2. Configure the Speech Transcriber: Set up your speech transcriber by initializing it with a locale object and the necessary options. The locale's language code corresponds to the language in which you want to receive transcription. You can configure options like audio time range to sync text playback with audio.

  3. Ensure the Model is Present: Check if the Speech Transcriber supports transcription for the desired language and whether the language is downloaded and installed. If not, you can request to download the necessary model assets.

  4. Handle the Results: The SpeechAnalyzer works asynchronously, allowing you to add audio as it becomes available and process results independently. You can handle both volatile (real-time guesses) and finalized results, with volatile results being replaced by finalized ones when they become available.

  5. Live Transcription: You can build a live transcription feature by setting up the SpeechAnalyzer with a transcriber module, passing audio buffers to the analyzer, and handling the transcription results in real-time.

For a detailed demonstration, you can watch the session Bring advanced speech-to-text to your app with SpeechAnalyzer (02:41).