Cordova | Get live stream from microphone on iOS

2019-03-31 14:10发布

I am trying to build a voice calendar app that needs to use live stream from the microphone for speech recognition.

So you have a button that starts listening to the microphone and stops automatically when the user stops speaking.

I have already explored Cordova Media API that allows me to record the data to a wav file. This works but makes the process very slow since I need to wait for the recording to be finished.

I used the https://api.ai as a starting point to build the 1st version of the app which works quite well. It took care of all the "listening" part!

Next phase for me is to integrate with a few different speech recognition APIs.

The major issue for me has been the lack of native development skills, so are there any cordova plugins that can help me do this?

Update 1 - 1st April 2016

Found this https://subvisual.co/blog/posts/39-tutorial-html-audio-capture-streaming-to-node-js-no-browser-extensions Will be trying to implement this in cordova through webrtc.


Update 2 - 1st April 2016

Installed https://github.com/eface2face/cordova-plugin-iosrtc to utilize webrtc


Update 3 - 2nd April 2016

Stuck at AudioContext.createMediaStreamSource is not a function on iOS! AudioContext.createMediaStreamSource alternative for iOS?


Update 4 - 6th April 2016

Going Native - Time to learn iOS Development!

1条回答
smile是对你的礼貌
2楼-- · 2019-03-31 14:32

Sorry to hear that you gave up on Cordova, but if you still are interested: I've created a cordova plugin for iOS and Android, that enables you to capture microphone data and forward it to the web layer of your application. You can either rely on the Web Audio API to handle the incoming sound, or use any other way to encode and save the raw sound data:

https://github.com/edimuj/cordova-plugin-audioinput

Example usage:

function onAudioInput( evt ) {
  // 'evt.data' is an integer array containing raw audio data
  console.log( "Audio data received: " + evt.data.length + " samples" );

  // ... do something with the evt.data array ...
}

// Listen to audioinput events
window.addEventListener( "audioinput", onAudioInput, false );

// Start capturing audio from the microphone
audioinput.start();
查看更多
登录 后发表回答