Wit speech
Makes network request to Wit.ai's speech API. For more information about the API see the official documentation.
Installation
npm install --save witspeech
Usage
Constructor
// Import module.const WitSpeech = ;// Create an instance.const witSpeech = 'WIT_TOKEN' '20171207';
Replace WIT_TOKEN with your token retrieved from the wit.ai website.
Methods
// The type of content that you will stream.let contentType = 'audio/wav';// Additional and optional web request parameters.let queryParameters = {};// Callback function with the response.let { if error console; return; console;}; // Retrieves the web request to pipe information to.witSpeech;
To see what content types you can send over see the official documentation.
Example
From file
// Import node module.const fs = ; // Initialize module, see constructor section for more information.const WitSpeech = ;const witSpeech = 'WIT_TOKEN' '20171207'; // Create request, see methods section for more information.let request = witSpeech; // Create read file stream.let stream = fs;// Pipe the stream to the request.stream;
From microphone
// Initialize module, see constructor section for more information.const WitSpeech = ;const witSpeech = 'WIT_TOKEN' '20171207'; // Import audio recorderconst AudioRecorder = ;const audioRecorder = ; // Create request, see methods section for more information.let request = witSpeech; // Start audio recorder.audioRecorderstart;// Get microphone stream.let stream = audioRecorder;// Pipe the stream to the request.stream;
For the audio recorder see the package or repository for it.
For another example see the Electron-VoiceInterfacePrototype's input.js.