gpt4 book ai didi

ios - 使用iOS SoundAnalysis Framework时出现“错误更新树格式”

转载 作者:行者123 更新时间:2023-12-01 16:01:43 24 4
gpt4 key购买 nike

我将SoundAnalysis framework与使用CreateML创建的CoreML模型结合使用。

我能够使用SNAudioFileAnalyzer对应用程序捆绑包中嵌入的音频文件执行分析,但是当对麦克风中的实时音频使用SNAudioStreamAnalyzer时无法使用。

使用以下代码时:

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

//https://forums.developer.apple.com/thread/44833
audioEngine.mainMixerNode

do {
// Start the stream of audio data.
try audioEngine.start()
} catch {
print("Unable to start AVAudioEngine: \(error.localizedDescription)")
}

// Get the native audio format of the engine's input bus.
let inputFormat = audioEngine.inputNode.inputFormat(forBus: 0)

// Create a new stream analyzer.
var streamAnalyzer = SNAudioStreamAnalyzer(format: inputFormat)

我在以下内容的最后一行出现错误:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Error updating tree format'

有人知道吗目前,关于SoundAnalysis框架的文章还很少,所以对此感到有些困惑。

最佳答案

我只是通过设置AVAudioSession.sharedInstance().setCategory(.playAndRecord)来解决错误

关于ios - 使用iOS SoundAnalysis Framework时出现“错误更新树格式”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58496448/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com