requests in Python.
The code
Forcing a language
Leavelanguage out to have the spoken language detected. Pass a code when you know it, or when you want a specific caption track on a multilingual video:
pt-BR and en-GB match that caption track, and speech-to-text transcribes in the base language, so language comes back as pt or en. See the full list of 99 supported languages.
What comes back
The response is the same shape for every language, whether the words came from captions or from speech-to-text:Notes that save you a round trip
When the video has captions in the language you want, you get them for $0.003. When it doesn't, Importly transcribes the audio in that language at $0.01 per started minute, so a foreign-language video with no subtitles still returns a transcript instead of nothing.maxCostDollars caps that charge: a long video over the cap fails with MAX_COST_EXCEEDED rather than running over it.
Speech-to-text transcribes, it doesn’t translate. Send language only when it’s the language actually spoken; asking for a different language than the audio gives a garbled transcript labelled with the wrong code. When you don’t know the language, leave it out and read it off result.language. Detection needs some speech to go on, so on a clip of a few seconds or one that’s mostly music, pass language when you can.
Need the media file as well as the transcript? Add includeTranscript: true and transcriptLanguage to POST /import and one job gives you the file and its transcript. See transcripts inside an import.
Full reference: languages
How
language behaves on captions and speech-to-text, and the 99 supported languages.