简体   繁体   English

iPhone通过语音启动录音

[英]iPhone start Audio Recording by Voice

i already have a 'start voice recording" when the volume reach a special level. But it has one downside. When it starts recording it already missed a 1/2 second or so. When speaking a sentence it would miss the first word. 当音量达到一个特殊水平时,我已经有了“开始录音”。但它有一个缺点。当它开始录音时已经错过了1/2秒左右。当说出一个句子时,它会错过第一个单词。

Any ideas (best with example). 任何想法(最好的例子)。

Lets say I start first listening and get the peakpower, average, lowpass 让我们说我开始先听,然后获得峰值功率,平均值,低通

 [recorder updateMeters];  ALPHA = 0.05;
peakPowerForChannel = pow(10, (0.05 * [recorder peakPowerForChannel:0]));
averagePowerForChannel = pow(10, (0.05 * [recorder averagePowerForChannel:0]));
lowPassResults = ALPHA * peakPowerForChannel + (1.0 - ALPHA) * lowPassResults;  
averagePassResults = ALPHA * averagePowerForChannel + (1.0 - ALPHA) * averagePassResults;   

than i look if its loud enough to record 比我看起来它的声音足够大

 if (peakPowerForChannel > 0.08f) ) -> start recording

and if its less than a value it stops 如果它小于一个值,它就会停止

  (peakPowerForChannel < 0.01f) -> stop record, start listening again

for now I found best is listening the peakpower, rather the average. 现在我发现最好听的是峰值功率,而不是平均值。 but still its not fine. 但仍然不好。 I also thought about to have a kind of tempory recording all time and when the peak is high enough I could start from now-2 seconds. 我还想过一直有一种临时录音,当峰值足够高时,我可以从现在开始--2秒。 Something like that, but here I dont know how to realize. 这样的事情,但在这里我不知道如何实现。 So any practical suggestions are welcome. 所以欢迎任何实用的建议。

thanks chris 谢谢克里斯

Like you said, continually record a short 1/2s chunk, which expands indefinitely when the power level is reached and indefinite recording starts. 就像你说的那样,不断记录一个短1/2的块,当达到功率级别并且无限期录制开始时,它会无限扩展。 When recording stops, it should include the missing 1/2s opening. 录制停止时,应包括缺少的1 / 2s开场。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM