unit fTTS; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, winapi.shellapi, FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls, FMX.Edit, FMX.ListBox, FMX.Controls.Presentation, uTTS, bass_simple; type TfrTTS = class(TFrame) Label1: TLabel; cbVoices: TComboBox; btnUpdateVoices: TButton; Label2: TLabel; edtText: TEdit; Label3: TLabel; btnSend: TButton; cbOutput: TComboBox; btnGetVoices: TButton; procedure btnUpdateVoicesClick(Sender: TObject); procedure btnSendClick(Sender: TObject); procedure cbVoicesChange(Sender: TObject); procedure cbOutputChange(Sender: TObject); procedure btnGetVoicesClick(Sender: TObject); private { Private declarations } tts: TTTS; public { Public declarations } end; implementation {$R *.fmx} uses ugeneral; procedure TfrTTS.btnGetVoicesClick(Sender: TObject); begin ShellExecute(0, 'open', pwidechar(ExtractFilePath(myConst.VoicesPath)), nil, nil, 1); ShellExecute(0, 'open', pwidechar('https://huggingface.co/rhasspy/piper-voices/tree/v1.0.0'), nil, nil, 1); end; procedure TfrTTS.btnSendClick(Sender: TObject); var s: string; begin case cbOutput.ItemIndex of 0: begin // this s := ExtractFilePath(ParamStr(0)) + 'piper\piper.exe'; if cbVoices.ItemIndex = -1 then exit; tts := TTTS.Create(s, myConst.VoicesPath); try tts.SetModel(cbVoices.Text); tts.TextToSpeech(edtText.Text, true); finally tts.Free; end; end; 1: begin // SilentPlay ShellExecute(0, 'open', PChar(myConst.SilentPlay), PChar(Format('%s %s "%s"', ['2', cbVoices.Text, edtText.Text])), nil, 0); end; end; end; procedure TfrTTS.btnUpdateVoicesClick(Sender: TObject); var s: string; List: TStringList; begin s := ExtractFilePath(ParamStr(0)) + 'piper\piper.exe'; tts := TTTS.Create(s, myConst.VoicesPath); List := TStringList.Create; try cbVoices.Items.Clear; List := tts.GetModelsList; cbVoices.Items.Assign(List); finally tts.Free; List.Free; end; end; procedure TfrTTS.cbOutputChange(Sender: TObject); begin db.WriteSetting('cbOutput',inttostr(cbOutput.ItemIndex)); end; procedure TfrTTS.cbVoicesChange(Sender: TObject); begin db.WriteSetting('cbVoices',inttostr(cbVoices.ItemIndex)); end; end.