Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FATAL EXCEPTION: AudioToWebSocketThread #94

Open
ZY6666 opened this issue Sep 16, 2020 · 1 comment
Open

FATAL EXCEPTION: AudioToWebSocketThread #94

ZY6666 opened this issue Sep 16, 2020 · 1 comment

Comments

@ZY6666
Copy link

ZY6666 commented Sep 16, 2020

Sorry for my poor English, I will make it simple
I successfully ran the example,But when I set inactivityTimeout to 1 second, I want to automatically end the connection or catch error code, but the application crashes
heres the code:

private RecognizeOptions getRecognizeOptions(InputStream captureStream) {
    return new RecognizeOptions.Builder()
            .audio(captureStream)
            .contentType(ContentType.OPUS.toString())
            .model("ja-JP_BroadbandModel")
            .interimResults(true)
            .inactivityTimeout(1)
            .build();
  }

and crash log:

E/AndroidRuntime: FATAL EXCEPTION: AudioToWebSocketThread
    Process: com.ibm.watson.developer_cloud.android.myapplication, PID: 3228
    java.lang.IllegalMonitorStateException
        at java.util.concurrent.locks.ReentrantLock$Sync.tryRelease(ReentrantLock.java:156)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer.release(AbstractQueuedSynchronizer.java:1291)
        at java.util.concurrent.locks.ReentrantLock.unlock(ReentrantLock.java:466)
        at com.ibm.watson.developer_cloud.android.library.audio.MicrophoneCaptureThread.end(MicrophoneCaptureThread.java:138)
        at com.ibm.watson.developer_cloud.android.library.audio.MicrophoneInputStream.close(MicrophoneInputStream.java:109)
        at com.ibm.watson.speech_to_text.v1.websocket.SpeechToTextWebSocketListener.sendInputStream(SpeechToTextWebSocketListener.java:213)
        at com.ibm.watson.speech_to_text.v1.websocket.SpeechToTextWebSocketListener.access$100(SpeechToTextWebSocketListener.java:42)
        at com.ibm.watson.speech_to_text.v1.websocket.SpeechToTextWebSocketListener$1.run(SpeechToTextWebSocketListener.java:168)

Crash code:
MicrophoneCaptureThread

public void end() {
    stop = true;

    if (!stopped) {
      try {
        running.tryLock(10, TimeUnit.SECONDS);
      } catch (InterruptedException e) {
        Log.e(TAG, e.getMessage());
      } finally {
        running.unlock();
      }
    }
  }

MicrophoneInputStream

@Override
  public void close() throws IOException {
    captureThread.end();
    os.close();
    is.close();
  }

Please help me,thank you very much

@kevinkowa
Copy link
Contributor

Try it out with the latest version of the SDK and let me know if it's working fine on your end!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants