DeeptoneSDK 1.4.5

DeeptoneSDK 1.4.5

OTO Systems 维护。



 
依赖
TensorFlowLiteSwift= 2.4.0
CryptoSwift= 1.4.0
SSZipArchive= 2.2.3
Alamofire= 5.4.4
SwiftyJSON= 5.0.1
SwiftJWT= 3.5.3
RealmSwift= 5.5.1
 

  • 作者:
  • OTO Systems

要求入门安装API 参考

要求

  • iOS 11.0+
  • Xcode 13.1
  • Swift 5.5

入门

首先导入 DeeptoneSDK

import DeeptoneSDK
let KEY = "YOUR_LICENSE_KEY"
let filePath = Bundle.main.path(forResource: "YourModel", ofType: "model")
let deeptone = Deeptone(key: KEY, modelPath: filePath!)

deeptone.start() { result in
    switch (result) {
    case Result.Success:
        print("SDK is ready!")
    case Result.Failure(let error):
        print("Something went wrong! Error: ", error)
    }
}

...
// Get predictions from file
let audioFile = Bundle.main.path(forResource: "YourAudioFile", ofType: ".m4a")
let data: DeeptoneOutput = try! deeptone.loadAudioFile(filePath: audioFile!)


// Get predictions from the microphone
var deeptoneStream: DeeptoneStream?
...
func startRecording() {
        deeptoneStream = self.deeptone.stream(
                onData: { (data: DeeptoneOutput) in
                    // Handle data over time
                },
                onSuccess: { (data: DeeptoneOutput) in
                    // Handle data at the end of the stream
                },
                onError: { (error: DeeptoneSDKError) in
                    //  Handle errors
                })

        let input = self.audioEngine.inputNode
        let format = input.inputFormat(forBus: 0)

        input.installTap(onBus: 0, bufferSize: 8192, format: format, block: { (buf, when) in
            self.deeptoneStream?.write(audioBuffer: buf)
        })

        self.audioEngine.prepare()
        do {
            try self.audioEngine.start()
        } catch {
            debugPrint("BOOM!")
        }
    }

    func stopRecording () {
        guard let deeptoneStream = self.deeptoneStream else {
            return
        }

        deeptoneStream.close()
        self.audioEngine.inputNode.removeTap(onBus: 0)
        self.audioEngine.stop()
        self.audioEngine.reset()
    }
...

API 参考

请参阅 文档 获取关于类型的更多信息。

安装

在项目中使用 DeeptoneSDK 的推荐方法是使用 CocoaPods 包管理器,因为它提供灵活的依赖管理以及简单易用的安装过程。

CocoaPods

如果没有安装,请安装CocoaPods

$ [sudo] gem install cocoapods
$ pod setup

进入你的Xcode项目目录,创建和编辑你的Podfile,并添加DeeptoneSDK

$ cd /path/to/MyProject
$ pod init
$ edit Podfile
# Uncomment the next line to define a global platform for your project
# platform :ios, '11.0'

target 'MyProject' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for MyProject
  pod 'DeeptoneSDK', '~> 1.4.4'
end

将DeeptoneSDK安装到你的项目中

$ pod install

如果CocoaPods没有找到DeeptoneSDK的任何依赖,请执行以下命令

$ pod repo update

从.xcworkspace文件(而不是常见的项目文件)打开你的Xcode项目

$ open MyProject.xcworkspace

打开源代码和许可证