-
Notifications
You must be signed in to change notification settings - Fork 94
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
The socket was disconnected for network reasons #68
Comments
Re-run the method that calls |
Only callback 'onError' after network disconnect |
Could you post some code to help understand your question better? |
IamOptions iamOptions = new IamOptions.Builder()
.apiKey("***")
.build();
service = new SpeechToText(iamOptions);
service.setEndPoint("https://gateway-tok.watsonplatform.net/speech-to-text/api");
microphoneHelper = new MicrophoneHelper(getActivity());
MicrophoneInputStream m = microphoneHelper.getInputStream(false);
RecognizeOptions options = new RecognizeOptions.Builder()
.audio(m)
.contentType(ContentType.RAW.toString())
.timestamps(true)
.wordConfidence(true)
//.profanityFilter(true)
.model("ar-AR_BroadbandModel")
.interimResults(true)
.inactivityTimeout(5000)
.build();
m.setOnAmplitudeListener(new AmplitudeListener() {
@Override
public void onSample(double amplitude, double volume) {
Log.e("TalkFragment","(:160)"+volume);
volumeBar.setProgress((int)volume);
}
});
service.recognizeUsingWebSocket(options ,new BaseRecognizeCallback(){
@Override
public void onTranscription(SpeechRecognitionResults speechResults) {
Log.e("TalkFragment","(:173)"+"==========="+speechResults);
if(!isFinish) return;
SpeechRecognitionResult speechRecognitionResult = speechResults.getResults().get(0);
if(speechRecognitionResult.isFinalResults()){
List<SpeechRecognitionAlternative> alternatives = speechRecognitionResult.getAlternatives();
isFinish = false;
e.onNext(alternatives.get(0).getTranscript());
}
}
@Override
public void onConnected() {
Log.e("Main3","(:73)"+"onConnected");
}
@Override
public void onError(Exception x) {
Log.e("TalkFragment","(:200)"+x.getMessage());
}
@Override
public void onListening() {
Log.e("Main3","(:83)"+"onListening");
}
@Override
public void onDisconnected() {
Log.e("TalkFragment","(:212)"+"onDisconnected");
}
}); ——————————————————————————————————————————————— When I turn off wifi, there is only onError callback. How should I reconnect now |
If you get an error, log that error using @Override
public void onError(Exception x) {
Log.e("Error recognizing audio","(:200)"+x.getMessage());
startRecognition();
} Where public void startRecognition() {
service.recognizeUsingWebSocket(options, this);
} Something like that. |
Session closed. Reason: Payload exceeds the 104857600 bytes limit. Can I continue to call the service. RecognizeUsingWebSocket (options, this); |
You can't send more than 100mb to the service. See https://console.bluemix.net/docs/services/speech-to-text/websockets.html#WSaudio |
|
The release version does not recognize speech but the debug version does |
If the socket is disconnected, what should I do to restart correctly
The text was updated successfully, but these errors were encountered: