program Lees; {$APPTYPE CONSOLE} uses SysUtils, Classes, Windows, Messages, FluencyAPI; var Name: string; Voice, Channel: Pointer; Text: TStrings; Speaking: boolean; Msg: TMsg; procedure FLUENCYSYNC(SyncEvent, TextIndex, WordLength, User: Cardinal); stdcall; var Word: string; begin case (SyncEvent) of 1: begin Word := Copy(Text.Text, TextIndex+1, WordLength); CharToOEM(PChar(Word), PChar(Word)); // convert to ASCII Write(Word, ' '); end; 2: begin Speaking := false; Writeln; end; end; end; begin if ParamCount = 0 then Exit; Text := TStringList.Create; Text.LoadFromFile(ParamStr(1)); if not fluencyInitialize then Exit; SetLength(Name, 100); SetLength(Name, fluencyGetPreferredVoiceName(PChar(Name), 100)); Voice := fluencyCreateVoice(PChar(Name)); if not Assigned(Voice) then Exit; Channel := fluencyCreateChannel(Voice, 0, false); fluencySetInputText(Channel, PChar(Text.Text)); Speaking := fluencySpeak(Channel, @FLUENCYSYNC, 0); while Speaking and GetMessage(Msg, 0, 0, 0) do begin TranslateMessage(Msg); DispatchMessage(Msg); end; fluencyClose; Text.Free; end.