Translate an AssemblyAI Subtitle Transcript
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.
- AssemblyAI SDK
- Googletrans
Import the assemblyai
package and set the API key. Import Translator
class from googletrans
package.
Create a Transcriber
object.
Create a Translator
object.
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.
Alternatively, you can pass in a path to an audio file saved on the internet.
Export SRT subtitles with the export_subtitles_srt
method. Create a subtitle_transcript
variable to translate in the next step.
Translate subtitle transcript to target language
Print results
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.