我从 Lambda 调用 AWS Transcribe 服务
拉姆达代码:
module.exports.createTranscribeJob = (event, context, callback) => {
const region = event.Records[0].awsRegion;
const bucket = event.Records[0].s3.bucket.name;
const key = event.Records[0].s3.object.key;
const transcribeservice = new AWS.TranscribeService({apiVersion: '2017-10-26'});
// Set the transcribeservice startTranscriptionJob params
const params = {
LanguageCode: 'en-US',
Media: {
MediaFileUri: `https://s3-${region}.amazonaws.com/${bucket}/${key}`
},
MediaFormat: 'mp3',
TranscriptionJobName: key,
MediaSampleRateHertz: 0,
OutputBucketName: bucket
};
// call startTranscriptionJob with the params
transcribeservice.startTranscriptionJob(params, function(err, data) {
if (err){
console.log(err, err.stack);
} else {
console.log(data);
}
});
callback(null);
};
我设置了我要使用的 API 的版本new AWS.TranscribeService({apiVersion: '2017-10-26'})
当我调用transcribeservice.startTranscriptionJob
作业失败并出现此错误时:
{ UnexpectedParameter: Unexpected key 'OutputBucketName' found in params
at ParamValidator.fail (/var/runtime/node_modules/aws-sdk/lib/param_validator.js:50:37)
at ParamValidator.validateStructure (/var/runtime/node_modules/aws-sdk/lib/param_validator.js:77:14)
at ParamValidator.validateMember (/var/runtime/node_modules/aws-sdk/lib/param_validator.js:88:21)
at ParamValidator.validate (/var/runtime/node_modules/aws-sdk/lib/param_validator.js:34:10)
at Request.VALIDATE_PARAMETERS (/var/runtime/node_modules/aws-sdk/lib/event_listeners.js:125:42)
at Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
at callNextListener (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:95:12)
at /var/runtime/node_modules/aws-sdk/lib/event_listeners.js:85:9
at finish (/var/runtime/node_modules/aws-sdk/lib/config.js:320:7)
at /var/runtime/node_modules/aws-sdk/lib/config.js:338:9
message: 'Unexpected key \'OutputBucketName\' found in params',
code: 'UnexpectedParameter',
time: 2018-07-19T12:50:58.278Z }
如果我删除OutputBucketName: bucket
它有效,所以我知道它不是权限问题
查看 AWS Javascript sdk 的源代码OutputBucketName
被定义为StartTranscriptionJobRequest
https://github.com/aws/aws-sdk-js/blob/75978fcfe4186d5a310e9b5c6d6328e90997edf0/apis/transcribe-2017-10-26.normal.json#L491的成员
我唯一的猜测是 lambda 没有使用正确的 SDK,即使我声明了 API 版本。
任何帮助表示赞赏,如果我有错误,请告诉我。
谢谢