我对使用Google speech API非常陌生。我的应用程序要求我连续流式传输用于语音识别的音频请求。连续使用超过1分钟。但是,根据Usage Limits,该服务在60秒后停止。有没有办法绕过这个问题?
任何帮助都是非常感谢的。
谢谢
发布于 2017-02-11 13:44:33
Google云控制台中有一个链接,指向一个表单,您可以在该表单中请求增加一些限制。但是,如果可能,请使用异步识别,这将为您提供最多80分钟的识别时间。
要获得限制增加表单,请执行以下操作:
在该弹出窗口中,转至API manager in the console
Discovery requests per 100 seconds
Discovery requests per 100 seconds发布于 2017-10-31 05:22:07
我在一个Node.js应用程序中通过创建一系列流识别请求解决了这个问题。
代码在这里:https://github.com/marciovm/Speech-Forever。
诀窍是在输入语音的适当中断上请求新的streams客户端(从用户的浏览器或类似的浏览器)。
关于app.js (节点服务器)的关键部分
var gstreams = []; // keeep track of speech streams
var activeStreamID = -1; // pointer to active speech stream
ws.on('message', function (data) {
if ( typeof data == 'string' ) {
if (data.indexOf("info")>0) { // client sends an info string on connection that triggers server to start a speech stream
console.log('Start first stream');
gstreams.push(startGoogleSpeechStream(ws));
activeStreamID = activeStreamID + 1;
}
else { // client requested a new speech stream (client-side logic allows for triggering on a lull in input volume)
console.log('Start another stream');
gstreams[activeStreamID].end();
gstreams.push(startGoogleSpeechStream(ws));
activeStreamID = activeStreamID + 1;
}
}
else {
gstreams[activeStreamID].write(data); // client sent audio, push it to active speech stream
}
}); 关于demo.js (客户端浏览器)的关键部分
var handleSuccess = function(stream) {
setRecordingTrue(1000); // give socket 1 sec to open
audioInput = context.createMediaStreamSource(stream);
audioInput.connect(recorder);
recorder.onaudioprocess = function(stream){
if(!recording) return;
var buf = stream.inputBuffer.getChannelData(0);
volume = detectVolume(buf, this);
$(".volume_meter")[0].value=volume * 100;
if (volume < 0.01 && (Date.now() > (streamStartTime + breakTime))) {
ws.send("restarting Google Stream");
console.log("restarting Google Stream");
streamStartTime = Date.now();
writeToCaret(' ');
}
else {
ws.send(float32ToInt16(buf)); // send audio stream to Node server
}
}
} https://stackoverflow.com/questions/40200220
复制相似问题