
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
You need to create an instance
Install Node.JS on your computer
Setup your project
Create a new Node.JS app :
$ mkdir myapp
$ cd myapp
$ npm init
...
Add node-wit as a dependencies in your package.json
"dependencies": {
"node-wit": "1.0.0"
},
We will send some audio file to Wit.AI
You can use SoX to record WAV files from the command line. The following options will create a Wit-ready WAV file (press Ctrl+C to stop recording):
sox -d -b 16 -c 1 -r 16k sample.wav
Create a index.js
file in myapp directory containing:
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, " "));
});
$ node index.js
Sending text & audio to Wit.AI
Error: null
Response from Wit {
"msg_id": "2a029fb0-a962-42f1-b914-6f70a0a055be",
"_text": "Hello world",
"outcomes": [
{
"_text": "Hello world",
"intent": "greetings_hi",
"entities": {},
"confidence": 0.929
}
]
}
Error: null
Response from Wit {
"msg_id": "a067f9f8-ef7d-4adf-8ffa-4a5080544fdd",
"_text": "what's the weather in New York",
"outcomes": [
{
"_text": "what's the weather in New York",
"intent": "weather",
"entities": {
"location": [
{
"suggested": true,
"value": "New York"
}
]
},
"confidence": 1
}
]
}
The captureTextIntent
function returns the meaning extracted from the text
input. The function takes 3 parameters:
access_token
: Your access token for your instancetext
: The text input you want to extract the meaning ofcallback(error, response)
: A callback function get 3 arguments:
error
when applicablevar wit = require('node-wit');
wit.captureTextIntent(ACCESS_TOKEN, "Hello world", function (err, res) {
console.log("Error: ", err);
console.log("Response from Wit", JSON.stringify(res, null, " "));
});
The captureSpeechIntent
function returns the meaning extracted from the audio
input. The function takes 4 arguments:
access_token
: Your access token for your instancestream
: The audio stream you want to extract the meaning ofcontent-type
: The content-type of your audio stream (audio/wav
, audio/mpeg3
,
audio/raw;encoding=unsigned-integer;bits=16;rate=8000;endian=big
, ...)callback(error, response)
: A callback function get 3 arguments:
error
when applicablevar wit = require('node-wit');
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, " "));
});
FAQs
Wit.ai Node.js SDK
The npm package node-wit receives a total of 572 weekly downloads. As such, node-wit popularity was classified as not popular.
We found that node-wit demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.