alexa-voice-service.js
Library for interacting with Alexa Voice Service (AVS) in the browser.
IN NEED OF MAINTAINERS
Please ping me if you'd like to take over this library since I've been out of the loop with Alexa/AVS. Thanks!
Things you can do
Things you can do with this library:
- Login with Amazon and get access token
- Get access token and refresh token from 'code' response type
- Get access token from refresh token
- Request user microphone
- Record user audio using microphone
- Send user audio to AVS
- Parse response from AVS
- Queue and play MP3 responses from AVS.
The audio recorded in this library is mono channel, sampled at 16k Hz, and signed 16 bit PCM encoding which is required by AVS.
Demo
https://lab.miguelmota.com/alexa-voice-service
Install
npm install alexa-voice-service
Example
Follow these steps to run demo locally:
- Git clone this repo
git clone git@github.com:miguelmota/alexa-voice-service.js.git cd alexa-voice-service.js/example/
- Install NPM Modules
npm install
- Run HTTPS server
npm start
- Go to browser url.
open https://localhost:9745
More info in the example README.
Usage
const AVS = ; const avs = options;
Please check out example as noted above.
Documentation
Most methods return a promise.
- redirectUri - {string} redirect uri set in portal avs -> ;avs -> alias to ;avs -> ;avs -> ;avs -> ;avs -> ;avs -> avs -> avs -> avs -> avs -> ;avs -> promise;avs -> promise;avs -> promise;avs -> ; - send audio to AVS and get back an object containing responseThe response object is the parsed http messageavs -> - mp3 blob avs LOG - when a log occurs ERROR - when an error occurs LOGIN - when user is logged in LOGOUT - when user is logged out RECORD_START - when recording is started RECORD_STOP - when recording is stopped TOKEN_SET - when token is set REFRESH_TOKEN_SET - when refresh token is set TOKEN_INVALID - when token is invalid usually because it is expired example: avs # Player avsplayer -> - add an audio source to play queue Converts input to AudioBufferavsplayer -> - dequeu an audio source to playavsplayer -> - play next source in queueavsplayer -> - stop playingavsplayer -> - replay last audio source playedavsplayer -> - pause playingavsplayer -> - empty the queueavsplayer -> - play a blob sourceavsplayer -> - play an AudioBuffer sourceavsplayer -> - play mp3 url avsplayer LOG - when a debug log occurs ERROR - when an error occurs PLAY - when audio source is played REPLAY - when audio source is replayed PAUSE - when audio source is paused STOP - when audio source is stopped playing ENQUEUE - when an audio source is added to queue DEQUE - when an audio source is removed from queue
Resources
TODO
- Better documentation
License
MIT