简体   繁体   English

使用 CoreML 时的 DSPGraph

[英]DSPGraph when Using CoreML

I am trying to use a SoundAnalyisis model that takes in audioSamples(Float32 15600) and returns a vggishFeature (MultiArray (Float32 12288) however I receive this error:我正在尝试使用一个 SoundAnalyisis 模型,它接收 audioSamples(Float32 15600) 并返回一个 vggishFeature (MultiArray (Float32 12288),但是我收到了这个错误:

 -01-22 10:45:43.404715+0000 SRTester[25654:891998] [DSPGraph] throwing DSPGraph::Exception with backtrace:
0       0x7fff2bdc0df9  DSPGraph::Graph::processMultiple(DSPGraph::GraphIOData*, DSPGraph::GraphIOData*) + 249
1       0x7fff2bd2223d  SoundAnalysis::primeGraph(DSPGraph::Graph&, int) + 542
2       0x7fff2bcfbaae  -[SNSoundClassifier primeGraph] + 134
3       0x7fff2bd052c2  -[SNAnalyzerHost primeAnalyzerGraph] + 88
4       0x7fff2bd0f268  -[SNAudioStreamAnalyzer configureAnalysisTreeWithFormat:] + 263
5       0x7fff2bd0f74b  -[SNAudioStreamAnalyzer _analyzeAudioBuffer:atAudioFramePosition:] + 303
6          0x10af1cd48  _dispatch_client_callout + 8
7          0x10af2b9bf  _dispatch_lane_barrier_sync_invoke_and_complete + 132
8       0x7fff2bd0f5d8  -[SNAudioStreamAnalyzer analyzeAudioBuffer:atAudioFramePosition:] + 121
9          0x10abb3116  $s8SRTester18homeViewControllerC16startAudioEngine33_CDAAA73F093090436FCAC2E152DEFC64LLyyFySo16AVAudioPCMBufferC_So0M4TimeCtcfU_yycfU_ + 326
10         0x10abb315d  $sIeg_IeyB_TR + 45
11         0x10af1bdd4  _dispatch_call_block_and_release + 12
12         0x10af1cd48  _dispatch_client_callout + 8
13         0x10af235ef  _dispatch_lane_serial_drain + 788
14         0x10af2417f  _dispatch_lane_invoke + 422
15         0x10af2fa4e  _dispatch_workloop_worker_thread + 719
[truncated?]
libc++abi.dylib: terminating with uncaught exception of type DSPGraph::Exception
(lldb)

The code throws the error in this line:代码在这一行抛出错误:

self.analyzer.analyze(buffer, atAudioFramePosition: time.sampleTime)

which belongs to this block of code:属于这个代码块:

/// Starts the audio engine
private func startAudioEngine() {
    self.isLisitingForInferance = true

    //requests to use the engine
    do {
        let request = try SNClassifySoundRequest(mlModel: soundClassifier.model)
        try analyzer.add(request, withObserver: resultsObserver) // sets the results observator
    } catch {
        print("Unable to prepare request: \(error.localizedDescription)")
        return
    }
    //starts a async task for the analyser
    audioEngine.inputNode.installTap(onBus: 0, bufferSize: 16000, format: inputFormat) { buffer, time in
        self.analysisQueue.async {
            self.analyzer.analyze(buffer, atAudioFramePosition: time.sampleTime) //this line recives a SIGABRT
        }
    }

    do{
        try audioEngine.start()
    }catch( _){
        print("error in starting the Audio Engine")
    }
}

Here is the class obsivation (although it does not even get triggered:这是类观察(尽管它甚至没有被触发:

class ResultsObserver: NSObject, SNResultsObserving {
    var delegate: iPhoneSpeakerRecongitionDelegate?
    func request(_ request: SNRequest, didProduce result: SNResult) {
        guard let result = result as? SNClassificationResult,
            let classification = result.classifications.first else { return }
        //print("here")
        let confidence = classification.confidence * 100.0
        //print(classification.)


        if confidence > 60 {
            delegate?.displayPredictionResult(identifier: classification.identifier, confidence: confidence)
        }
    }
}

Managed to get this to return a different error (which is where the model was incompatible)设法让它返回一个不同的错误(这是模型不兼容的地方)

To resolve this you have to manually move the model file into the app directory and then add it to xcode - it seems to be a bug in Xcode putting the model that is stored in another directory into the app package要解决此问题,您必须手动将模型文件移动到应用程序目录中,然后将其添加到 xcode - 将存储在另一个目录中的模型放入应用程序包似乎是 Xcode 中的一个错误

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

相关问题 使用 MLMultiArray 作为 CoreML 模型的输出 - Using an MLMultiArray as an Output of a CoreML model ios / CoreML-将keras模型转换为CoreML时,输入类型为MultiArray - ios / CoreML - The input type is MultiArray when keras model is converted to CoreML 使用 AVAssetWriter 和 CoreML 的相机上的 FPS 不一致 - FPS not consistent on Camera using AVAssetWriter and CoreML 在CoreML VNCoreMLRequest之前触发时未显示ActivityIndi​​cator - ActivityIndicator not showing when triggered before CoreML VNCoreMLRequest 更新 CoreML model 时 MLUpdateContext 为空 - MLUpdateContext is empty when updating CoreML model 在后台模式下使用 CoreML 对用户活动进行分类 - Classifing user activity using CoreML in background mode 在 iOS 12.4 上使用 CoreML Word Tagger - Using CoreML Word Tagger on iOS 12.4 初始化CoreML模型时崩溃:Error Domain = com.apple.CoreML Code = 0“声明网络时出错。” - Crash when initializing CoreML model: Error Domain=com.apple.CoreML Code=0 “Error in declaring network.” CoreML错误:导入mymodel.mlmodel时,源文件无效 - error with CoreML: source file is not valid , when importing mymodel.mlmodel 当应用程序不再需要 CoreML 时,如何阻止它运行? - How to stop CoreML from running when it's no longer needed in the app?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM