Голоса перенесены в AppData
This commit is contained in:
+14
-14
@@ -138,7 +138,7 @@ object frSettings: TfrSettings
|
||||
Size.Width = 128.000000000000000000
|
||||
Size.Height = 22.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
TabOrder = 31
|
||||
TabOrder = 29
|
||||
Text = #1054#1090#1082#1088#1099#1090#1100' '#1089#1090#1088#1080#1084
|
||||
TextSettings.Trimming = None
|
||||
OnClick = btnOpenStreamClick
|
||||
@@ -149,7 +149,7 @@ object frSettings: TfrSettings
|
||||
Size.Width = 128.000000000000000000
|
||||
Size.Height = 22.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
TabOrder = 32
|
||||
TabOrder = 31
|
||||
Text = #1055#1086#1083#1091#1095#1080#1090#1100' Token'
|
||||
TextSettings.Trimming = None
|
||||
OnClick = btnGetTokenStreamerClick
|
||||
@@ -197,7 +197,7 @@ object frSettings: TfrSettings
|
||||
object btnDAGetCode: TButton
|
||||
Position.X = 200.000000000000000000
|
||||
Position.Y = 216.000000000000000000
|
||||
TabOrder = 40
|
||||
TabOrder = 34
|
||||
Text = #1055#1086#1083#1091#1095#1080#1090#1100
|
||||
TextSettings.Trimming = None
|
||||
OnClick = btnDAGetCodeClick
|
||||
@@ -207,11 +207,11 @@ object frSettings: TfrSettings
|
||||
Position.Y = 24.000000000000000000
|
||||
TextSettings.Trimming = None
|
||||
Text = 'Client ID'
|
||||
TabOrder = 33
|
||||
TabOrder = 29
|
||||
end
|
||||
object edtDAClientID: TEdit
|
||||
Touch.InteractiveGestures = [LongTap, DoubleTap]
|
||||
TabOrder = 35
|
||||
TabOrder = 31
|
||||
Password = True
|
||||
Position.X = 8.000000000000000000
|
||||
Position.Y = 49.000000000000000000
|
||||
@@ -225,11 +225,11 @@ object frSettings: TfrSettings
|
||||
Position.Y = 79.000000000000000000
|
||||
TextSettings.Trimming = None
|
||||
Text = 'Client Secret'
|
||||
TabOrder = 34
|
||||
TabOrder = 30
|
||||
end
|
||||
object edtDAClientSecret: TEdit
|
||||
Touch.InteractiveGestures = [LongTap, DoubleTap]
|
||||
TabOrder = 36
|
||||
TabOrder = 32
|
||||
Password = True
|
||||
Position.X = 8.000000000000000000
|
||||
Position.Y = 104.000000000000000000
|
||||
@@ -243,11 +243,11 @@ object frSettings: TfrSettings
|
||||
Position.Y = 134.000000000000000000
|
||||
TextSettings.Trimming = None
|
||||
Text = 'Redirect URL'
|
||||
TabOrder = 38
|
||||
TabOrder = 33
|
||||
end
|
||||
object edtDARedirectURL: TEdit
|
||||
Touch.InteractiveGestures = [LongTap, DoubleTap]
|
||||
TabOrder = 39
|
||||
TabOrder = 35
|
||||
Password = True
|
||||
Position.X = 8.000000000000000000
|
||||
Position.Y = 159.000000000000000000
|
||||
@@ -258,7 +258,7 @@ object frSettings: TfrSettings
|
||||
end
|
||||
object edtDACode: TEdit
|
||||
Touch.InteractiveGestures = [LongTap, DoubleTap]
|
||||
TabOrder = 41
|
||||
TabOrder = 36
|
||||
Password = True
|
||||
Position.X = 8.000000000000000000
|
||||
Position.Y = 214.000000000000000000
|
||||
@@ -271,7 +271,7 @@ object frSettings: TfrSettings
|
||||
Position.Y = 189.000000000000000000
|
||||
TextSettings.Trimming = None
|
||||
Text = 'Code'
|
||||
TabOrder = 42
|
||||
TabOrder = 38
|
||||
end
|
||||
object btnDAStart: TButton
|
||||
Position.X = 8.000000000000000000
|
||||
@@ -279,7 +279,7 @@ object frSettings: TfrSettings
|
||||
Size.Width = 121.000000000000000000
|
||||
Size.Height = 22.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
TabOrder = 43
|
||||
TabOrder = 40
|
||||
Text = #1055#1086#1076#1082#1083#1102#1095#1080#1090#1100#1089#1103
|
||||
TextSettings.Trimming = None
|
||||
OnClick = btnDAStartClick
|
||||
@@ -291,7 +291,7 @@ object frSettings: TfrSettings
|
||||
Size.Width = 209.000000000000000000
|
||||
Size.Height = 22.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
TabOrder = 46
|
||||
TabOrder = 44
|
||||
Text = #1055#1086#1083#1091#1095#1080#1090#1100' '#1076#1072#1085#1085#1099#1077' Donation Alerts'
|
||||
TextSettings.Trimming = None
|
||||
Visible = False
|
||||
@@ -345,7 +345,7 @@ object frSettings: TfrSettings
|
||||
Size.Width = 193.000000000000000000
|
||||
Size.Height = 22.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
TabOrder = 7
|
||||
TabOrder = 6
|
||||
Text = #1047#1072#1087#1091#1089#1090#1080#1090#1100' '#1084#1072#1089#1090#1077#1088' '#1085#1072#1089#1090#1088#1086#1081#1082#1080
|
||||
TextSettings.Trimming = None
|
||||
OnClick = btnMasterClick
|
||||
|
||||
+37
-35
@@ -4,11 +4,12 @@ interface
|
||||
|
||||
uses
|
||||
System.SysUtils, System.Types, System.UITypes, System.Classes,
|
||||
System.Variants, uQ,
|
||||
System.Variants, uQ, IdHTTP, IdComponent, System.Zip,
|
||||
FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls,
|
||||
winapi.ShellAPI, System.IOUtils, uDataBase,
|
||||
FMX.Controls.Presentation, FMX.Edit, uTWAuth, uRecords, uAPIDA, uShowText,
|
||||
System.json, uWSDA, fLog;
|
||||
System.json, uWSDA, fLog, IdBaseComponent, IdIOHandler, IdIOHandlerSocket,
|
||||
IdIOHandlerStack, IdSSL, IdSSLOpenSSL;
|
||||
|
||||
type
|
||||
TfrSettings = class(TFrame)
|
||||
@@ -83,18 +84,18 @@ uses uGeneral;
|
||||
procedure TfrSettings.btnDAGetCodeClick(Sender: TObject);
|
||||
var
|
||||
twa: TTTWAuth;
|
||||
Url: string;
|
||||
URL: string;
|
||||
begin
|
||||
if (edtDAClientSecret.text = '') or (edtDAClientID.text = '') or
|
||||
(edtDARedirectURL.text = '') then
|
||||
exit;
|
||||
|
||||
Url := 'https://www.donationalerts.com/oauth/authorize?client_id=' +
|
||||
URL := 'https://www.donationalerts.com/oauth/authorize?client_id=' +
|
||||
edtDAClientID.text +
|
||||
'&redirect_uri=http://localhost/da&response_type=code&scope=oauth-user-show+oauth-donation-subscribe';
|
||||
twa := TTTWAuth.Create;
|
||||
twa.OnToken := OnTokenDA;
|
||||
twa.StartServer(Url);
|
||||
twa.StartServer(URL);
|
||||
// ttw_Auth áóäåò îñâîáîæäåí àâòîìàòè÷åñêè ïîñëå ïîëó÷åíèÿ òîêåíà (ñì. uTWAuth)
|
||||
end;
|
||||
|
||||
@@ -107,7 +108,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure TfrSettings.btnDAStartClick(Sender: TObject);
|
||||
var
|
||||
UserInfo: TJSONObject;
|
||||
@@ -124,17 +124,14 @@ begin
|
||||
if FAPIClient.Token = '' then
|
||||
begin
|
||||
try
|
||||
FAPIClient.Token := FAPIClient.GetAccessToken(
|
||||
edtDAClientID.text,
|
||||
edtDAClientSecret.text,
|
||||
edtDARedirectURL.text,
|
||||
edtDACode.text
|
||||
);
|
||||
FAPIClient.Token := FAPIClient.GetAccessToken(edtDAClientID.text,
|
||||
edtDAClientSecret.text, edtDARedirectURL.text, edtDACode.text);
|
||||
except
|
||||
on E: Exception do
|
||||
begin
|
||||
TTW_Bot.toLog('fSettings', 'btnDAStartClick', 'Îøèáêà ïîëó÷åíèÿ òîêåíà: ' + E.Message,2);
|
||||
Exit;
|
||||
TTW_Bot.toLog('fSettings', 'btnDAStartClick',
|
||||
'Îøèáêà ïîëó÷åíèÿ òîêåíà: ' + E.Message, 2);
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
|
||||
@@ -143,31 +140,34 @@ begin
|
||||
try
|
||||
UserInfo := FAPIClient.GetUserInfo;
|
||||
Data := UserInfo.GetValue<TJSONObject>('data');
|
||||
FWSClient.Wsstoken := Data.GetValue<string>('socket_connection_token');
|
||||
FWSClient.Wsstoken := Data.GetValue<string>
|
||||
('socket_connection_token');
|
||||
FWSClient.WSID := Data.GetValue<string>('id');
|
||||
except
|
||||
on E: Exception do
|
||||
begin
|
||||
TTW_Bot.toLog( 'fSettings','btnDAStartClick', 'Îøèáêà ïîëó÷åíèÿ UserInfo: ' + E.Message,2);
|
||||
Exit;
|
||||
TTW_Bot.toLog('fSettings', 'btnDAStartClick',
|
||||
'Îøèáêà ïîëó÷åíèÿ UserInfo: ' + E.Message, 2);
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
try
|
||||
FWSClient.Connect('wss://centrifugo.donationalerts.com/connection/websocket');
|
||||
FWSClient.Send(Format(
|
||||
'{"params":{"token":"%s"},"id":1}',
|
||||
[FWSClient.Wsstoken]
|
||||
));
|
||||
FWSClient.Connect
|
||||
('wss://centrifugo.donationalerts.com/connection/websocket');
|
||||
FWSClient.Send(Format('{"params":{"token":"%s"},"id":1}',
|
||||
[FWSClient.Wsstoken]));
|
||||
except
|
||||
on E: Exception do
|
||||
TTW_Bot.toLog( 'fSettings','btnDAStartClick', 'Îøèáêà ïîäêëþ÷åíèÿ ê WebSocket: ' + E.Message,2);
|
||||
TTW_Bot.toLog('fSettings', 'btnDAStartClick',
|
||||
'Îøèáêà ïîäêëþ÷åíèÿ ê WebSocket: ' + E.Message, 2);
|
||||
end;
|
||||
|
||||
except
|
||||
on E: Exception do
|
||||
TTW_Bot.toLog('fSettings', 'btnDAStartClick', 'Íåèçâåñòíàÿ îøèáêà: ' + E.Message,2);
|
||||
TTW_Bot.toLog('fSettings', 'btnDAStartClick', 'Íåèçâåñòíàÿ îøèáêà: ' +
|
||||
E.Message, 2);
|
||||
end;
|
||||
finally
|
||||
UserInfo.Free;
|
||||
@@ -176,14 +176,15 @@ begin
|
||||
else
|
||||
begin
|
||||
try
|
||||
edtDACode.Text:='';
|
||||
edtDACode.text := '';
|
||||
if Assigned(FWSClient) then
|
||||
begin
|
||||
try
|
||||
FWSClient.Disconnect;
|
||||
except
|
||||
on E: Exception do
|
||||
TTW_Bot.toLog( 'fSettings', 'btnDAStartClick', 'Îøèáêà ïðè îòêëþ÷åíèè WS: ' + E.Message,2);
|
||||
TTW_Bot.toLog('fSettings', 'btnDAStartClick',
|
||||
'Îøèáêà ïðè îòêëþ÷åíèè WS: ' + E.Message, 2);
|
||||
end;
|
||||
FreeAndNil(FWSClient);
|
||||
end;
|
||||
@@ -204,7 +205,7 @@ begin
|
||||
if SaveDialog1.Execute then
|
||||
begin
|
||||
DestinationFile := SaveDialog1.FileName;
|
||||
TFile.Copy(myConst.DBPath, DestinationFile, True);
|
||||
TFile.Copy(myConst.DBPath, DestinationFile, true);
|
||||
end;
|
||||
end;
|
||||
|
||||
@@ -227,10 +228,10 @@ begin
|
||||
s := 'https://id.twitch.tv/oauth2/authorize?client_id=' + edtBotClientID.text
|
||||
+ '&redirect_uri=http://localhost&response_type=token&' + 'scope=' + sope;
|
||||
ttw_Auth.StartServer('');
|
||||
forbot := True;
|
||||
forbot := true;
|
||||
fShowText.Memo1.Lines.text := s;
|
||||
fShowText.Show;
|
||||
fShowText.Memo1.WordWrap := True;
|
||||
fShowText.Memo1.WordWrap := true;
|
||||
|
||||
end;
|
||||
|
||||
@@ -261,7 +262,7 @@ begin
|
||||
SourceFile := OpenDialog1.FileName;
|
||||
DestinationDir := myConst.DBPath;
|
||||
DestinationFile := myConst.DBPath;
|
||||
TFile.Copy(SourceFile, DestinationFile, True);
|
||||
TFile.Copy(SourceFile, DestinationFile, true);
|
||||
DB := TSettingsDatabase.Create(myConst.DBPath);
|
||||
end;
|
||||
end;
|
||||
@@ -315,11 +316,12 @@ end;
|
||||
|
||||
destructor TfrSettings.Destroy;
|
||||
begin
|
||||
if Assigned(FWSClient) then
|
||||
if Assigned(FWSClient) then
|
||||
begin
|
||||
try
|
||||
FWSClient.Disconnect; // åñëè åñòü ìåòîä îòêëþ÷åíèÿ
|
||||
except end;
|
||||
except
|
||||
end;
|
||||
FreeAndNil(FWSClient);
|
||||
end;
|
||||
FreeAndNil(FAPIClient);
|
||||
@@ -339,7 +341,7 @@ end;
|
||||
|
||||
procedure TfrSettings.init;
|
||||
begin
|
||||
if not Assigned(FAPIClient) then
|
||||
if not Assigned(FAPIClient) then
|
||||
FAPIClient := TAPIClient.Create;
|
||||
if not Assigned(FWSClient) then
|
||||
begin
|
||||
@@ -369,14 +371,14 @@ end;
|
||||
procedure TfrSettings.HandleWSDonate(aNick, aMessage, aSum: string);
|
||||
begin
|
||||
// fDonats.OnDADonate(aNick, aMessage, aSum);
|
||||
TTW_Bot.frOBS1.toEventWebServer(aNick,aSum,aMessage);
|
||||
TTW_Bot.frOBS1.toEventWebServer(aNick, aSum, aMessage);
|
||||
TTW_Bot.frEvents1.OnDonate(aNick, aMessage, aSum);
|
||||
|
||||
end;
|
||||
|
||||
procedure TfrSettings.HandleWSStatus(AStatusText: string; AStatusCode: integer);
|
||||
begin
|
||||
TTW_Bot.tolog('fSettings','HandleWSStatus',AStatusText,3);
|
||||
TTW_Bot.toLog('fSettings', 'HandleWSStatus', AStatusText, 3);
|
||||
TTW_Bot.Label8.text := AStatusText;
|
||||
case AStatusCode of
|
||||
0:
|
||||
|
||||
@@ -70,4 +70,15 @@ object frTTS: TfrTTS
|
||||
TextSettings.Trimming = None
|
||||
OnClick = btnSendClick
|
||||
end
|
||||
object btnGetVoices: TButton
|
||||
Position.X = 177.000000000000000000
|
||||
Position.Y = 63.000000000000000000
|
||||
Size.Width = 128.000000000000000000
|
||||
Size.Height = 22.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
TabOrder = 8
|
||||
Text = #1055#1086#1083#1091#1095#1080#1090#1100' '#1075#1086#1083#1086#1089#1072
|
||||
TextSettings.Trimming = None
|
||||
OnClick = btnGetVoicesClick
|
||||
end
|
||||
end
|
||||
|
||||
+14
-6
@@ -18,10 +18,12 @@ type
|
||||
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;
|
||||
@@ -34,19 +36,26 @@ 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, s1: string;
|
||||
s: string;
|
||||
|
||||
begin
|
||||
case cbOutput.ItemIndex of
|
||||
0:
|
||||
begin // this
|
||||
s := ExtractFilePath(ParamStr(0)) + 'piper\piper.exe';
|
||||
s1 := ExtractFilePath(ParamStr(0)) + 'piper\voices';
|
||||
if cbVoices.ItemIndex = -1 then
|
||||
exit;
|
||||
tts := TTTS.Create(s, s1);
|
||||
tts := TTTS.Create(s, myConst.VoicesPath);
|
||||
try
|
||||
tts.SetModel(cbVoices.Text);
|
||||
tts.TextToSpeech(edtText.Text, true);
|
||||
@@ -67,13 +76,12 @@ end;
|
||||
|
||||
procedure TfrTTS.btnUpdateVoicesClick(Sender: TObject);
|
||||
var
|
||||
s, s1: string;
|
||||
s: string;
|
||||
List: TStringList;
|
||||
begin
|
||||
s := ExtractFilePath(ParamStr(0)) + 'piper\piper.exe';
|
||||
s1 := ExtractFilePath(ParamStr(0)) + 'piper\voices';
|
||||
|
||||
tts := TTTS.Create(s, s1);
|
||||
tts := TTTS.Create(s, myConst.VoicesPath);
|
||||
List := TStringList.Create;
|
||||
try
|
||||
cbVoices.Items.Clear;
|
||||
|
||||
Reference in New Issue
Block a user