谷歌语音识别api v2中期结果(google speech recognition api v2 interim results)

编程入门 行业动态 更新时间:2024-10-11 15:23:35
谷歌语音识别api v2中期结果(google speech recognition api v2 interim results)

我一直在使用节点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

更多推荐

本文发布于:2023-07-27 07:34:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1287132.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:语音识别   api   google   results   interim

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!