unity-sdk icon indicating copy to clipboard operation
unity-sdk copied to clipboard

[Android] Speech-To-Text sometimes not work

Open jacktsai526 opened this issue 8 years ago • 8 comments

I am building an android app with the latest Watson-Unity-sdk's Speech-To-Text via Unity. However, it sometimes work and sometimes not. After I dig into the log, it sometimes shows:

[SpeechToText.OnListen()][ERROR] Failed to enter listening state. and [WSConnector][ERROR] Caught WebSocket exception: System.InvalidOperationException: The current state of the connection is not Open.

and sometimes even there is no message sent back but not work either. So I guess the config is not loaded successfully before I call service?

In my project, I do this first: Credentials credentials = new Credentials(_username, _password, _url); _speechToText = new SpeechToText(credentials); Active = true;

then after that, system will call StartRecording() and StopRecording().

I checked some old discussion and also add one line to wait one sec right before SpeechToText(credentials), but did not solve the problem.

How can I solve this situation? or is there anyway I could make sure config is loaded before calling the service?

Thanks!!

jacktsai526 avatar Mar 23 '18 20:03 jacktsai526

Is there a sample project or code you can share? I just published on Android and everything seems to be working as expected.

mediumTaj avatar Mar 23 '18 21:03 mediumTaj

Please reopen this if you are still having issues.

mediumTaj avatar Apr 06 '18 16:04 mediumTaj

I seem to be getting the same problem. Seems to happen about one time in thirty with no particular pattern, So might be a timing issue as suggested above. I do not get the WSConnector error. Requesting reopen bug.

[02/20/2019 22:16:44][SpeechToText.OnListen()][ERROR] Failed to enter listening state.
UnityEngine.Debug:LogError(Object)
IBM.Watson.DeveloperCloud.Debug.DebugReactor:ProcessLog(LogRecord) (at Assets/Watson/Scripts/Debug/DebugReactor.cs:60)
IBM.Watson.DeveloperCloud.Logging.LogSystem:ProcessLog(LogRecord) (at Assets/Watson/Scripts/Logging/Logger.cs:206)
IBM.Watson.DeveloperCloud.Logging.Log:Error(String, String, Object[]) (at Assets/Watson/Scripts/Logging/Logger.cs:279)
IBM.Watson.DeveloperCloud.Services.SpeechToText.v1.SpeechToText:OnListen(AudioData) (at Assets/Watson/Scripts/Services/SpeechToText/v1/SpeechToText.cs:692)
<RecordingHandler>d__22:MoveNext() (at Assets/NewBasicAudioFunc/WatsonStreaming.cs:188)
IBM.Watson.DeveloperCloud.Utilities.Routine:MoveNext() (at Assets/Watson/Scripts/Utilities/Runnable.cs:131)
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

McGake avatar Feb 20 '19 22:02 McGake

Can you post a sample project or code where I can reproduce the error? I will reopen if you can post some code. I just tried Speech to Text on Android today (for https://github.com/watson-developer-cloud/unity-sdk/issues/515) and everything works fine. How long is the socket open before the error?

mediumTaj avatar Feb 20 '19 22:02 mediumTaj

[02/20/2019 22:16:33][SpeechToText.CreateListenConnector()][DEBUG] Created listen socket. Model: en-US_BroadbandModel, parsedParams: 
UnityEngine.Debug:Log(Object)

If the above represents opening the socket (i don't know much about this) then it looks like it is open for eleven seconds before the error in this particular case. I am basically using a modified version of your example code to trigger recording. But I trigger it in various ways. It would be ugly to post the entire project, so I will try to see if I can narrow it down to something that will reproduce the error regularly. This may take me a couple days.

McGake avatar Feb 20 '19 23:02 McGake

Do you get the error with the unmodified ExampleStreaming scene?

mediumTaj avatar Feb 21 '19 01:02 mediumTaj

Unfortunately, I have run into a different problem that is keeping me from even testing the unmodified ExampleStreaming scene. Sorry about that. If I am ever able to reproduce the issue I will update.

McGake avatar Mar 05 '19 02:03 McGake

I solved Error

I encounter the same issue with Unity 2018.3.14f1. I just change player settings and then works fine file -> build settings - > player settings -> Other Settings Configuration

  • Scripting runtime version : .Net 4x equivalent
  • API Compatibility level: .Net 4x

update

Code-Console avatar Feb 18 '20 15:02 Code-Console