Comparing version 6.2.2 to 6.3.0
@@ -6,4 +6,4 @@ /** | ||
module.exports = { | ||
DEFAULT_API_VERSION: '20210928', | ||
DEFAULT_API_VERSION: 20220608, | ||
DEFAULT_WIT_URL: 'https://api.wit.ai', | ||
}; |
@@ -42,2 +42,5 @@ /** | ||
}); | ||
wit.on('partialUnderstanding', rsp => { | ||
console.log('Live understanding: ' + JSON.stringify(rsp)); | ||
}); | ||
@@ -44,0 +47,0 @@ rl.on('line', line => { |
@@ -6,4 +6,4 @@ /** | ||
module.exports = { | ||
DEFAULT_API_VERSION: '20210928', | ||
DEFAULT_API_VERSION: 20220608, | ||
DEFAULT_WIT_URL: 'https://api.wit.ai', | ||
}; |
@@ -42,2 +42,5 @@ /** | ||
}); | ||
wit.on('partialUnderstanding', rsp => { | ||
console.log('Live understanding: ' + JSON.stringify(rsp)); | ||
}); | ||
@@ -44,0 +47,0 @@ rl.on('line', line => { |
@@ -15,2 +15,4 @@ /** | ||
const LIVE_UNDERSTANDING_API_VERSION = 20220608; | ||
class Wit extends EventEmitter { | ||
@@ -82,2 +84,5 @@ constructor(opts) { | ||
const live_understanding_enabled = | ||
apiVersion >= LIVE_UNDERSTANDING_API_VERSION; | ||
const req = fetch(fullURL, { | ||
@@ -106,10 +111,17 @@ body, | ||
} | ||
for (const {error, intents, text} of parseResponse(contents)) { | ||
for (const rsp of parseResponse(contents)) { | ||
const {error, intents, is_final, text} = rsp; | ||
// Live transcription | ||
if (!(error || intents)) { | ||
logger.debug('[speech] partialTranscription:', text); | ||
this.emit('partialTranscription', text); | ||
} else if (text) { | ||
logger.debug('[speech] fullTranscription:', text); | ||
this.emit('fullTranscription', text); | ||
} | ||
// Live understanding | ||
if (live_understanding_enabled && intents && !is_final) { | ||
logger.debug('[speech] partialUnderstanding:', rsp); | ||
this.emit('partialUnderstanding', rsp); | ||
} | ||
} | ||
@@ -123,3 +135,11 @@ }); | ||
.then(response => Promise.all([response.text(), response.status])) | ||
.then(([contents, status]) => [parseResponse(contents).pop(), status]) | ||
.then(([contents, status]) => { | ||
const finalResponse = parseResponse(contents).pop(); | ||
const {text} = finalResponse; | ||
logger.debug('[speech] fullTranscription:', text); | ||
this.emit('fullTranscription', text); | ||
return [finalResponse, status]; | ||
}) | ||
.catch(e => e) | ||
@@ -126,0 +146,0 @@ .then(makeWitResponseHandler(logger, 'speech')); |
@@ -15,2 +15,4 @@ /** | ||
const LIVE_UNDERSTANDING_API_VERSION = 20220608; | ||
class Wit extends EventEmitter { | ||
@@ -82,2 +84,5 @@ constructor(opts) { | ||
const live_understanding_enabled = | ||
apiVersion >= LIVE_UNDERSTANDING_API_VERSION; | ||
const req = fetch(fullURL, { | ||
@@ -106,10 +111,17 @@ body, | ||
} | ||
for (const {error, intents, text} of parseResponse(contents)) { | ||
for (const rsp of parseResponse(contents)) { | ||
const {error, intents, is_final, text} = rsp; | ||
// Live transcription | ||
if (!(error || intents)) { | ||
logger.debug('[speech] partialTranscription:', text); | ||
this.emit('partialTranscription', text); | ||
} else if (text) { | ||
logger.debug('[speech] fullTranscription:', text); | ||
this.emit('fullTranscription', text); | ||
} | ||
// Live understanding | ||
if (live_understanding_enabled && intents && !is_final) { | ||
logger.debug('[speech] partialUnderstanding:', rsp); | ||
this.emit('partialUnderstanding', rsp); | ||
} | ||
} | ||
@@ -123,3 +135,11 @@ }); | ||
.then(response => Promise.all([response.text(), response.status])) | ||
.then(([contents, status]) => [parseResponse(contents).pop(), status]) | ||
.then(([contents, status]) => { | ||
const finalResponse = parseResponse(contents).pop(); | ||
const {text} = finalResponse; | ||
logger.debug('[speech] fullTranscription:', text); | ||
this.emit('fullTranscription', text); | ||
return [finalResponse, status]; | ||
}) | ||
.catch(e => e) | ||
@@ -126,0 +146,0 @@ .then(makeWitResponseHandler(logger, 'speech')); |
{ | ||
"name": "node-wit", | ||
"version": "6.2.2", | ||
"version": "6.3.0", | ||
"description": "Wit.ai Node.js SDK", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
19152
604
7