# 語音辨識修正 (GoogleSpeechRecognizer.cs) ## 老樣子,又是路徑問題 在 ```csharp=107 string credentialsPath = Path.Combine(Application.streamingAssetsPath, CredentialFileName); // 這是原本的 GCP 憑證位置 ``` 添加 ```csharp=109 #if UNITY_ANDROID // 因為 Android 不能直接讀 StreamingAssets,所以我們要搬它 var unityWebRequest = UnityEngine.Networking.UnityWebRequest.Get(credentialsPath); unityWebRequest.SendWebRequest(); while (!unityWebRequest.isDone) { } credentialsPath = Path.Combine(Application.persistentDataPath, CredentialFileName); // 常識改變活動紀錄 File.WriteAllText(credentialsPath, unityWebRequest.downloadHandler.text); #endif ``` ## 辨識時間太長它會罷工 雖然正確的解法是有需要辨識的時候再開它, 但我們的超爛解法是不定時去開關它就好了 ```cs=146 StartCoroutine(PeriodlyRestart()); } /// <summary> /// BADBADBADBAD /// </summary> IEnumerator PeriodlyRestart() { while (true) { yield return new WaitForSeconds(30f); print("[StreamingRecognizer] Restarting"); Restart(); } } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up