NRSpeechToText
介绍
NRSpeechToText:此库提供语音到文本功能,通过 iOS 语音框架实现。
示例
要运行示例项目,首先克隆仓库,然后从 Example 目录运行 pod install
。
需求
Xcode 9+,Swift 4,iOS 9及更高版本
Plist 密钥 & 背景模式
在使用语音服务之前,请确保您在 plist 文件中有以下密钥。
<key>Privacy - Microphone Usage Description</key>
<string>We will use this microphone for testing our demo.</string>
<key>Privacy - Speech Recognition Usage Description</key>
<string>We will speech recognition for testing demo</string>
安装
NRSpeechToText通过CocoaPods提供。要安装它,只需在Podfile中添加以下行
pod "NRSpeechToText"
用法
@IBAction func microphoneButtonPressed(_ sender: AnyObject) {
NRSpeechToText.shared.authorizePermission { (authorize) in
if authorize {
if NRSpeechToText.shared.isRunning {
NRSpeechToText.shared.stop()
OperationQueue.main.addOperation {
self.microphoneButton.setTitle("Start Recording", for: .normal)
}
}
else {
OperationQueue.main.addOperation {
self.microphoneButton.setTitle("Stop Recording", for: .normal)
}
self.startRecording()
}
}
}
}
func startRecording() {
NRSpeechToText.shared.startRecording {(result: String?, isFinal: Bool, error: Error?) in
if error == nil {
self.textView.text = result
}
}
}
贡献
欢迎贡献!(
- 将其分叉( http://github.com/naveenrana1309/NRSpeechToText/fork )
- 创建特征分支 ('git checkout -b my-new-feature')
- 提交您的更改 ('git commit -am '添加一些功能')
- 将更改推送到分支 ('git push origin my-new-feature')
- 创建新的拉取请求
兼容性
Xcode 9+ , Swift 4 , iOS 10及以上
作者
Naveen Rana。 查看个人资料
Email: [email protected]。
查看Facebook个人资料获取详细信息。
许可
NRSpeechToText 遵循 MIT 许可发布。详情请见 LICENSE 文件。