swift Mac上的AVAudioEngine输入,干扰低优先级声音

ltskdhd1  于 9个月前  发布在  Swift
关注(0)|答案(1)|浏览(76)

我通过敲击Mac上的麦克风来分析声音,并将识别出的声音打印出来。
一切都运行良好,但它会干扰其他(我认为)低优先级的声音,例如界面听起来像是将项目拖离码头,在outlook中发送消息,在快捷方式或终端中说些什么。其他声音,如music.app播放,Siri说话没有被干扰。干扰听起来像是声音的最后一部分被重复了两次,非常明显。这是代码(直接从这里:https://developer.apple.com/documentation/soundanalysis/classifying_sounds_in_an_audio_stream):

import Cocoa
import AVFAudio

func startAudioEngine() {
    // Create a new audio engine.
    audioEngine = AVAudioEngine()

    // Get the native audio format of the engine's input bus.
    inputBus = AVAudioNodeBus(0)
    inputFormat = audioEngine.inputNode.inputFormat(forBus: inputBus)
    
    do {
        // Start the stream of audio data.
        try audioEngine.start()
    } catch {
        print("Unable to start AVAudioEngine: \(error.localizedDescription)")
    }
}

字符串
我尝试增加缓冲区,将qos改为实用程序(希望声音分析比系统声音更重要),在非主线程上运行。
问题是100% AVAudioEngine,任何帮助将不胜感激。

mspsb9vt

mspsb9vt1#

我已经和苹果的开发团队谈过这个问题,他们已经复制了这个问题,并且已经作为AVAudioEngine的一个错误提交了。

相关问题