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

[Speech to text] Keep alive fails to keep service running

Open Naphier opened this issue 8 years ago • 24 comments

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.

Naphier avatar Feb 22 '18 15:02 Naphier

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.

mediumTaj avatar Feb 22 '18 16:02 mediumTaj

Hello, I also have similar error, but in string [SpeechToText.OnListenClosed()][DEBUG] OnListenClosed(), State = DISCONNECTED Can you help?

Olegjan avatar Mar 02 '18 16:03 Olegjan

@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

mediumTaj avatar Mar 02 '18 17:03 mediumTaj

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.

cjloh avatar Mar 22 '18 11:03 cjloh

@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.

screen shot 2018-07-24 at 8 55 31 am

erics1033 avatar Jul 24 '18 13:07 erics1033

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

mediumTaj avatar Jul 24 '18 15:07 mediumTaj

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 .

erics1033 avatar Jul 24 '18 21:07 erics1033

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?

HjoshM avatar Dec 23 '18 14:12 HjoshM

@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.

image

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 avatar Jan 14 '19 09:01 cocapasteque

@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 avatar Jan 14 '19 15:01 mediumTaj

@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

cocapasteque avatar Jan 14 '19 16:01 cocapasteque

@mediumTaj Created a new resource located in Washington DC, still not working. I'm going to try with a older unity version.

cocapasteque avatar Jan 14 '19 16:01 cocapasteque

@mediumTaj Working with 2018.2.0f2, didn't worked with 2018.3.0f2. I really have no idea why.

cocapasteque avatar Jan 14 '19 16:01 cocapasteque

@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 !

cocapasteque avatar Jan 14 '19 16:01 cocapasteque

Hmm ok. I’ll add to the readme. I’m glad you got it working!

mediumTaj avatar Jan 14 '19 17:01 mediumTaj

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 avatar Oct 21 '19 14:10 samuelthomson

@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;

mediumTaj avatar Oct 21 '19 14:10 mediumTaj

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?

samuelthomson avatar Oct 21 '19 15:10 samuelthomson

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?

samuelthomson avatar Oct 21 '19 15:10 samuelthomson

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;

mediumTaj avatar Oct 21 '19 16:10 mediumTaj