简体   繁体   English

如何从 aws 转录创建字幕

[英]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 ).我将 AWS SDK 用于 python ( boto3 ),并希望将字幕设置为 output 格式(即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.当我使用此代码时,出现以下错误,其中提到的参数Subtitle不是有效参数,但根据 AWS 文档,我应该能够在此参数中传递一些值。

    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我得到的错误是输入中的未知参数:“字幕”,必须是以下之一:TranscriptionJobName、LanguageCode、MediaSampleRateHertz、MediaFormat、Media、OutputBucketName、OutputEncryptionKMSKeyId、Settings

refered the aws documentation 参考了 aws 文档

I have faced a similar issue, and after some research, I have found out it is because of my boto3 and botocore versions.我遇到过类似的问题,经过一番研究,我发现这是因为我的 boto3 和 botocore 版本。

I have upgraded these two packages, and it worked.我已经升级了这两个包,并且有效。 My requirements.txt for these two packages:我的这两个包的requirements.txt:

boto3==1.20.0
botocore==1.23.54

PS: Remember to check these two new versions are compatible with your other python packages. PS:记得检查这两个新版本是否与您的其他 python 软件包兼容。 Especially if you are using other AWS Libraries like awsebcli .特别是如果您使用其他 AWS 库,如awsebcli To make sure everything is working perfectly together, try running this command after upgrading these two libraries to check the errors:为确保一切正常,请在升级这两个库后尝试运行此命令以检查错误:

pip check

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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