我正在从Lambda调用AWS Transcribe服务
Lambda代码:
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
我唯一的猜测是即使我声明了API版本,lambda也没有使用正确的SDK。
感谢您的帮助,如果我有错误,请告诉我。
谢谢