[Speech to text] Keep alive fails to keep service running
Unity 2017.3.1f1 Watson Unity SDK 2.0.0 Windows 10 64-bit pro - Unity Editor
Unity Watson SDK - ExampleStreaming scene (no modifications to code)
Expected: Session doesn't timeout and remains alive.
Actual: After about 1 minute Session Timeout error occurs. "Sending keep alive" console messages appear, but doesn't seem to help.
Editor log attached. Editor.log
Current workaround: I'm just using a coroutine to wait half a second and then restart the service. Not really ideal as there will be periods when the service is off.
Can you see if setting DetectSilence to false helps?
https://github.com/watson-developer-cloud/unity-sdk/blob/develop/Examples/ServiceExamples/Scripts/ExampleStreaming.cs#L63
Trying to narrow down this issue.
Lowering the SilenceThreshold in the same block to 0.001f may also work.
Hello, I also have similar error, but in string [SpeechToText.OnListenClosed()][DEBUG] OnListenClosed(), State = DISCONNECTED Can you help?
@Olegjan This is a different issue. Services just switched from TLS 1.0 to TLS 1.2 and the ws library is not liking it. see this issue https://github.com/watson-developer-cloud/unity-sdk/issues/330
A hotfix for this will be out soon
hi, is there any other way to keep the session alive with DetectSilence set to true? currently i set InactivityTimeout = -1 and every 20 seconds i will send "highHat" clip with OnListen method and yet i couldn't keep the session alive.
@mediumTaj Was wondering what you would recommend to solve this issue? (error CS0117: System.Security.Authentication.SslProtocols' does not contain a definition for Tls12') If I get rid of the line with Tls12, I end up having the same issue as @Olegjan . Any help would be greatly appreciated.

If using Unity 2018.2 or later you'll need to set Scripting Runtime Version in Build Settings to .NET 4.x equivalent. We need to access security options to enable TLS 1.2.
https://github.com/watson-developer-cloud/unity-sdk#configuring-unity
Thanks got it working!
On Tue, Jul 24, 2018 at 10:18 AM Ajiemar Santiago [email protected] wrote:
If using Unity 2018.2 or later you'll need to set Scripting Runtime Version in Build Settings to .NET 4.x equivalent. We need to access security options to enable TLS 1.2.
https://github.com/watson-developer-cloud/unity-sdk#configuring-unity
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/watson-developer-cloud/unity-sdk/issues/325#issuecomment-407444775, or mute the thread https://github.com/notifications/unsubscribe-auth/AaDk8r5zZN_yKfEZ4KmUZw0VN1sG7gaRks5uJzq7gaJpZM4SPjGn .
My Scripting Runtime Version in Build Settings is already set to .NET 4.x but I still get this error message... What am I missing?
@mediumTaj Same here, using Unity 2018.3.0f2. Can't get the samples to work.
[01/14/2019 09:10:39][SpeechToText.CreateListenConnector()][DEBUG] Created listen socket. Model: en-US_BroadbandModel, parsedParams:
[01/14/2019 09:10:39][ExampleStreaming.RecordingHandler()][DEBUG] devices: Microphone (Realtek Audio)
[01/14/2019 09:10:40][SpeechToText.SendStart()][DEBUG] SendStart() with the following params: {"action":"start","content-type":"audio/l16;rate=22050;channels=1;","inactivity_timeout":-1,"interim_results":true,"max_alternatives":0,"profanity_filter":false,"smart_formatting":true,"speaker_labels":false,"timestamps":true,"word_confidence":true}
[01/14/2019 09:10:41][SpeechToText.OnListenClosed()][DEBUG] OnListenClosed(), State = DISCONNECTED
[01/14/2019 09:10:41][SpeechToText.KeepAlive()][DEBUG] KeepAlive exited.

I used both https://stream-tls10.watsonplatform.net/speech-to-text/api and https://gateway-lon.watsonplatform.net/speech-to-text/api URLs but it didn't work..
Is this unity-sdk is still maintained ?
@cocapasteque Yes the sdk is still maintained. London endpoint is relatively new. I've had users successfully access it even though we are not explicitly handling it in the SDK. I will patch that up this week though. Are you using .NET 4.x Scripting Runtime?
https://github.com/watson-developer-cloud/unity-sdk#configuring-unity
You can also join our #unity-sdk slack channel in wdc-community: http://wdc-slack-inviter.mybluemix.net/
@mediumTaj Yes of course I'm using .NET 4.x. Should I use a different endpoint and test with this ?
Gonna join on slack also :) Thanks for your answer
@mediumTaj Created a new resource located in Washington DC, still not working. I'm going to try with a older unity version.
@mediumTaj Working with 2018.2.0f2, didn't worked with 2018.3.0f2. I really have no idea why.
@mediumTaj Last message in this thread for me, found why it wasn't working... Scripting Runtime was set on .NET 4.x but the Api Compatibility Level was on .NET Standard 2.0, switched it to 4.x and it worked.
You should at this somewhere in your documentation, not only the Scripting runtime should be on .NET 4.x but also the API Compatibility Level. :) Thank you !
Hmm ok. I’ll add to the readme. I’m glad you got it working!
Hello, I'm getting the same error message (KeepAlive exited). But I'm using Unity 2019.2.1 and the option "Scripting Runtime Version" options are no longer available. Instead I set Api Compatibility to .Net 4.x, and I set "Scripting Backend" to IL2CPP. However, I'm still getting the same error message.
Is there anything else to try?
@samuelthomson Can you try the branch in this PR? https://github.com/watson-developer-cloud/unity-sdk/pull/602
The important part being yielding for the keepAlive audio to load
AudioClip _keepAliveClip = Resources.Load<AudioClip>("highHat");
while (_keepAliveClip.loadState != AudioDataLoadState.Loaded)
yield return null;
I'm not a regular Github user, can you tell me how I can do that? I'm not sure how to integrate anything from that page into my project. Is there a quick explanation?
Well, I manually added the line recommended here: "https://github.com/watson-developer-cloud/unity-sdk/issues/601" to ExampleStreaming.cs and it now seems to be working. Where would you add the code you quoted, and what would that add?
Search for the following line in Scripts/Services/SpeechToText/V1/SpeechToTextServiceExtension.cs
AudioClip _keepAliveClip = Resources.Load<AudioClip>("highHat");
Add these two lines below that line
while (_keepAliveClip.loadState != AudioDataLoadState.Loaded)
yield return null;