首页 文章

科尔多瓦|在iOS上从麦克风获取直播

提问于
浏览
3

我正在尝试构建一个语音日历应用程序,需要使用麦克风的实时流进行语音识别 .

因此,您有一个开始收听麦克风的按钮,并在用户停止讲话时自动停止 .

我已经探索过Cordova Media API,它允许我将数据记录到wav文件中 . 这可以工作,但是因为我需要等待录制完成,所以这个过程非常慢 .

我使用https://api.ai作为起点来构建应用程序的第一个版本,该版本运行良好 . 它照顾了所有"listening"部分!

我的下一阶段是与几个不同的语音识别API集成 .

对我来说主要的问题是缺乏原生开发技能,那么有没有可以帮助我做到这一点的cordova插件?

Update 1 - 1st April 2016

发现这个https://subvisual.co/blog/posts/39-tutorial-html-audio-capture-streaming-to-node-js-no-browser-extensions将尝试通过webrtc在cordova中实现这一点 .


Update 2 - 1st April 2016

已安装https://github.com/eface2face/cordova-plugin-iosrtc以利用webrtc


Update 3 - 2nd April 2016

坚持 AudioContext.createMediaStreamSource 不是iOS上的功能! AudioContext.createMediaStreamSource alternative for iOS?


Update 4 - 6th April 2016

走向本土 - 学习iOS开发的时间!

1 回答

  • 8

    很抱歉听到您放弃了Cordova,但如果您仍然感兴趣:我已经为iOS和Android创建了一个cordova插件,可以捕获麦克风数据并将其转发到应用程序的Web层 . 您可以依靠Web Audio API来处理传入的声音,也可以使用任何其他方式对原始声音数据进行编码和保存:

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

    用法示例:

    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();
    

相关问题