Skip to content

Instantly share code, notes, and snippets.

@yegorkryukov
Created June 25, 2020 16:50
Show Gist options
  • Save yegorkryukov/b76b39c36bd926184dfb73d3fcc20295 to your computer and use it in GitHub Desktop.
Save yegorkryukov/b76b39c36bd926184dfb73d3fcc20295 to your computer and use it in GitHub Desktop.
def start_transcribe_job(transcribe, job_name, bucket, file):
"""Starts an AWS Transcribe job
Parameters
----------
transcribe : AWS `transcribe` service client instance
job_name : str, name of the AWS job
bucket : str, AWS S3 bucket name
file : str, name of the mp3 file to transcribe
Returns
-------
True: if job started successfully
"""
# this is the location of your mp3 file
file_uri = f'https://s3.amazonaws.com/{bucket}/{file}'
# try launching the job and return any error messages
try:
transcribe.start_transcription_job(
TranscriptionJobName=job_name,
Media={'MediaFileUri': file_uri},
MediaFormat='mp3',
LanguageCode='en-US')
return True
except Exception as e:
return e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment