Skip to main content
In this guide, you’ll learn how to implement real-time translation of final transcripts using AssemblyAI’s Streaming API and LLM Gateway.

Quickstart

Step-by-Step Instructions

Before we begin, make sure you have an AssemblyAI account and an API key. You can sign up and get your API key from your dashboard.

Install Dependencies

Import Packages & Set API Key

Audio Configuration & Global Variables

Set all of your audio configurations and global variables.

Define Translate Text Function

Define a function called translate_text (Python) or translateText (JavaScript), which uses LLM Gateway to translate the English final transcripts into another language. This example is translating the text into Spanish. To set this to a different language, just replace “Spanish” in the prompt with your language of choice.

Websocket Event Handlers

Open Websocket

Handle Websocket Messages

In this function, use the previously defined translate_text / translateText to translate all final transcripts.

Close Websocket

Websocket Error Handling

Begin Real-time STT Transcription