首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何使用StreamingRecognize超过1分钟?

如何使用StreamingRecognize超过1分钟?
EN

Stack Overflow用户
提问于 2016-10-23 14:30:45
回答 2查看 2.6K关注 0票数 1

我对使用Google speech API非常陌生。我的应用程序要求我连续流式传输用于语音识别的音频请求。连续使用超过1分钟。但是,根据Usage Limits,该服务在60秒后停止。有没有办法绕过这个问题?

任何帮助都是非常感谢的。

谢谢

EN

回答 2

Stack Overflow用户

发布于 2017-02-11 13:44:33

Google云控制台中有一个链接,指向一个表单,您可以在该表单中请求增加一些限制。但是,如果可能,请使用异步识别,这将为您提供最多80分钟的识别时间。

要获得限制增加表单,请执行以下操作:

在该弹出窗口中,转至API manager in the console

  • Click“quota”选项卡并向下滚动至任意可调整的配额,例如,在其右侧的“Discovery requests per 100 seconds

  • Click”图标上,
  1. 在该弹出窗口中,应该会有一个标题为“Discovery requests per 100 seconds
  2. Click
    1. ”的链接。
票数 0
EN

Stack Overflow用户

发布于 2017-10-31 05:22:07

我在一个Node.js应用程序中通过创建一系列流识别请求解决了这个问题。

代码在这里:https://github.com/marciovm/Speech-Forever

诀窍是在输入语音的适当中断上请求新的streams客户端(从用户的浏览器或类似的浏览器)。

关于app.js (节点服务器)的关键部分

代码语言:javascript
运行
复制
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 (客户端浏览器)的关键部分

代码语言:javascript
运行
复制
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   
      }     
    }    
  }  
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40200220

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档