Very recent problem with STT in Java

I am working on a Java application which includes speech to text recognition technology based on Google Cloud API, already set up to interact with the user in 5 languages (en-GB, it-IT, de-DE, fi-FI, fr-FR).

It has worked well for more than a year, but for the past few days only English, German and Finnish have been working, while Italian and French no longer work. Specifically, the onResponse(…) method is invoked and "StreamingRecognitionResult result" contains correct data, but result.getIsFinal() never returns true for it-IT and fr-FR languages. In the other three languages getIsFinal() works correctly.

private class SpeechRecognitionTask extends SwingWorker<Void, Void> {
	private ResponseObserver<StreamingRecognizeResponse> responseObserver = null;
	
	@Override
	protected Void doInBackground() throws Exception {
		//...
		if(isListening && !exit) {
			//...
			ArrayList<StreamingRecognizeResponse> responses = new ArrayList<>();

			try (SpeechClient client = SpeechClient.create()) {
				responseObserver = new ResponseObserver<StreamingRecognizeResponse>() {

				ArrayList<StreamingRecognizeResponse> responses = new ArrayList<>();
				
					public void onResponse(StreamingRecognizeResponse response) {
						if(!isListening)
							   System.out.println("Waiting ...");
							
						else {
							responses.add(response);
							StreamingRecognitionResult result = response.getResultsList().get(0);

							if (result.getIsFinal()) {																//in it-IT and fr-FR getIsFinal never returns true
								SpeechRecognitionAlternative alternative = result.getAlternativesList().get(0);
								String str =  alternative.getTranscript().trim();
								System.out.println("Someone said: " + str); 

								try { 
									listenAndAnswer(str);

								} catch (Exception e) {
									e.printStackTrace();
								}	
							}
						}
					}
				}
				//...
			}
			//...	
		}	
		//...
	}
	//...
}

Thank you very much for your attention.

1 Like

While waiting for a solution, which so far I have not found and which no one has suggested to me, I use a trick to communicate in Italian and French: by replacing it-IT with it-CH and fr-FR with fr-CH, everything starts working again. Thank goodness for Switzerland :slightly_smiling_face: