unit Sprachausgabe;
interface
uses
Androidapi.JNI.TTS,
FMX.Memo,
AndroidAPI.JNIBridge,
Androidapi.JNI.JavaTypes,
FMX.Helpers.Android,
Androidapi.JNI.GraphicsContentViewText,
FMX.Dialogs;
type
TttsOnInitListener =
class(TJavaLocal, JTextToSpeech_OnInitListener)
private
//[weak] FParent : TForm1;
public
//constructor Create(AParent : TForm1);
constructor Create;
procedure onInit(status: Integer);
cdecl;
end;
var
ttsListener : TttsOnInitListener;
tts : JTextToSpeech;
procedure SpeakOut(s :
String);
implementation
constructor TttsOnInitListener.Create;
begin
end;
procedure TttsOnInitListener.onInit(status: Integer);
var
Result : Integer;
begin
if (status = TJTextToSpeech.JavaClass.SUCCESS)
then
begin
result := tts.setLanguage(TJLocale.JavaClass.GERMAN);
if (result = TJTextToSpeech.JavaClass.LANG_MISSING_DATA)
or
(result = TJTextToSpeech.JavaClass.LANG_NOT_SUPPORTED)
then
ShowMessage('
This Language is not supported')
else
begin
end;
end
else
ShowMessage('
Initilization Failed!');
end;
procedure SpeakOut(s :
String);
var
text : JString;
begin
text := StringToJString(s);
//Format('Es ist jetzt %s',[s]));
tts.setSpeechRate(0.75);
tts.speak(text, TJTextToSpeech.JavaClass.QUEUE_FLUSH,
nil);
end;
end.