【问题标题】:Cannot use Voice Isolation with AVAudioRecorder or AudioUnit无法将语音隔离与 AVAudioRecorder 或 AudioUnit 一起使用
【发布时间】:2022-08-17 01:19:34
【问题描述】:
我正在尝试使用AVAudioRecorder 或AUAudioUnit 录制语音音频。
在这两种情况下,录音开始后,无论何时拨打AVCaptureDevice.showSystemUserInterface(.microphoneModes) 并选择语音隔离,都会出现以下错误:
\"语音隔离和广谱目前不可用\"
TLDR:我需要什么才能让用户更改为语音隔离模式?
标签:
swift
audiounit
avaudiorecorder
ios15
【解决方案1】:
我有一个实时播放音频的应用程序,通过编写以下内容可以使用音频分离模式。
private let audioEngine = AVAudioEngine()
// omission (of middle part of a text)
let audioInput = audioEngine.inputNode
audioInput.isVoiceProcessingBypassed = true
do {
try audioInput.setVoiceProcessingEnabled(true)
} catch {
print("Could not enable voice processing \(error)")
return
}
let audioFormat = audioEngine.inputNode.outputFormat(forBus: 0)
audioEngine.connect(audioInput, to: audioEngine.mainMixerNode, format:audioFormat)
由于我使用的是 AVAudioEngine,我相信只需更改 AVAudioEngine 输出目标即可实现您的目标。