-
-
Save stephenlb/26ef10c857dad157b042577e1a889cf7 to your computer and use it in GitHub Desktop.
audio lext test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var AWS = require('aws-sdk'); | |
AWS.config.update({ | |
accessKeyId: "__id__", | |
secretAccessKey: "__secret__", | |
}); | |
var lexruntime = new AWS.LexRuntime({region: 'us-east-1'}); | |
// // TEXT REQUEST -> TEXT RESPONSE | |
// var params = { | |
// botAlias: 'StephenChatEngineExample', // required */ | |
// botName: 'StephenChatEngineExample', // required */ | |
// userId: 'irdfvbdefb', // required */ | |
// inputText: 'yo', | |
// }; | |
// lexruntime.postText(params, function (err, data) { | |
// if (err) console.log(err, err.stack); // an error occurred | |
// else console.log(data); // successful response | |
// }); | |
// var audioBuffer; | |
// TEXT REQUEST -> AUDIO AND TEXT RESPONSE | |
var params = { | |
botAlias: 'StephenChatEngineExample', /* required */ | |
botName: 'StephenChatEngineExample', /* required */ | |
contentType: 'text/plain; charset=utf-8', /* required */ | |
inputStream: 'hi stephen', /* required */ | |
userId: 'rthrthrthr', /* required */ | |
accept: 'audio/pcm', | |
}; | |
lexruntime.postContent(params, function (err, data) { | |
if (err) console.log(err, err.stack); // an error occurred | |
else console.log(data); // successful response | |
audioBuffer = data.audioStream; | |
// audioBuffer = Buffer.from(audioBuffer).toString('base64'); | |
// audioBuffer = Buffer.from(audioBuffer, 'base64').toString('ascii'); | |
// AUDIO REQUEST -> AUDIO AND TEXT RESPONSE | |
var params = { | |
botAlias: 'StephenChatEngineExample', /* required */ | |
botName: 'StephenChatEngineExample', /* required */ | |
// accept: 'audio/*', | |
contentType: 'audio/l16; rate=16000; channels=1', | |
inputStream: audioBuffer, /* required */ | |
userId: 'rthrthrthrth546h5', /* required */ | |
}; | |
lexruntime.postContent(params, function (err, data) { | |
if (err) console.log(err, err.stack); // an error occurred | |
else console.log(data); // successful response | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment