DEV Community

loading...
Cover image for Voice To Text Using AWS Transcribe With Python
BoTreeTechnologies

Voice To Text Using AWS Transcribe With Python

Chirag Lunagariya
Python Developer
・2 min read

Boto3 is the Amazon Web Services (AWS) Software Development Kit (SDK) for Python, which allows Python developers to write software that makes use of Amazon Web services like S3 and EC2.

Amazon Transcribe is an automatic speech recognition (ASR) service that is fully managed and continuously trained that generates accurate transcripts for audio files. It makes it easy for developers to add speech to text capability to their applications. You can analyze audio files stored in Amazon S3 and have the service return a text file of the transcribed speech using the Amazon Transcribe API. Reach out to learn more about the web development agency in New York for the various ways to improve or build the quality of projects and across your company.

  • You need to grant permissions to use the Amazon Transcribe console for the actions shown in the following policy:

1. Initialize Client:

  • To run transcribe job initialize client using boto3 with AWS credentials.

2. Run Transcribe Job:

  • start_transcription_job(**kwargs) it will start an asynchronous job to transcribe speech to text.

  • Required parameters to run transcribe job are TranscriptionJobName, Media, MediaFormat ('mp3'|'mp4'|'wav'|'flac'), LanguageCode ('en-US'|'es-US'|'en-AU'|'fr-CA'|'en-GB'|'de-DE'|'pt-BR'|'fr-FR'|'it-IT').

3. Check Job Status:

  • Due to the asynchronous nature of the transcription job, we need to check the job status. The time taken to run the transcription job is depending on the length and complexity of your recordings.
  • When the transcription job status is completed, the result links to an Amazon S3 presigned URL that contains the transcription in JSON format:

4. Retrieve Text:

  • On complete transcription, the job result contains the transcription in JSON format. Using python library load JSON response and get the text from the result.

Discussion (0)