How can I extract the preceding audio (from microphone) as a buffer when silence is detected (JS)?

前端 未结 3 882
后悔当初
后悔当初 2020-12-05 11:20

I\'m using the Google Cloud API for Speech-to-text, with a NodeJS back-end. The app needs to be able to listen for voice commands, and transmit them to the back-end as a buf

3条回答
  •  不知归路
    2020-12-05 11:45

    The simplest approach would be to use .pause() and .resume(), .stop() methods of MediaRecorder() to allow user to start, pause, and stop recording audio captured utilizing navigator.mediaDevices.getUserMedia() and convert the resulting Blob to an ArrayBuffer, if that is what the api is expecting to be POSTed to server

    
    
    
    
      User Media Recording
    
    
    
      
      
      
      
    
    
    
    

    plnkr https://plnkr.co/edit/7caWYMsvub90G6pwDdQp?p=preview

提交回复
热议问题