VidyasagarMSC / WatBot

An Android ChatBot powered by IBM Watson Services (Assistant V1, Text-to-Speech, and Speech-to-Text with Speaker Recognition) on IBM Cloud.
Other
72 stars 53 forks source link

app closed when I pressed mic button #3

Closed chamif1974 closed 7 years ago

chamif1974 commented 7 years ago

E/AudioRecord: Could not get audio input for session 81, record source 1, sample rate 16000, format 0x1, channel mask 0x10, flags 0 E/AudioRecord-JNI: Error creating AudioRecord instance: initialization check failed with status -22. E/android.media.AudioRecord: Error code -20 when initializing native AudioRecord object.

                         --------- beginning of crash

E/AndroidRuntime: FATAL EXCEPTION: Thread-5 Process: com.example.vmac.chatbot, PID: 2468 java.lang.IllegalStateException: startRecording() called on an uninitialized AudioRecord. at android.media.AudioRecord.startRecording(AudioRecord.java:976) at com.ibm.watson.developer_cloud.android.library.audio.MicrophoneCaptureThread.run(MicrophoneCaptureThread.java:63) W/System.err: java.lang.RuntimeException: Session timed out, no data received in the last 30 seconds. W/System.err: at com.ibm.watson.developer_cloud.speech_to_text.v1.websocket.WebSocketManager$SpeechToTextWebSocketListener.onMessage(WebSocketManager.java:140) W/System.err: at okhttp3.internal.ws.RealWebSocket$1.onMessage(RealWebSocket.java:62) W/System.err: at okhttp3.internal.ws.WebSocketReader.readMessageFrame(WebSocketReader.java:242) W/System.err: at okhttp3.internal.ws.WebSocketReader.processNextFrame(WebSocketReader.java:108) W/System.err: at okhttp3.internal.ws.RealWebSocket.readMessage(RealWebSocket.java:97) W/System.err: at okhttp3.ws.WebSocketCall.createWebSocket(WebSocketCall.java:152) W/System.err: at okhttp3.ws.WebSocketCall.access$000(WebSocketCall.java:41) W/System.err: at okhttp3.ws.WebSocketCall$1.onResponse(WebSocketCall.java:97) W/System.err: at okhttp3.RealCall$AsyncCall.execute(RealCall.java:126) W/System.err: at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32) W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) W/System.err: at java.lang.Thread.run(Thread.java:761)

VidyasagarMSC commented 7 years ago

The issue was with different devices supporting different sampling rates. Its fixed and verified. Please pull the latest code and check.

chamif1974 commented 7 years ago

I verified in the my phone and it's working. But we need to click > to submit the voice text right. can we make it auto submit after 5 secs

When I verified with simulator (Nexus 5 API 25 - android 7.1.1 x86_64 apilevel=25 ) it's still crashed the app I/art: Background partial concurrent mark sweep GC freed 14581(2MB) AllocSpace objects, 27(612KB) LOS objects, 38% free, 6MB/10MB, paused 7ms total 197.427ms I/CredentialUtils: JNDI string lookups is not available. E/AudioRecord: Could not get audio input for session 25, record source 1, sample rate 16000, format 0x1, channel mask 0x10, flags 0 E/AudioRecord-JNI: Error creating AudioRecord instance: initialization check failed with status -22. E/android.media.AudioRecord: Error code -20 when initializing native AudioRecord object.

                         --------- beginning of crash

E/AndroidRuntime: FATAL EXCEPTION: Thread-5 Process: com.example.vmac.chatbot, PID: 2675 java.lang.IllegalStateException: startRecording() called on an uninitialized AudioRecord. at android.media.AudioRecord.startRecording(AudioRecord.java:976) at com.ibm.watson.developer_cloud.android.library.audio.MicrophoneCaptureThread.run(MicrophoneCaptureThread.java:63)

VidyasagarMSC commented 7 years ago

Also, Check permission in android manifest.