我一直在使用节点js npm谷歌语音识别API v2 google-speech-api https://www.npmjs.com/package/google-speech-api它正在工作,但我需要获得“中期结果” 。
如何获得正在处理的音频的中间结果。 我在线搜索但无法找到有用的信息并使其正常工作。
以下是我目前正在处理的代码:
var speech = require('google-speech-api'); var fs = require('fs'); var opts = { file: 'amy_16.wav', key: 'xxxx', }; speech(opts, function (err, results) { console.log(JSON.stringify(results)); // [{result: [{alternative: [{transcript: '...'}]}]}] });I have been working on google speech recognition API v2 using node js npm google-speech-api https://www.npmjs.com/package/google-speech-api it is working, but i need to get the "interim results".
How can i get the interim results of the audio being processing. I have searched online but not able to find helpful information and make it work.
Below is the code i am working on currently:
var speech = require('google-speech-api'); var fs = require('fs'); var opts = { file: 'amy_16.wav', key: 'xxxx', }; speech(opts, function (err, results) { console.log(JSON.stringify(results)); // [{result: [{alternative: [{transcript: '...'}]}]}] });最满意答案
看起来你没有使用流识别。 为了获得部分结果,您需要使用speech.createRecognizeStream并将interimResults配置标志设置为true。 例如:
var request = { config: { encoding: 'LINEAR16', sampleRate: 16000 }, singleUtterance: false, interimResults: true }; fs.createReadStream('amy_16.wav') .on('error', console.error) .pipe(speech.createRecognizeStream(request)) .on('error', console.error) .on('data', function(data) { //do something with the data console.log(data) });不确定你想要实现什么,但为了简化你可能想要查看的东西。 它是一个始终聆听的语音识别框架,它支持开箱即用的部分结果。 它还可以进行热门词检测。 免责声明:这是我的项目
Looks like you aren't using streaming recognition. In order to get partial results you'll need to use speech.createRecognizeStream and set the interimResults config flag to true. For example:
var request = { config: { encoding: 'LINEAR16', sampleRate: 16000 }, singleUtterance: false, interimResults: true }; fs.createReadStream('amy_16.wav') .on('error', console.error) .pipe(speech.createRecognizeStream(request)) .on('error', console.error) .on('data', function(data) { //do something with the data console.log(data) });Not sure what you are trying to achieve, but to simplify things you might want to check out Sonus. It's an always listening speech recognition framework and it supports partial results out of the box. It also does hotword detection. Disclaimer: this is my project
更多推荐
发布评论