Audio Recording

Refer:http://blog.youkuaiyun.com/spenghui/article/details/77500721

  • Normal Mode

    rec radio.wav
  • Monitoring Mode
    keep listening, when volume greater than threshold then record it. There are two threshold params. The first is for starting recording, & the second is for stopping recording.

    rec -p | sox -p radio.wav silence 1 0.50 2% -1 2.0 2%
var Microphone = { // Setup the audiocontext and all required objects. Should be called before // any of the other js microphone interface functions in this file. If this // returns true, it is possible to start an audio recording with Start() JS_Microphone_InitOrResumeContext: function() { if (!WEBAudio || WEBAudio.audioWebEnabled == 0) { // No WEBAudio object (Unity version changed?) return false; } if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) { navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia; if (!navigator.getUserMedia) { return false; } } var ctx = document.unityMicrophoneInteropContext; if (!ctx) { document.unityMicrophoneInteropContext = {}; ctx = document.unityMicrophoneInteropContext; } if (!ctx.audioContext || ctx.audioContext.state == "closed") { // 创建时指定目标采样率 try { ctx.audioContext = new AudioContext({ sampleRate: 16000 }); } catch(e) { // 回退到默认采样率 ctx.audioContext = new AudioContext(); console.warn("Using default sample rate:", ctx.audioContext.sampleRate); } } if (ctx.audioContext.state == "suspended") { ctx.audioContext.resume(); } if (ctx.audioContext.state == "suspended") { return false; } return true; }, // Returns the index of the most recently created audio clip so we can // write to it. Should be called immediately after creating the clip and // the value stored for indexing purposes. // Relies on undocumented/unexposed js code within Unity's WebGL code, // so may break with later versions JS_Microphone_GetBufferInstanceOfLastAudioClip: function() { if (WEBAudio && WEBAudio.audioInstanceIdCounter) { return WEBAudio.audioInstanceIdCounter; } return -1; }, JS_Microphone_IsRecording: function
最新发布
03-15
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值