Socket
Socket
Sign inDemoInstall

node-wit

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-wit - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

2

lib/wit.js

@@ -19,3 +19,3 @@ /*

var _ = require('underscore');
var VERSION = "20140916";
var VERSION = "20141119";

@@ -22,0 +22,0 @@ var getHeaders = function (access_token, others) {

{
"name": "node-wit",
"version": "1.0.0",
"version": "1.1.0",
"private": false,

@@ -5,0 +5,0 @@ "homepage": "https://github.com/wit-ai/node-wit",

@@ -1,58 +0,61 @@

# Wit.AI wrapper for Node.JS
## Quick start
1. You need to create an instance
1. You need to create an [Wit instance first](https://wit.ai/docs/console/quickstart).
2. Install [Node.JS](http://nodejs.org/) on your computer
2. Install [Node.JS](http://nodejs.org/) on your computer.
3. Setup your project
Create a new Node.JS app :
Create a new Node.JS app :
```bash
$ mkdir myapp
$ cd myapp
$ npm init
...
```
Add node-wit as a dependencies in your package.json
```json
"dependencies": {
"node-wit": "1.1.0"
},
```
Execute `npm install` in your current folder to fetch the dependencies
We will send an audio file to Wit.AI
You can use [SoX](http://sox.sourceforge.net) to record WAV files from the command line.
`brew install sox` on OSX and `apt-get install sox` on ubuntu.
The following options will create a Wit-ready WAV file (press Ctrl+C to stop recording):
```bash
sox -d -b 16 -c 1 -r 16k sample.wav
```
Create a `index.js` file in myapp directory containing:
```javascript
var wit = require('node-wit');
var fs = require('fs');
var ACCESS_TOKEN = "IQ77NWUPUMNBYEUEKRTWU3VDR5YSLHTA";
console.log("Sending text & audio to Wit.AI");
wit.captureTextIntent(ACCESS_TOKEN, "Hello world", function (err, res) {
console.log("Response from Wit for text input: ");
if (err) console.log("Error: ", err);
console.log(JSON.stringify(res, null, " "));
});
var stream = fs.createReadStream('sample.wav');
wit.captureSpeechIntent(ACCESS_TOKEN, stream, "audio/wav", function (err, res) {
console.log("Response from Wit for audio stream: ");
if (err) console.log("Error: ", err);
console.log(JSON.stringify(res, null, " "));
});
```
```bash
$ mkdir myapp
$ cd myapp
$ npm init
...
```
Add node-wit as a dependencies in your package.json
```json
"dependencies": {
"node-wit": "1.0.0"
},
```
We will send some audio file to Wit.AI
You can use [SoX](http://sox.sourceforge.net) to record WAV files from the command line.
The following options will create a Wit-ready WAV file (press Ctrl+C to stop recording):
```bash
sox -d -b 16 -c 1 -r 16k sample.wav
```
Create a `index.js` file in myapp directory containing:
```javascript
var wit = require('node-wit');
var fs = require('fs');
var ACCESS_TOKEN = "YOUR TOKEN HERE";
console.log("Sending text & audio to Wit.AI");
wit.captureTextIntent(ACCESS_TOKEN, "Hello world", function (err, res) {
console.log("Error: ", err);
console.log("Response from Wit", JSON.stringify(res, null, " "));
});
var stream = fs.createReadStream('sample.wav');
wit.captureSpeechIntent(ACCESS_TOKEN, stream, "audio/wav", function (err, res) {
console.log("Error: ", err);
console.log("Response from Wit", JSON.stringify(res, null, " "));
});
```
4. Start your app

@@ -63,5 +66,5 @@

Sending text & audio to Wit.AI
Error: null
Response from Wit {
"msg_id": "2a029fb0-a962-42f1-b914-6f70a0a055be",
Response from Wit for text input:
{
"msg_id": "b46d4a08-1e2e-43f4-b30a-aaa7bccb88e3",
"_text": "Hello world",

@@ -77,5 +80,5 @@ "outcomes": [

}
Error: null
Response from Wit {
"msg_id": "a067f9f8-ef7d-4adf-8ffa-4a5080544fdd",
Response from Wit for audio stream:
{
"msg_id": "83c14e47-13cb-4ad4-9f5e-723cd47016be",
"_text": "what's the weather in New York",

@@ -111,3 +114,3 @@ "outcomes": [

- `text`: The text input you want to extract the meaning of
- `callback(error, response)`: A callback function get 3 arguments:
- `callback(error, response)`: A callback function get 2 arguments:
1. An `error` when applicable

@@ -119,4 +122,5 @@ 2. A JSON object containing the Wit.AI response

wit.captureTextIntent(ACCESS_TOKEN, "Hello world", function (err, res) {
console.log("Error: ", err);
console.log("Response from Wit", JSON.stringify(res, null, " "));
console.log("Response from Wit for text input: ");
if (err) console.log("Error: ", err);
console.log(JSON.stringify(res, null, " "));
});

@@ -133,3 +137,3 @@ ```

`audio/raw;encoding=unsigned-integer;bits=16;rate=8000;endian=big`, ...)
- `callback(error, response)`: A callback function get 3 arguments:
- `callback(error, response)`: A callback function get 2 arguments:
1. An `error` when applicable

@@ -140,7 +144,9 @@ 2. A JSON object containing the Wit.AI response

var wit = require('node-wit');
var fs = require('fs');
var stream = fs.createReadStream('sample.wav');
wit.captureSpeechIntent(ACCESS_TOKEN, stream, "audio/wav", function (err, res) {
console.log("Error: ", err);
console.log("Response from Wit", JSON.stringify(res, null, " "));
console.log("Response from Wit for audio stream: ");
if (err) console.log("Error: ", err);
console.log(JSON.stringify(res, null, " "));
});
```
```

@@ -31,3 +31,3 @@ /*

'Authorization': 'Bearer 1234',
'Accept': 'application/vnd.wit.20140916'
'Accept': 'application/vnd.wit.20141119'
}

@@ -62,3 +62,3 @@ }).get('/message?q=set%20alarm%20tomorrow%20at%205pm')

'Authorization': 'Bearer 1234',
'Accept': 'application/vnd.wit.20140916',
'Accept': 'application/vnd.wit.20141119',
'Content-Type': "audio/wav"

@@ -65,0 +65,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc