简体   繁体   中英

how to create subtitles from aws transcribe

I'm using AWS SDK for python ( boto3 ) and want to set the subtitle output format (ie SRT ). When I use this code, I get the error below which mentioned parameter Subtitle is not a valid parameter but according to AWS Documentation, I should be able to pass some values in this parameter.

    s3 = boto3.client('s3', aws_access_key_id=ACCESS_KEY,aws_secret_access_key=SECRET_KEY)
    transcribe = boto3.client('transcribe',aws_access_key_id=ACCESS_KEY, 
    aws_secret_access_key=SECRET_KEY, region_name=region_name)
    job_name = "kateri1234"
    job_uri = "s3://transcribe-upload12/english.mp4"
    transcribe.start_transcription_job(TranscriptionJobName=job_name,Media{'MediaFileUri':job_uri},
    MediaFormat='mp4',
    LanguageCode='en-US', 
    Subtitles={'Formats': ['vtt']},
    OutputBucketName = "transcribe-output12"
    )
    while True:
        status = transcribe.get_transcription_job(TranscriptionJobName=job_name)
        if status['TranscriptionJob']['TranscriptionJobStatus'] in ['COMPLETED', 'FAILED']:
            break
            print("Not ready yet...")
            time.sleep(5)
            print(status)

ERROR i get is Unknown parameter in input: "Subtitles", must be one of: TranscriptionJobName, LanguageCode, MediaSampleRateHertz, MediaFormat, Media, OutputBucketName, OutputEncryptionKMSKeyId, Settings

refered the aws documentation

I have faced a similar issue, and after some research, I have found out it is because of my boto3 and botocore versions.

I have upgraded these two packages, and it worked. My requirements.txt for these two packages:

boto3==1.20.0
botocore==1.23.54

PS: Remember to check these two new versions are compatible with your other python packages. Especially if you are using other AWS Libraries like awsebcli . To make sure everything is working perfectly together, try running this command after upgrading these two libraries to check the errors:

pip check

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM