2

我正在尝试为 lex 测试用于音频输入和输出的 amazon web node api sdk 并成功配置它,但是当我测试它时,它向我发送垃圾输入脚本(如“是”、“哦不”、“嗯”等.) 作为回应。

请求参数如下,

var params = {
        botAlias: 'Test', /* required */
        botName: 'Revert', /* required */
        contentType: 'audio/l16; rate=16000; channels=1', /* required */    
        inputStream: <Buffer 52 49 46 46 80 55 02 00 57 41 56 45 66 6d 74 20 10 00 00 00 01 00 02 00 80 3e 00 00 00 7d 00 00 04 00 10 00 64 61 74 61 54 55 02 00 00 00 00 00 00 00 ... >, /* required */
        userId: '12321', /* required */
        accept: 'audio/*',
        sessionAttributes: {"firstName": "Joe"} 

};

我得到的回应如下,

{ contentType: 'audio/mpeg',
  sessionAttributes: { firstName: 'Joe' },
  message: 'Sorry No Match',
  dialogState: 'ElicitIntent',
  inputTranscript: 'yeah',
  audioStream: <Buffer 49 44 33 04 00 00 00 00 00 23 54 53 53 45 00 00 00 0f 00 00 03 4c 61 76 66 35 37 2e 35 36 2e 31 30 31 00 00 00 00 00 00 00 00 00 00 00 ff f3 60 c4 00 ... > }

对于录音,我使用我的笔记本电脑内置麦克风和 RecordRTC api,

recorder = RecordRTC(microphone, {
            type: 'audio',
            recorderType: StereoAudioRecorder,
            desiredSampRate: 16000
        });

录制的语音被编码成base64并发送到节点服务器,在那里它被解码并以缓冲区格式发送到lex api。

4

0 回答 0