I hereby claim:
- I am yegorkryukov on github.
- I am iopheam (https://keybase.io/iopheam) on keybase.
- I have a public key ASCCdbofhOcpuacxKvb07YNsz671C7OIOIc6AjpIwxqiLwo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
import boto3 | |
import time | |
import urllib.request | |
import json |
# 'rootkey.csv' is the file you've downloaded from AWS | |
with open('rootkey.csv', 'r') as f: | |
content = f.readlines() | |
keys = {} | |
for line in content: | |
pair = line.strip().split('=') | |
keys.update({pair[0] : pair[1]}) | |
AWS_ACCESS_KEY_ID = keys['AWSAccessKeyId'] |
import boto3 | |
BUCKET_NAME = <'YOUR-S3-BUCKET-NAME'> | |
FILE_NAME = <'YOUR-AUDIO-FILENAME.mp3'> | |
JOB_NAME = <'YOUR-TRANSCRIBE-JOB-NAME'> # can be anything | |
# Instantiate a client to the AWS transcribe service | |
transcribe = boto3.client( | |
'transcribe', | |
aws_access_key_id=AWS_ACCESS_KEY_ID, |
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 | |
def get_transcription_text(transcribe, job_name): | |
"""Returns transcription text for the AWS Transcribe job | |
Parameters | |
---------- | |
transcribe : AWS `transcribe` service client instance | |
job_name : transcribe service `job` name | |
Returns | |
------- |
# launch the job | |
job_status = start_transcribe_job(transcribe, JOB_NAME, BUCKET_NAME, FILE_NAME) | |
# if job launched successfully `job_status` will be True | |
if job_status: # and we can start requesting the results from the service | |
text = get_transcription_text(transcribe, JOB_NAME) | |
print(f'The transcribed text for {FILE_NAME} file:') | |
print(text) | |
else: # or print the error code if somethign went wrong | |
print(f'Job {JOB_NAME} failed with the error: {job_status}') |