我有一个音频文件S3
。
我不知道音频文件的语言。所以我需要使用IdentifyLanguage
for start_transcription_job()
。
LanguageCode
将是空白的,因为我不知道音频文件的语言。
环境
使用 Python 3.8 运行时,boto3 版本1.16.5
,botocore 版本:1.19.5
,无 Lambda 层。
这是我的转录工作代码:
mediaFileUri = 's3://'+ bucket_name+'/'+prefixKey
transcribe_client = boto3.client('transcribe')
response = transcribe_client.start_transcription_job(
TranscriptionJobName="abc",
IdentifyLanguage=True,
Media={
'MediaFileUri':mediaFileUri
},
)
然后我得到这个错误:
{
"errorMessage": "Parameter validation failed:\nMissing required parameter in input: \"LanguageCode\"\nUnknown parameter in input: \"IdentifyLanguage\", must be one of: TranscriptionJobName, LanguageCode, MediaSampleRateHertz, MediaFormat, Media, OutputBucketName, OutputEncryptionKMSKeyId, Settings, ModelSettings, JobExecutionSettings, ContentRedaction",
"errorType": "ParamValidationError",
"stackTrace": [
" File \"/var/task/app.py\", line 27, in TranscribeSoundToWordHandler\n response = response = transcribe_client.start_transcription_job(\n",
" File \"/var/runtime/botocore/client.py\", line 316, in _api_call\n return self._make_api_call(operation_name, kwargs)\n",
" File \"/var/runtime/botocore/client.py\", line 607, in _make_api_call\n request_dict = self._convert_to_request_dict(\n",
" File \"/var/runtime/botocore/client.py\", line 655, in _convert_to_request_dict\n request_dict = self._serializer.serialize_to_request(\n",
" File \"/var/runtime/botocore/validate.py\", line 297, in serialize_to_request\n raise ParamValidationError(report=report.generate_report())\n"
]
}
有了这个错误,意味着我必须指定LanguageCode
andIdentifyLanguage
是一个无效的参数。
100% 确定音频文件存在于 S3 中。但是没有LanguageCode
它不起作用,并且IdentifyLanguage
参数是未知参数
我使用 SAM 应用程序在本地使用以下命令进行测试:
sam local invoke MyHandler -e lambda\TheDirectory\event.json
我cdk deploy
也检查了 Aws Lambda 控制台,对其进行了相同的测试events.json
,但仍然出现相同的错误
我认为这是 Lambda 执行环境,我没有使用任何 Lambda 层。
我从 Aws Transcribe 看这个文档:
https://docs.aws.amazon.com/transcribe/latest/dg/API_StartTranscriptionJob.html
和这个文档boto3
:
明确说明LanguageCode
不是必需的并且IdentifyLanguage
是有效参数。
那么我错过了什么?对此有任何想法吗?我该怎么办?
更新:
我一直在网上搜索并询问了几个人,我认为我应该首先构建函数容器,让SAM将boto3打包到容器中。
所以我要做的是cdk synth
一个模板文件:
cdk synth --no-staging > template.yaml
然后:
sam build --use-container
sam local invoke MyHandler78A95900 -e lambda\TheDirectory\event.json
但是,我仍然得到同样的错误,但也发布了堆栈跟踪
[ERROR] ParamValidationError: Parameter validation failed:
Missing required parameter in input: "LanguageCode"
Unknown parameter in input: "IdentifyLanguage", must be one of: TranscriptionJobName, LanguageCode, MediaSampleRateHertz, MediaFormat, Media, OutputBucketName, OutputEncryptionKMSKeyId, Settings, JobExecutionSettings, ContentRedaction
Traceback (most recent call last):
File "/var/task/app.py", line 27, in TranscribeSoundToWordHandler
response = response = transcribe_client.start_transcription_job(
File "/var/runtime/botocore/client.py", line 316, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/var/runtime/botocore/client.py", line 607, in _make_api_call
request_dict = self._convert_to_request_dict(
File "/var/runtime/botocore/client.py", line 655, in _convert_to_request_dict
request_dict = self._serializer.serialize_to_request(
File "/var/runtime/botocore/validate.py", line 297, in serialize_to_request
raise ParamValidationError(report=report.generate_report())
真的不知道我在这里做错了什么。我还在这里报告了一个 github 问题,但似乎无法重现该问题。
主要问题/问题:
无法start_transription_job
没有
LanguageCode
和
IdentifyLanguage=True
什么可能的原因导致这种情况,我该如何解决这个问题(不知道音频文件的语言,我想在没有给出 LanguageCode 的情况下识别音频文件的语言)?