├── .gitignore ├── LICENSE ├── README.md ├── index.js ├── lib └── wit.js ├── package.json └── test ├── resources ├── sample.wav └── wit_response.json ├── wit_record.js └── wit_test.js /.gitignore: -------------------------------------------------------------------------------- 1 | ### https://raw.github.com/github/gitignore/77e29837cf03b59fc4d885ea011bbd683caaaf85/node.gitignore 2 | 3 | # Logs 4 | logs 5 | *.log 6 | 7 | # Runtime data 8 | pids 9 | *.pid 10 | *.seed 11 | 12 | # Directory for instrumented libs generated by jscoverage/JSCover 13 | lib-cov 14 | 15 | # Coverage directory used by tools like istanbul 16 | coverage 17 | 18 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 19 | .grunt 20 | 21 | # node-waf configuration 22 | .lock-wscript 23 | 24 | # Compiled binary addons (http://nodejs.org/api/addons.html) 25 | build/Release 26 | 27 | # Dependency directory 28 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git 29 | node_modules 30 | 31 | 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014, Wit.ai, Inc. All rights reserved. 3 | * 4 | * You are hereby granted a non-exclusive, worldwide, royalty-free license to 5 | * use, copy, modify, and distribute this software in source code or binary 6 | * form for use in connection with the web services and APIs provided by 7 | * Wit.ai. 8 | * 9 | * As with any software that integrates with the Wit.ai platform, your use 10 | * of this software is subject to the Wit.ai Terms of Service 11 | * [https://wit.ai/terms]. This copyright notice shall be included in all 12 | * copies or substantial portions of the software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | * DEALINGS IN THE SOFTWARE. 21 | * 22 | */ 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Quick start 2 | 3 | 1. You need to create an [Wit instance first](https://wit.ai/docs/console/quickstart). 4 | 5 | 2. Install [Node.JS](http://nodejs.org/) on your computer. 6 | 7 | 3. Setup your project 8 | 9 | Create a new Node.JS app : 10 | 11 | ```bash 12 | $ mkdir myapp 13 | $ cd myapp 14 | $ npm init 15 | ... 16 | ``` 17 | 18 | Install and add node-wit as a dependencies in your package.json : 19 | 20 | ```bash 21 | npm install --save node-wit 22 | ``` 23 | 24 | Execute `npm install` in your current folder to fetch the dependencies 25 | 26 | We will send an audio file to Wit.AI 27 | 28 | You can use [SoX](http://sox.sourceforge.net) to record WAV files from the command line. 29 | `brew install sox` on OSX and `apt-get install sox` on ubuntu. 30 | The following options will create a Wit-ready WAV file (press Ctrl+C to stop recording): 31 | 32 | ```bash 33 | sox -d -b 16 -c 1 -r 16k sample.wav 34 | ``` 35 | 36 | Create a `index.js` file in myapp directory containing: 37 | 38 | ```javascript 39 | var wit = require('node-wit'); 40 | var fs = require('fs'); 41 | var ACCESS_TOKEN = "IQ77NWUPUMNBYEUEKRTWU3VDR5YSLHTA"; 42 | 43 | console.log("Sending text & audio to Wit.AI"); 44 | 45 | wit.captureTextIntent(ACCESS_TOKEN, "Hello world", function (err, res) { 46 | console.log("Response from Wit for text input: "); 47 | if (err) console.log("Error: ", err); 48 | console.log(JSON.stringify(res, null, " ")); 49 | }); 50 | 51 | var stream = fs.createReadStream('sample.wav'); 52 | wit.captureSpeechIntent(ACCESS_TOKEN, stream, "audio/wav", function (err, res) { 53 | console.log("Response from Wit for audio stream: "); 54 | if (err) console.log("Error: ", err); 55 | console.log(JSON.stringify(res, null, " ")); 56 | }); 57 | ``` 58 | 59 | 4. Start your app 60 | 61 | ```bash 62 | $ node index.js 63 | Sending text & audio to Wit.AI 64 | Response from Wit for text input: 65 | { 66 | "msg_id": "b46d4a08-1e2e-43f4-b30a-aaa7bccb88e3", 67 | "_text": "Hello world", 68 | "outcomes": [ 69 | { 70 | "_text": "Hello world", 71 | "intent": "greetings_hi", 72 | "entities": {}, 73 | "confidence": 0.929 74 | } 75 | ] 76 | } 77 | Response from Wit for audio stream: 78 | { 79 | "msg_id": "83c14e47-13cb-4ad4-9f5e-723cd47016be", 80 | "_text": "what's the weather in New York", 81 | "outcomes": [ 82 | { 83 | "_text": "what's the weather in New York", 84 | "intent": "weather", 85 | "entities": { 86 | "location": [ 87 | { 88 | "suggested": true, 89 | "value": "New York" 90 | } 91 | ] 92 | }, 93 | "confidence": 1 94 | } 95 | ] 96 | } 97 | ``` 98 | 99 | ## Examples 100 | 101 | 102 | ## API 103 | 104 | ### captureTextIntent 105 | 106 | The `captureTextIntent` function returns the meaning extracted from the text 107 | input. The function takes 4 parameters: 108 | - `access_token`: Your access token for your instance 109 | - `text`: The text input you want to extract the meaning of 110 | - `options`: [optional] A json object containing any call options such as `verbose` or `context` 111 | - `callback(error, response)`: A callback function get 2 arguments: 112 | 1. An `error` when applicable 113 | 2. A JSON object containing the Wit.AI response 114 | 115 | ```javascript 116 | var wit = require('node-wit'); 117 | wit.captureTextIntent(ACCESS_TOKEN, "Hello world", function (err, res) { 118 | console.log("Response from Wit for text input: "); 119 | if (err) console.log("Error: ", err); 120 | console.log(JSON.stringify(res, null, " ")); 121 | }); 122 | ``` 123 | 124 | ### captureSpeechIntent 125 | 126 | The `captureSpeechIntent` function returns the meaning extracted from the audio 127 | input. The function takes 5 arguments: 128 | - `access_token`: Your access token for your instance 129 | - `stream`: The audio stream you want to extract the meaning of 130 | - `content-type`: The content-type of your audio stream (`audio/wav`, `audio/mpeg3`, 131 | `audio/raw;encoding=unsigned-integer;bits=16;rate=8000;endian=big`, ...) 132 | - `options`: [optional] A json object containing any call options such as `verbose` or `context` 133 | - `callback(error, response)`: A callback function get 2 arguments: 134 | 1. An `error` when applicable 135 | 2. A JSON object containing the Wit.AI response 136 | 137 | ```javascript 138 | var wit = require('node-wit'); 139 | var fs = require('fs'); 140 | var stream = fs.createReadStream('sample.wav'); 141 | wit.captureSpeechIntent(ACCESS_TOKEN, stream, "audio/wav", function (err, res) { 142 | console.log("Response from Wit for audio stream: "); 143 | if (err) console.log("Error: ", err); 144 | console.log(JSON.stringify(res, null, " ")); 145 | }); 146 | ``` 147 | 148 | ### captureSpeechIntentFromMic 149 | 150 | 151 | The `captureSpeechIntentFromMic` function returns the meaning extracted from the audio recorded from your microphone using sox. 152 | The function takes 5 arguments: 153 | - `access_token`: Your access token for your instance 154 | - `options`: [optional] A json object containing any call options such as `verbose` or `context` 155 | - `callback(error, response)`: A callback function get 2 arguments: 156 | 1. An `error` when applicable 157 | 2. A JSON object containing the Wit.AI response 158 | 159 | ```javascript 160 | var wit = require('node-wit'); 161 | // The `captureSpeechIntent` function returns the `node-record-lpcm16` object 162 | // See https://github.com/gillesdemey/node-record-lpcm16 for more details 163 | var recording = wit.captureSpeechIntentFromMic(ACCESS_TOKEN, function (err, res) { 164 | console.log("Response from Wit for microphone audio stream: "); 165 | if (err) console.log("Error: ", err); 166 | console.log(JSON.stringify(res, null, " ")); 167 | }); 168 | // The microphone audio stream will automatically attempt to stop when it encounters silence. 169 | // You can stop the recording manually by calling `stop` 170 | // Ex: Stop recording after five seconds 171 | setTimeout(function () { 172 | recording.stop(); 173 | }, 5000); 174 | ``` 175 | 176 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Wit.AI Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | module.exports = require("./lib/wit.js"); -------------------------------------------------------------------------------- /lib/wit.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Wit.AI Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | var request = require('request'); 18 | var _ = require('underscore'); 19 | var record = require('node-record-lpcm16'); 20 | var VERSION = "20150306"; 21 | 22 | var getHeaders = function (access_token, others) { 23 | return _.extend(others || {}, { 24 | 'Authorization': 'Bearer ' + access_token, 25 | 'Accept': 'application/vnd.wit.' + VERSION 26 | }); 27 | }; 28 | 29 | /** 30 | * Returns the meaning extracted from the text input 31 | * @param access_token your access token from your instance settings page 32 | * @param text the text you want to analyze 33 | * @param [options] json object to be passed to wit. Can include any of 'context', 'verbose', 'n' 34 | * @param callback callback that takes 2 arguments err and the response body 35 | */ 36 | var captureTextIntent = function (access_token, text, options, callback) { 37 | if(!callback) { 38 | callback = options; 39 | options = undefined; 40 | } 41 | 42 | // Set up the query 43 | query_params = _.extend({'q': text}, options); 44 | 45 | // Request options 46 | var request_options = { 47 | url: 'https://api.wit.ai/message', 48 | qs: query_params, 49 | json: true, 50 | headers: getHeaders(access_token) 51 | }; 52 | 53 | // Make the request 54 | request(request_options, function (error, response, body) { 55 | if (response && response.statusCode != 200) { 56 | error = "Invalid response received from server: " + response.statusCode 57 | } 58 | callback(error, body); 59 | }); 60 | }; 61 | 62 | /** 63 | * Returns the meaning extracted from an audio stream 64 | * @param access_token your access token from your instance settings page 65 | * @param stream The audio stream to send over to WIT.AI 66 | * @param content_type The content-type for this audio stream (audio/wav, ...) 67 | * @param [options] json object to be passed to wit. Can include any of 'context', 'verbose', 'n' 68 | * @param callback callback that takes 2 arguments err and the response body 69 | */ 70 | var captureSpeechIntent = function (access_token, stream, content_type, options, callback) { 71 | if(!callback) { 72 | callback = options; 73 | options = undefined; 74 | } 75 | 76 | // Set up the query (empty b/c not sending 'q') 77 | query_params = _.extend({}, options); 78 | 79 | // Request options 80 | var request_options = { 81 | url: 'https://api.wit.ai/speech', 82 | qs: query_params, // may be empty object 83 | method: 'POST', 84 | json: true, 85 | headers: getHeaders(access_token, {'Content-Type': content_type}) 86 | }; 87 | 88 | // Pipe the request 89 | stream.pipe(request(request_options, function (error, response, body) { 90 | if (response && response.statusCode != 200) { 91 | error = "Invalid response received from server: " + response.statusCode 92 | } 93 | callback(error, body); 94 | })); 95 | }; 96 | 97 | 98 | /** 99 | * Returns the meaning extracted from an audio stream from the microphone using sox 100 | * @param access_token your access token from your instance settings page 101 | * @param [options] json object to be passed to wit. Can include any of 'context', 'verbose', 'n' 102 | * @param callback callback that takes 2 arguments err and the response body 103 | * @return record recording that can be stopped manually 104 | */ 105 | var captureSpeechIntentFromMic = function (access_token, options, callback) { 106 | if(!callback) { 107 | callback = options; 108 | options = undefined; 109 | } 110 | 111 | // Setup audio stream 112 | var content_type = 'audio/wav'; 113 | var stream = record.start(); 114 | 115 | // Get the speech intent for the microphone stream 116 | captureSpeechIntent(access_token, stream, content_type, options, callback); 117 | 118 | // Return record so it can be manually/forcefully stopped 119 | return record; 120 | 121 | }; 122 | 123 | module.exports.captureTextIntent = captureTextIntent; 124 | module.exports.captureSpeechIntent = captureSpeechIntent; 125 | module.exports.captureSpeechIntentFromMic = captureSpeechIntentFromMic; 126 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node-wit", 3 | "version": "2.0.0", 4 | "private": false, 5 | "homepage": "https://github.com/wit-ai/node-wit", 6 | "description": "Node module to request Wit.AI", 7 | "repository": "https://github.com/wit-ai/node-wit", 8 | "bugs": { 9 | "url": "https://github.com/wit-ai/node-wit/issues" 10 | }, 11 | "keywords": [ 12 | "wit", 13 | "automation", 14 | "home", 15 | "siri", 16 | "wit.ai", 17 | "nlp", 18 | "speech", 19 | "intent", 20 | "jarvis" 21 | ], 22 | "author": { 23 | "name": "Olivier Vaussy", 24 | "email": "oliv@wit.ai" 25 | }, 26 | "contributors": [ 27 | { 28 | "name": "Anthony Kesich", 29 | "email": "anthony@wit.ai" 30 | }, 31 | { 32 | "name": "irfaan", 33 | "email": "github@irfaan.com" 34 | } 35 | ], 36 | "scripts": { 37 | "test": "node_modules/mocha/bin/_mocha test/*_test.js --ignore-leaks -t 20000 --reporter spec" 38 | }, 39 | "dependencies": { 40 | "node-record-lpcm16": "0.1.4", 41 | "request": "2.42.0", 42 | "underscore": "1.7.0" 43 | }, 44 | "devDependencies": { 45 | "mocha": "1.21.4", 46 | "nock": "0.47.0", 47 | "chai": "1.9.1" 48 | }, 49 | "main": "./index.js" 50 | } 51 | -------------------------------------------------------------------------------- /test/resources/sample.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookarchive/DEPRECATED-node-wit/a61a384b00db1e06305e794eacf680a58dfdaf62/test/resources/sample.wav -------------------------------------------------------------------------------- /test/resources/wit_response.json: -------------------------------------------------------------------------------- 1 | { 2 | "msg_id" : "595b9d2b-2465-47e0-b18a-8e6827dbdb88", 3 | "_text" : "set alarm tomorrow at 5pm", 4 | "outcomes" : [ { 5 | "_text" : "set alarm tomorrow at 5pm", 6 | "intent" : "alarm_set", 7 | "entities" : { 8 | "datetime" : [ { 9 | "value" : { 10 | "from" : "2014-09-17T17:00:00.000-07:00", 11 | "to" : "2014-09-17T18:00:00.000-07:00" 12 | } 13 | } ], 14 | "on_off" : [ { 15 | "value" : "on" 16 | } ] 17 | }, 18 | "confidence" : 0.998 19 | } ] 20 | } -------------------------------------------------------------------------------- /test/wit_record.js: -------------------------------------------------------------------------------- 1 | /* 2 | * To run: 3 | * WIT_ACCESS_TOKEN= node test/wit_record.js 4 | */ 5 | var wit = require('../lib/wit'); 6 | var ACCESS_TOKEN = process.env.WIT_ACCESS_TOKEN; 7 | var path = require('path'); 8 | var fs = require('fs'); 9 | 10 | // The `captureSpeechIntent` function returns the `node-record-lpcm16` object 11 | // See https://github.com/gillesdemey/node-record-lpcm16 for more details 12 | console.log('Recording...'); 13 | var recording = wit.captureSpeechIntentFromMic(ACCESS_TOKEN, function (err, res) { 14 | console.log("Response from Wit for microphone audio stream: "); 15 | if (err) console.log("Error: ", err); 16 | console.log(JSON.stringify(res, null, " ")); 17 | }); 18 | // The microphone audio stream will automatically attempt to stop when it encounters silence. 19 | // You can stop the recording manually by calling `stop` 20 | // Ex: Stop recording after five seconds 21 | setTimeout(function () { 22 | recording.stop(); 23 | }, 5000); 24 | 25 | 26 | /* 27 | var stream = fs.createReadStream(path.resolve(__dirname, './resources/sample.wav')); 28 | wit.captureSpeechIntent(ACCESS_TOKEN, stream, "audio/wav", function (err, res) { 29 | console.log("Response from Wit for microphone audio stream: "); 30 | if (err) console.log("Error: ", err); 31 | console.log(JSON.stringify(res, null, " ")); 32 | 33 | }); 34 | */ 35 | -------------------------------------------------------------------------------- /test/wit_test.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Wit.AI Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | var path = require('path'); 17 | var fs = require('fs'); 18 | var nock = require('nock'); 19 | var wit = require('../lib/wit.js'); 20 | var assert = require('chai').assert; 21 | 22 | describe('Wit', function () { 23 | var resourceDir = path.join(__dirname, '/resources'); 24 | var wit_response = require(path.join(resourceDir, 'wit_response.json')); 25 | var error_response = {code: 'invalid request'}; 26 | describe('captureTextIntent', function () { 27 | it('return the correct answer', function (done) { 28 | var scope = nock('https://api.wit.ai/', { 29 | reqheaders: { 30 | 'Authorization': 'Bearer 1234', 31 | 'Accept': 'application/vnd.wit.20150306' 32 | } 33 | }).get('/message?q=set%20alarm%20tomorrow%20at%205pm') 34 | .reply(200, wit_response); 35 | wit.captureTextIntent("1234", "set alarm tomorrow at 5pm", function (err, res) { 36 | assert.isNull(err, "error should be undefined"); 37 | assert.deepEqual(res, wit_response); 38 | scope.done(); 39 | done(); 40 | }); 41 | }); 42 | it('return the correct answer with states in context', function (done) { 43 | var scope = nock('https://api.wit.ai/', { 44 | reqheaders: { 45 | 'Authorization': 'Bearer 1234', 46 | 'Accept': 'application/vnd.wit.20150306' 47 | } 48 | }).get('/message?q=set%20alarm%20tomorrow%20at%205pm&context=%7B%22state%22%3A%5B%22myState1%22%2C%22myState2%22%5D%7D') 49 | .reply(200, wit_response); 50 | var context = JSON.stringify({state: ["myState1", "myState2"]}); 51 | wit.captureTextIntent("1234", "set alarm tomorrow at 5pm", 52 | {context: context}, 53 | function (err, res) { 54 | assert.isNull(err, "error should be undefined"); 55 | assert.deepEqual(res, wit_response); 56 | scope.done(); 57 | done(); 58 | }); 59 | }); 60 | it('return an error', function (done) { 61 | var scope = nock('https://api.wit.ai/') 62 | .get('/message?q=set%20alarm%20tomorrow%20at%205pm') 63 | .reply(400, error_response); 64 | wit.captureTextIntent("1234", "set alarm tomorrow at 5pm", function (err, res) { 65 | assert.equal(err, "Invalid response received from server: 400"); 66 | assert.deepEqual(res, error_response); 67 | scope.done(); 68 | done(); 69 | }); 70 | }); 71 | it('should send options as given in parameter', function (done) { 72 | var scope = nock('https://api.wit.ai/', { 73 | reqheaders: { 74 | 'Authorization': 'Bearer 1234', 75 | 'Accept': 'application/vnd.wit.20150306' 76 | } 77 | }).get('/message?q=set%20alarm%20tomorrow%20at%205pm&verbose=true&context=%7B%22test%22%3A%221%22%7D') 78 | .reply(200, wit_response); 79 | var options = {verbose: true, 80 | context: JSON.stringify({"test" : "1"})}; 81 | wit.captureTextIntent("1234", "set alarm tomorrow at 5pm", options, 82 | function (err, res) { 83 | assert.isNull(err, "error should be undefined"); 84 | assert.deepEqual(res, wit_response); 85 | scope.done(); 86 | done(); 87 | }); 88 | }); 89 | }); 90 | 91 | describe('captureSpeechIntent', function () { 92 | it('return the correct answer', function (done) { 93 | var stream = fs.createReadStream(path.join(resourceDir, 'sample.wav')); 94 | var scope = nock('https://api.wit.ai/', { 95 | reqheaders: { 96 | 'Authorization': 'Bearer 1234', 97 | 'Accept': 'application/vnd.wit.20150306', 98 | 'Content-Type': "audio/wav" 99 | } 100 | }).post('/speech') 101 | .reply(200, wit_response); 102 | wit.captureSpeechIntent("1234", stream, "audio/wav", function (err, res) { 103 | assert.isNull(err, "error should be undefined"); 104 | assert.deepEqual(res, wit_response); 105 | scope.done(); 106 | done(); 107 | }); 108 | }); 109 | it('return an error', function (done) { 110 | var stream = fs.createReadStream(path.join(resourceDir, 'sample.wav')); 111 | var scope = nock('https://api.wit.ai/') 112 | .post('/speech') 113 | .reply(404, error_response); 114 | wit.captureSpeechIntent("1234", stream, "audio/wav", function (err, res) { 115 | assert.equal(err, "Invalid response received from server: 404"); 116 | assert.deepEqual(res, error_response); 117 | scope.done(); 118 | done(); 119 | }) 120 | }); 121 | it('should send options as given in parameter', function (done) { 122 | var stream = fs.createReadStream(path.join(resourceDir, 'sample.wav')); 123 | var scope = nock('https://api.wit.ai/', { 124 | reqheaders: { 125 | 'Authorization': 'Bearer 1234', 126 | 'Accept': 'application/vnd.wit.20150306' 127 | } 128 | }).post('/speech?verbose=true&context=%7B%22test%22%3A%221%22%7D') 129 | .reply(200, wit_response); 130 | var options = {verbose: true, 131 | context: JSON.stringify({"test" : "1"})}; 132 | wit.captureSpeechIntent("1234", stream, "audio/wav", options, 133 | function (err, res) { 134 | assert.isNull(err, "error should be undefined"); 135 | assert.deepEqual(res, wit_response); 136 | scope.done(); 137 | done(); 138 | }); 139 | }); 140 | }); 141 | }); 142 | --------------------------------------------------------------------------------