Browse Source

判断语音权限

刘亚军 1 year ago
parent
commit
78d9b70e8f
1 changed files with 5 additions and 0 deletions
  1. 5 0
      CampusAssistant/MainController.swift

+ 5 - 0
CampusAssistant/MainController.swift

@@ -239,6 +239,11 @@ class MainController: UIViewController,WKUIDelegate, WKNavigationDelegate, WKScr
     
     //开启语音识别
     @objc func startSpeechMark() {
+        if (!YJSpeechManager.default().microphoneAuthorization()){
+            LGAlertHUD.shareInstance().showInfo(withStatus: "麦克风权限未打开")
+            return
+        }
+        self.webView.evaluateJavaScript("startRecognitionAnima()")
         YJSpeechManager.default().startEngine(atRefText: nil, markType: .chineseASR, symbol: true)
         YJSpeechManager.default().speechEngineResult { resultModel in
             if (resultModel!.isError){