1

I find a trip "Android Text To Speech JNI Translation" in forum. But i want to convert Speech to Text, same as "Voice Recognize" . And then i have a few code below:

{ TForm1.TRecognitionListener }

 constructor TForm1.TRecognitionListener.Create(AParent: TForm1);
  begin
    inherited Create;
    FParent := AParent;
  end;
 procedure TForm1.ButtonInitSpeechClick(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);

  end;
end;

It have bug :"SpeechRecognize should be used from application's main thead" That's all; Plz tell me what reason?, And, how to fix it.

2

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.