awslabs / aws-lex-browser-audio-capture

An example web application using the Lex JavaScript SDK to send and receive audio from the Lex PostContent API. Demonstrates how to capture an audio device, record audio, and convert the audio into a format that Lex will recognize, and play the response. All from a web browser.
MIT No Attribution
165 stars 74 forks source link

audioControl.startRecording() throws error, how to start and stop recording ? #12

Closed devansvd closed 6 years ago

devansvd commented 6 years ago

The example works fine, however I'm not comfortable using the aws secret. It works with cognito pool id as well;

    AWS.config.region = 'us-east-1';
     AWS.config.credentials = new AWS.CognitoIdentityCredentials({
        IdentityPoolId: 'XXXXXXXXXXXXXXXXXXX',
     });

Question : How do I control the start and stop recording ?. This continously recording and playing the responses. In the docs it suggested that the audioControl.startRecording(); will start the recording process But it throws error.

Error: Record Audio throws error:

var audioControl = new LexAudio.audioControl(); audioControl.startRecording();

aws-lex-audio.js:659 Uncaught TypeError: Failed to execute 'createMediaStreamSource' on 'BaseAudioContext': parameter 1 is not of type 'MediaStream'. at Object.createRecorder (aws-lex-audio.js:659) at Object.startRecording (aws-lex-audio.js:47) at (index):43

devansvd commented 6 years ago

Looks like this throws the error only for the first time