簡體   English   中英

使用 CoreML 時的 DSPGraph

[英]DSPGraph when Using CoreML

我正在嘗試使用一個 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)

代碼在這一行拋出錯誤:

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

屬於這個代碼塊:

/// 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")
    }
}

這是類觀察(盡管它甚至沒有被觸發:

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)
        }
    }
}

設法讓它返回一個不同的錯誤(這是模型不兼容的地方)

要解決此問題,您必須手動將模型文件移動到應用程序目錄中,然后將其添加到 xcode - 將存儲在另一個目錄中的模型放入應用程序包似乎是 Xcode 中的一個錯誤

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM