{"id":3929,"date":"2021-10-19T17:49:25","date_gmt":"2021-10-19T09:49:25","guid":{"rendered":"http:\/\/123.57.164.21\/?p=3929"},"modified":"2021-10-19T17:49:25","modified_gmt":"2021-10-19T09:49:25","slug":"swiftui%e4%b9%8b%e5%a3%b0%e9%9f%b3%e8%af%86%e5%88%ab%ef%bc%88machinelearning%ef%bc%89","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=3929","title":{"rendered":"SwiftUI\u4e4b\u58f0\u97f3\u8bc6\u522b\uff08MachineLearning\uff09"},"content":{"rendered":"\n<p>SwiftUI\u4e4b\u58f0\u97f3\u8bc6\u522b<br>\u914d\u5408MachineLearning\u529f\u80fd\uff0c\u5224\u65ad\u8bf4\u8bdd\u7684\u4eba\u662f\u7537\u6027\u8fd8\u662f\u5973\u6027\u3002\u9700\u8981\u5b9e\u73b0\u8fd9\u4e2a\u529f\u80fd\uff0c\u9996\u5148\u9700\u8981\u6709MachineLearning\u6a21\u5757\uff0c\u5373\u5df2\u7ecf\u8bad\u7ec3\u8fc7\u7684\u6570\u636e\u3002<br>\u82f9\u679c\u81ea\u5e26\u4e86CreateML\u5de5\u5177\uff0c\u53ef\u4ee5\u81ea\u5df1\u8bad\u7ec3\u56fe\u7247\uff0c\u6587\u5b57\uff0c\u58f0\u97f3\uff0c\u751a\u81f3\u56fe\u8868\uff0c\u5173\u952e\u5728\u4e8e\u6536\u96c6\u683c\u5f0f\u5408\u9002\u4ee5\u53ca\u6570\u91cf\u53ef\u89c2\u7684\u6570\u636e\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2021\/10\/image-26-1024x589.png\" alt=\"\" class=\"wp-image-3930\" width=\"666\" height=\"383\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-26-1024x589.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-26-300x173.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-26-768x442.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-26-1536x884.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-26-830x478.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-26-230x132.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-26-350x201.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-26-480x276.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-26.png 1912w\" sizes=\"(max-width: 666px) 100vw, 666px\" \/><\/figure><\/div>\n\n\n\n<p>\u4e0a\u56fe\u662f\u8bad\u7ec3\u97f3\u9891\u7684\u8f6f\u4ef6\uff0c\u4f7f\u7528\u65b9\u6cd5\u5f88\u7b80\u5355\uff0c\u7c7b\u4f3c\u4e8e\u6587\u672c\u8bad\u7ec3\uff0c\u901a\u8fc7\u6587\u4ef6\u5939\u533a\u5206\u7537\u5973\u58f0\uff0c\u7136\u540e\u5728\u6587\u4ef6\u5939\u4e0b\u653e\u7f6e\u641c\u96c6\u7684\u7537\u5973\u58f0\u97f3\u9891\u6587\u4ef6\uff0c\u4e3a\u4e86\u51c6\u786e\u6027\uff0c\u53ef\u4ee5\u5c06\u6587\u4ef6\u5206\u7c7b\u4e3a\u8bad\u7ec3\u7528\uff0c\u6821\u9a8c\u7528\uff0c\u4ee5\u53ca\u6d4b\u8bd5\u7528\u3002\u5373\u5206\u6210\u5404\u79cd\u6587\u4ef6\u5939\uff0c\u800c\u97f3\u9891\u6587\u4ef6\u8d8a\u591a\u8d8a\u597d\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2021\/10\/image-27-1024x543.png\" alt=\"\" class=\"wp-image-3931\" width=\"690\" height=\"366\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-27-1024x543.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-27-300x159.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-27-768x408.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-27-1536x815.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-27-830x440.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-27-230x122.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-27-350x186.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-27-480x255.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-27.png 1888w\" sizes=\"(max-width: 690px) 100vw, 690px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2021\/10\/image-28-1024x472.png\" alt=\"\" class=\"wp-image-3932\" width=\"684\" height=\"315\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-28-1024x472.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-28-300x138.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-28-768x354.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-28-1536x708.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-28-830x383.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-28-230x106.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-28-350x161.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-28-480x221.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-28.png 1926w\" sizes=\"(max-width: 684px) 100vw, 684px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2021\/10\/image-29-1024x495.png\" alt=\"\" class=\"wp-image-3933\" width=\"695\" height=\"336\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-29-1024x495.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-29-300x145.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-29-768x372.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-29-1536x743.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-29-830x402.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-29-230x111.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-29-350x169.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-29-480x232.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-29.png 1918w\" sizes=\"(max-width: 695px) 100vw, 695px\" \/><\/figure><\/div>\n\n\n\n<p>\u7136\u540e\u5c06\u6587\u4ef6\u8def\u5f84\u653e\u5230\u8bad\u7ec3\u5de5\u5177CreateML\u4e2d<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2021\/10\/image-30-1024x533.png\" alt=\"\" class=\"wp-image-3934\" width=\"723\" height=\"376\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-30-1024x533.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-30-300x156.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-30-768x400.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-30-1536x799.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-30-830x432.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-30-230x120.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-30-350x182.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-30-480x250.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-30.png 1926w\" sizes=\"(max-width: 723px) 100vw, 723px\" \/><\/figure><\/div>\n\n\n\n<p>\u70b9\u51fb\u25b6\ufe0f\uff0c\u8bad\u7ec3\u5373\u53ef\u3002\u8bad\u7ec3\u540e\u7684\u6a21\u5757\u51c6\u786e\u6027\u8ddf\u5f88\u591a\u4e1c\u897f\u6709\u5173\uff0c\u7528\u4e8e\u8bad\u7ec3\u7684\u6587\u4ef6\u8d8a\u591a\u81ea\u7136\u8d8a\u597d\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2021\/10\/image-31-1024x158.png\" alt=\"\" class=\"wp-image-3935\" width=\"714\" height=\"110\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-31-1024x158.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-31-300x46.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-31-768x118.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-31-1536x236.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-31-830x128.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-31-230x35.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-31-350x54.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-31-480x74.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-31.png 1936w\" sizes=\"(max-width: 714px) 100vw, 714px\" \/><\/figure><\/div>\n\n\n\n<p>\u4eceOutput\u4e2d\u76f4\u63a5\u62d6\u51fa\u8bad\u7ec3\u597d\u7684\u6a21\u5757\uff0c\u5373\u53ef\u653e\u5165\u5de5\u7a0b\u4e2d\u3002<br>\u4ee5\u4e0a\u53ea\u662f\u7b80\u5355\u4ecb\u7ecd\u5236\u4f5c\u65b9\u6cd5\u3002<br>\u5f53\u6a21\u5757\u62d6\u5230\u5de5\u7a0b\u540e\uff0c\u5982\u56fe<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2021\/10\/image-32-1024x527.png\" alt=\"\" class=\"wp-image-3936\" width=\"707\" height=\"364\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-32-1024x527.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-32-300x155.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-32-768x396.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-32-1536x791.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-32-830x427.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-32-230x118.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-32-350x180.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-32-480x247.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-32.png 1930w\" sizes=\"(max-width: 707px) 100vw, 707px\" \/><\/figure><\/div>\n\n\n\n<p>Inputs\u4e3a\u6211\u4eec\u9700\u8981\u8f93\u5165\u6a21\u5757\u7684\u5185\u5bb9\uff0c\u5373\u97f3\u9891\u6837\u672c\uff08audioSamples\uff09,\u800c\u6a21\u5757\u4f1a\u8f93\u51fa\u8be5\u6837\u672c\u6700\u53ef\u80fd\u7684\u5206\u7c7b\u53ca\u53ef\u80fd\u6027\u6bd4\u4f8b\u3002<\/p>\n\n\n\n<p>\u56e0\u4e3a\u9700\u8981\u7528\u5230\u97f3\u9891\u83b7\u53d6\u4ee5\u53ca\u58f0\u97f3\u5206\u6790\uff0c\u6240\u4ee5\u9996\u5148<br><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2021\/10\/image-33-1024x216.png\" alt=\"\" class=\"wp-image-3937\" width=\"730\" height=\"154\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-33-1024x216.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-33-300x63.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-33-768x162.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-33-830x175.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-33-230x49.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-33-350x74.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-33-480x101.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-33.png 1344w\" sizes=\"(max-width: 730px) 100vw, 730px\" \/><\/figure><\/div>\n\n\n\n<p>\u5b9a\u4e49\u4e00\u4e2aObservableObject\u7c7b\u578b\u53d8\u91cf<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class testMessage: ObservableObject{\n    @Published var message = \"Nothing\"\n}\n<\/pre>\n\n\n\n<p>\u56e0\u4e3a\u9700\u8981\u5728\u4e0d\u540c\u7684\u89c6\u56fe\u5185\u4f20\u9012\u6570\u636e\uff0c\u4f7f\u7528\u4e86protocol\u4ee5\u53canotification\u4e24\u79cd\u65b9\u5f0f\u4f20\u9012\u6570\u636e<br>\u5728contentView\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u53d8\u91cf<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/\u53e6\u4e00\u79cd\u6570\u636e\u4f20\u9012\u65b9\u5f0f\u6d4b\u8bd5\u7528\n@State  var message = \"Nothing\"\n    \n    @ObservedObject var myMessage = testMessage()\n    \/\/AVEngine\n    private let audioEngine = AVAudioEngine()\n    \/\/\u58f0\u97f3\u8bc6\u522b\u6a21\u5757\n    private var soundClassifier = MySoundClassifier 1()\n\n    var inputFormat: AVAudioFormat!\n    var analyzer: SNAudioStreamAnalyzer!\n    var resultsObserver = ResultsObserver()\n    let analysisQueue = DispatchQueue(label: \"dongdong\")\n<\/pre>\n\n\n\n<p>\u521d\u59cb\u5316\u51fd\u6570<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">init(){\n        \n        resultsObserver.delegate = self\n        inputFormat = audioEngine.inputNode.inputFormat(forBus: 0)\n        analyzer = SNAudioStreamAnalyzer(format: inputFormat)\n    }\n<\/pre>\n\n\n\n<p>\u542f\u52a8audio\u51fd\u6570<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">func startAudioEngine() {\n        do {\n            let request = try SNClassifySoundRequest(mlModel: soundClassifier.model)\n            try analyzer.add(request, withObserver: resultsObserver)\n        } catch {\n            print(\"Unable to prepare request: \\(error.localizedDescription)\")\n            return\n        }\n       \n        audioEngine.inputNode.installTap(onBus: 0, bufferSize: 8192, format: inputFormat) { buffer, time in\n                self.analysisQueue.async {\n                    self.analyzer.analyze(buffer, atAudioFramePosition: time.sampleTime)\n                }\n        }\n        \n        do{\n        try audioEngine.start()\n        }catch( _){\n            print(\"error in starting the Audio Engin\")\n        }\n    }\n<\/pre>\n\n\n\n<p>\u5b9a\u4e49procotol\u51fd\u6570\u5185\u5bb9<\/p>\n\n\n\n<p>\u6570\u636e\u4f20\u9012<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">func displayPredictionResult(identifier: String, confidence: Double) {\n        DispatchQueue.main.async {\n            \n        \/\/self.myMessage.message = (\"Recognition: \\(identifier)\\nConfidence \\(confidence)\")\n            self.myMessage.message = self.translateString(identifier: identifier)\n            \/\/print(self.myMessage.message)\n        }\n        \n        \n    }\n<\/pre>\n\n\n\n<p>\u56e0\u4e3a\u6a21\u5757\u8f93\u51fa\u7684\u5185\u5bb9\u6bd4\u8f83\u5355\u4e00\u4e14\u8bad\u7ec3\u7684\u65f6\u5019\u662f\u82f1\u6587\u5206\u7c7b\uff0c\u6240\u4ee5\u505a\u4e2a\u7b80\u5355\u7684\u5904\u7406<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">func translateString(identifier: String) -> String{\n        \n        switch identifier{\n        case \"male\":\n            return \"\u7537\u751f\u26f9\ufe0f\ud83d\udc71\ud83c\udffc\u200d\u2642\ufe0f\"\n        default:\n            return \"\u5973\u751f\ud83d\udc69\ud83c\udffb\u200d\ud83e\uddb3\ud83d\udc84\"\n        }\n    }\n<\/pre>\n\n\n\n<p>\u5728ContentView\u7684\u6240\u6709\u5b9a\u4e49\u4e4b\u5916\uff0c\u5b9a\u4e49\u7c7b\uff0c\u53c2\u8003\u82f9\u679c\u5b98\u7f51\u5bf9\u4e8esound\u4ecb\u7ecd<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2021\/10\/image-34.png\" alt=\"\" class=\"wp-image-3939\" width=\"374\" height=\"295\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-34.png 1018w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-34-300x237.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-34-768x607.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-34-830x656.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-34-230x182.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-34-350x276.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-34-480x379.png 480w\" sizes=\"(max-width: 374px) 100vw, 374px\" \/><\/figure><\/div>\n\n\n\n<p>class ResultsObserver: NSObject, SNResultsObserving {<br>var delegate: GenderClassifierDelegate?<br>func request(_ request: SNRequest, didProduce result: SNResult) {<br>guard let result = result as? SNClassificationResult,<br>let classification = result.classifications.first else { return }<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class ResultsObserver: NSObject, SNResultsObserving {\n    var delegate: GenderClassifierDelegate?\n    func request(_ request: SNRequest, didProduce result: SNResult) {\n        guard let result = result as? SNClassificationResult,\n            let classification = result.classifications.first else { return }\n        \n        \/\/ Determine the time of this result.\n        let formattedTime = String(format: \"%.2f\", result.timeRange.start.seconds)\n        print(\"Analysis result for audio at time: \\(formattedTime)\")\n        \n        let confidence = classification.confidence * 100.0\n        \n       \n            delegate?.displayPredictionResult(identifier: classification.identifier, confidence: confidence)\n        \n       \n        \/\/\u4f7f\u7528\u901a\u77e5\u4f20\u9012\u6570\u636e\uff0c\u4f46\u662f\u6570\u636e\u53ea\u80fd\u4e3a[Hasable:Any?]\u683c\u5f0f\n        \/\/\u5fc5\u987bDispathcqueue\n        DispatchQueue.main.async {\n            NotificationCenter.default.post(name: NSNotification.Name(\"ForMyTest\"), object: nil,userInfo: [\"\u6027\u522b\": classification.identifier,\"\u6982\u7387\":String(confidence)])\n        }\n    }\n}\n<\/pre>\n\n\n\n<p>\u4ee5\u4e0a\u4ee3\u7801\u57fa\u672c\u548c\u82f9\u679c\u5b98\u7f51\u4e00\u81f4\uff0c\u4e0d\u540c\u4e4b\u5904\u6709\u534f\u8bae\u65b9\u5f0f\u4f20\u9012\u6570\u636e<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">delegate?.displayPredictionResult(identifier: classification.identifier, confidence: confidence)\n<\/pre>\n\n\n\n<p>\u7136\u540e\u6d4b\u8bd5\u901a\u8fc7\u540c\u5fd7\u4f20\u9012\u6570\u636e\u7528\u4e8e\u6d4b\u8bd5\u5185\u5bb9<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">DispatchQueue.main.async {\n            NotificationCenter.default.post(name: NSNotification.Name(\"ForMyTest\"), object: nil,userInfo: [\"\u6027\u522b\": classification.identifier,\"\u6982\u7387\":String(confidence)])\n        }\n<\/pre>\n\n\n\n<p>\u7136\u540e\u52a0\u5165\u534f\u8bae\uff0c\u6240\u6709\u5185\u5bb9\u4e4b\u5916\u9762<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">protocol GenderClassifierDelegate {\n    func displayPredictionResult(identifier: String, confidence: Double)\n}\n<\/pre>\n\n\n\n<p>\u7ec8\u4e8e\u8fdb\u5165body\u90e8\u5206<br>\u7b80\u5355\u7684\u4ee3\u7801\uff0c\u89c1\u6ce8\u91ca<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">var body: some View {\n        Text(myMessage.message)\n            .onAppear{\n                self.startAudioEngine()\n        }\n        .onTapGesture {\n            self.message = \"what\"\n        }\n            \/\/\u6b64\u5904\u63a5\u53d7\u901a\u77e5\uff0c\u5904\u7406\u6570\u636e\uff0c\u6b64\u65f6@state message\u4e5f\u80fd\u66f4\u6539\u4e86\n            \/\/\u5f53\u6709\u901a\u77e5\u5185\u5bb9\u4f20\u9012\u8fc7\u6765\u540e\uff0c\u5904\u7406\u7c7b\u5bb9\uff0c\u6253\u5370\u51fa\u7ed3\u679c.\n        .onReceive(NotificationCenter.default.publisher(for: Notification.Name(\"ForMyTest\"))){\n            label in\n            \/\/print(label)\n            if let new = label.userInfo as? [String:String]\n            {\n                self.message = new[\"\u6027\u522b\"]!\n                print(self.message)\n                \n            }\n        }\n    }\n<\/pre>\n\n\n\n<p>\u901a\u77e5\u4f20\u9012\u6570\u636e\u65b9\u5f0f\u76f8\u5bf9\u6b65\u9aa4\u5c11\u4e00\u4e9b\uff0c\u6b64\u5904\u6ca1\u6709\u73b0\u5b9e\u51fa\u6765\uff0c\u53ea\u662f\u6253\u5370\u4e86\u4e00\u4e0b\uff0c\u4e0eprotocol\u65b9\u5f0f\u7ed3\u679c\u5b8c\u5168\u4e00\u81f4\uff0c\u65e0\u95ee\u9898\uff0c\u53ef\u53c2\u8003\u5907\u7528.<br>\u7136\u540e\u8fd0\u884c\u7a0b\u5e8f\uff0c\u7136\u540e\u7a0b\u5e8f\u5c31\u6302\u4e86<br>\u56e0\u4e3a\u8fd8\u6ca1\u6709\u5f00\u9ea6\u514b\u98ce\u6743\u9650\uff0c\u5982\u56fe\uff0cinfo.list\u4e2d<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2021\/10\/image-35-1024x64.png\" alt=\"\" class=\"wp-image-3940\" width=\"748\" height=\"46\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-35-1024x64.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-35-300x19.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-35-768x48.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-35-1536x95.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-35-830x51.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-35-230x14.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-35-350x22.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-35-480x30.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-35.png 1612w\" sizes=\"(max-width: 748px) 100vw, 748px\" \/><\/figure><\/div>\n\n\n\n<p>\u7136\u540e\u518d\u8fd0\u884c<br>\u8bc6\u522b\u51fa\u58f0\u97f3\u7c7b\u578b<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2021\/10\/image-36.png\" alt=\"\" class=\"wp-image-3941\" width=\"301\" height=\"546\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-36.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-36-166x300.png 166w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-36-230x417.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-36-350x634.png 350w\" sizes=\"(max-width: 301px) 100vw, 301px\" \/><\/figure><\/div>\n\n\n\n<p>\u975e\u5e38\u7b80\u5355\u7684\u4f7f\u7528\u5230\u4e86ML\u7684\u5c0f\u7a0b\u5e8f\uff0c\u82f9\u679c\u81ea\u5e26\u7684CreateML\u529f\u80fd\u8fd8\u662f\u5f88\u5f3a\u5927\u7684\uff0c\u652f\u6301\u5f88\u591a\u7c7b\u578b\uff0c\u5982<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2021\/10\/image-37-895x1024.png\" alt=\"\" class=\"wp-image-3942\" width=\"582\" height=\"666\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-37-895x1024.png 895w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-37-262x300.png 262w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-37-768x879.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-37-830x950.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-37-230x263.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-37-350x401.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-37-480x549.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/10\/image-37.png 970w\" sizes=\"(max-width: 582px) 100vw, 582px\" \/><\/figure><\/div>\n\n\n\n<p>\u4f46\u662f\u5728\u8bad\u7ec3\u6a21\u5757\u65f6\uff0c\u771f\u6b63\u6df1\u5165ML\u65f6\uff0cCreateML\u5219\u611f\u89c9\u529f\u80fd\u6709\u4e9b\u4e0d\u591f\u4e86\uff0c\u8fd9\u65f6\u5019\u8fd8\u662f\u7684\u7528Python\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>SwiftUI\u4e4b\u58f0\u97f3\u8bc6\u522b\u914d\u5408MachineLearning\u529f\u80fd\uff0c\u5224\u65ad\u8bf4\u8bdd\u7684\u4eba\u662f\u7537\u6027\u8fd8\u662f\u5973\u6027\u3002\u9700\u8981\u5b9e\u73b0\u8fd9\u4e2a\u529f\u80fd\uff0c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,5],"tags":[],"_links":{"self":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/3929"}],"collection":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3929"}],"version-history":[{"count":2,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/3929\/revisions"}],"predecessor-version":[{"id":3943,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/3929\/revisions\/3943"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3929"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3929"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3929"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}