Speech Recognizer in Delphi Firemonkey Mobile APP (Speech to Text)

  

I am creating test android mobile application using with Firemonkey mobile in “Delphi XE6”.

I have downloaded sample application from “embarcadero site”.
I am getting access violation when going to create :

SpeechRecognizer := TJSpeechRecognizer.JavaClass.createSpeechRecognizer(SharedActivityContext);

Access Violation : “java.lang.runtimeexception speech recognizer should be used only from the application’s main thread”

How I handled this access volition in Delphi for my APP.

Below is Button Click function:

procedure TForm1.Button3Click(Sender: TObject);
var
b : Boolean;

begin
b := TJSpeechRecognizer.JavaClass.isRecognitionAvailable(SharedActivityContext);
if b then
begin
SpeechRecognizer := TJSpeechRecognizer.JavaClass.createSpeechRecognizer(SharedActivityContext);
RecListener := TRecognitionListener.Create(self);
RecognizerIntent := TJRecognizerIntent.JavaClass.getVoiceDetailsIntent(SharedActivityContext);
RecognizerIntent.putExtra(TJRecognizerIntent.JavaClass.EXTRA_LANGUAGE_MODEL, StringToJString(‘en-US’));
SpeechRecognizer.setRecognitionListener(RecListener);
Button3.Enabled := false;
Button4.Enabled := true;
end;

Please help me in this case.
Thanks

Comments are closed.