Universal Streaming
By default, Universal-Streaming is set to transcribe English audio. If you’d like to enable multilingual streaming (support for English, Spanish, French, German, Italian, and Portuguese), enable multilingual transcription instead.
Streaming is now available in EU-West via streaming.eu.assemblyai.com. To
use the EU streaming endpoint, replace streaming.assemblyai.com with
streaming.eu.assemblyai.com in your connection configuration.
Quickstart
In this quick guide you will learn how to use AssemblyAI’s Streaming Speech-to-Text feature to transcribe audio from your microphone.
To run this quickstart you will need:
- Python or JavaScript installed
- A valid AssemblyAI API key
To run the quickstart:
Python SDK
Python
JavaScript SDK
JavaScript
Python SDK
Python
JavaScript SDK
JavaScript
Core concepts
For a message-by-message breakdown of a turn, see our Streaming API: Message Sequence Breakdown guide.
Universal-Streaming is built based upon two core concepts: Turn objects and immutable transcriptions.
Turn object
A Turn object is intended to correspond to a speaking turn in the context of voice agent applications, and therefore it roughly corresponds to an utterance in a broader context. We assign a unique ID to each Turn object, which is included in our response. Specifically, the Universal-Streaming response is formatted as follows:
turn_order: Integer that increments with each new turnturn_is_formatted: Boolean indicating if the text in the transcript field is formatted. Text formatting is enabled whenformat_turnsis set totrue. It adds punctuation as well as performs casing and inverse text normalization to display various entities, such as dates, times, and phone numbers, in a human-friendly formatend_of_turn: Boolean indicating if this is the end of the current turntranscript: String containing only finalized wordsend_of_turn_confidence: Floating number (0-1) representing the confidence that the current turn has finished, i.e., the current speaker has completed their turnwords: List of Word objects with individual metadata
Each Word object in the words array includes:
text: The string representation of the wordword_is_final: Boolean indicating if the word is finalized, where a finalized word means the word won’t be altered in future transcription responsesstart: Timestamp for word startend: Timestamp for word endconfidence: Confidence score for the word
Immutable transcription
AssemblyAI’s streaming system receives audio in a streaming fashion, it returns transcription responses in real-time using the format specified above. Unlike many other streaming speech-to-text models that implement the concept of partial/variable transcriptions to show transcripts in an ongoing manner, Universal-Streaming transcriptions are immutable. In other words, the text that has already been produced will not be overwritten in future transcription responses. Therefore, with Universal-Streaming, the transcriptions will be delivered in the following way:
When an end of the current turn is detected, you then receive a message with end_of_turn being true. Additionally, if you enable text formatting, you will also receive a transcription response with turn_is_formatted being true.
In this example, you may have noticed that the last word of each transcript may occasionally be a subword (“zac” in the example shown above). Each Word object has the word_is_final field to indicate whether the model is confident that the last word is a completed word. Note that, except for the last word, word_is_final is always true.