For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
PlaygroundChangelogSign In
OverviewAPI ReferencePre-recorded STTStreaming STTVoice AgentsSpeech UnderstandingGuardrailsLLM GatewayFAQ
OverviewAPI ReferencePre-recorded STTStreaming STTVoice AgentsSpeech UnderstandingGuardrailsLLM GatewayFAQ
  • Getting started
    • Transcribe a pre-recorded audio file
    • Model selection
    • View model benchmarks
    • Evaluate model accuracy
    • Cloud endpoints & data residency
    • Manage concurrent requests
    • Webhooks
  • Models
    • Medical Mode
  • Features
    • Boost specific terms
    • Label speakers
    • Transcribe multiple audio channels
    • Transcribe audio with mixed languages
    • Correct spelling of terms
    • Include filler words
    • Search for words in transcript
    • Set the start and end of the transcript
  • Guides
      • Build a meeting notetaker
      • Build a medical scribe
      • Build a contact center application
        • Create Custom Length Subtitles
        • Create Subtitles with Speaker Labels
        • Generate Subtitles for Videos
        • Translate an AssemblyAI Subtitle Transcript
LogoLogo
PlaygroundChangelogSign In
On this page
  • Get Started
  • Step-by-Step Instructions
  • Conclusion
  • Further Documentation
GuidesTutorialsSubtitles

Translate an AssemblyAI Subtitle Transcript

Was this page helpful?
Previous

Schedule a DELETE request with AssemblyAI and EasyCron

Next
Built with

In this guide, we’ll show you how to translate an AssemblyAI generated subtitle transcript. We will also be using the Googletrans Python library to implement the Google Translate API.

Get Started

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

Step-by-Step Instructions

Install the relevant packages.

  1. AssemblyAI SDK
  2. Googletrans
$pip install -U assemblyai googletrans

Import the assemblyai package and set the API key. Import Translator class from googletrans package.

1import assemblyai as aai
2from googletrans import Translator
3
4aai.settings.api_key = "YOUR_API_KEY"

Create a Transcriber object.

1config = aai.TranscriptionConfig(speech_models=["universal-3-pro", "universal-2"])
2transcriber = aai.Transcriber()

Create a Translator object.

1translator = Translator()

Use the Transcriber object’s transcribe method and pass in the audio file’s path as a parameter. The transcribe method saves the results of the transcription to the Transcriber object’s transcript attribute.

1transcript = transcriber.transcribe("./my-audio.mp3", config)

Alternatively, you can pass in a path to an audio file saved on the internet.

1transcript = transcriber.transcribe("https://example.org/audio.mp3", config)

Export SRT subtitles with the export_subtitles_srt method. Create a subtitle_transcript variable to translate in the next step.

1subtitle_transcript = transcript.export_subtitles_srt()

Translate subtitle transcript to target language

1translation = translator.translate(subtitle_transcript, dest='es')

Print results

1print(translation.text)

Conclusion

Using the subtitles and transcripts generated by AssemblyAI, we can also generate translated alternatives using other translation APIs. The implementation logic will be similar with other solutions like DeepL, Yandex Translate and many more.

To translate to other languages, find the full list of Supported Languages in the Further Documentations section.

Further Documentation

Googletrans Library

Translation Supported Languages