Skip to content

Commit 0eb2ec6

Browse files
committed
MSpeech v1.5.7
Signed-off-by: Mikhail Grigorev <[email protected]>
1 parent 1599f10 commit 0eb2ec6

36 files changed

+1617
-3316
lines changed

ASR.pas

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
{ ############################################################################ }
22
{ # # }
3-
{ # MSpeech v1.5.5 - Ðàñïîçíàâàíèå ðå÷è èñïîëüçóÿ Google Speech API # }
3+
{ # MSpeech v1.5.7 - Ðàñïîçíàâàíèå ðå÷è èñïîëüçóÿ Google Speech API # }
44
{ # # }
55
{ # License: GPLv3 # }
66
{ # # }
7+
{ # Automated Speech Recognition (ASR) Module # }
8+
{ # # }
79
{ # Author: Mikhail Grigorev (icq: 161867489, email: [email protected]) # }
810
{ # # }
911
{ ############################################################################ }
@@ -19,7 +21,7 @@ //JSONError = class(Exception);
1921
// Ñòðóêòóðà ñ èíôîðìàöèåé î ðàñïîçíàííîé ôðàçå (ïåðåäàåòñÿ â callback ïðîöåäóðó)
2022
PRecognizeInfo = ^TRecognizeInfo;
2123
TRecognizeInfo = record
22-
FStatus : Integer; // Ñòàòóñ ðàñïîçíàâàíèÿ: 5- çàïèñü íå ðàñïîçíàíà, 0 - çàïèñü ðàñïîçíàíà
24+
FStatus : Integer; // Ñòàòóñ ðàñïîçíàâàíèÿ: 5- çàïèñü íå ðàñïîçíàíà, 0 - çàïèñü ðàñïîçíàíà, 1 - Îøèáêà ïàðñèíãà îòâåòà, 2 - îøèáêà ïîëó÷åíèÿ îòâåòà
2325
FConfidence : Real; // Äîñòîâåðíîñòü ðàñïîçíàâàíèÿ â %
2426
FTranscript : String; // Ðàñïîçíàííàÿ ôðàçà
2527
end;
@@ -183,20 +185,26 @@ procedure TGoogleRecognizer.Execute;
183185
else
184186
begin
185187
FRecognizeInfo := SendRecognizeRequest(FInputFileName);
186-
if FRecognizeInfo.FStatus = 1 then // Îøèáêà ïðè ïàðñèíãå îòâåòà
188+
if FRecognizeInfo.FStatus = 0 then // Çàïèñü ðàñïîçíàíà
187189
begin
188-
FRecognizeErr := reErrorGoogleResponse;
189-
FRecognizeErrStr := FResultList.Text;
190-
Synchronize(ErrorEvent);
190+
FRecognizeStatus := rsRecognizeDone;
191+
Synchronize(StatusEvent);
191192
end
192-
else if FRecognizeInfo.FStatus = 5 then // Çàïèñü íå ðàñïîçíàíà
193+
else if FRecognizeInfo.FStatus = 1 then // Îøèáêà ïðè ïàðñèíãå îòâåòà
193194
begin
195+
if EnableLogs then WriteInLog(WorkPath, FormatDateTime('dd.mm.yy hh:mm:ss', Now) + ': Îøèáêà ïðè ïîëó÷åíèè îòâåòà îò ñåðâåðà Google. (' + FRecognizeInfo.FTranscript + ')');
194196
FRecognizeStatus := rsRecordingNotRecognized;
195197
Synchronize(StatusEvent);
196198
end
197-
else if FRecognizeInfo.FStatus = 0 then // Çàïèñü ðàñïîçíàíà
199+
else if FRecognizeInfo.FStatus = 2 then // Îøèáêà ïðè ïîëó÷åíèè îòâåòà îò ñåðâåðà
198200
begin
199-
FRecognizeStatus := rsRecognizeDone;
201+
if EnableLogs then WriteInLog(WorkPath, FormatDateTime('dd.mm.yy hh:mm:ss', Now) + ': Îøèáêà ïðè ïîëó÷åíèè îòâåòà îò ñåðâåðà Google, âîçìîæíî çàïèñü äëÿ ðàñïîçíàâàíèÿ áûëà ñëèøêîì äëèííîé, ïîïðîáóéòå å¸ ñîêðàòèòü äî 3-5 ñåêóíä. (' + FRecognizeInfo.FTranscript + ')');
202+
FRecognizeStatus := rsRecordingNotRecognized;
203+
Synchronize(StatusEvent);
204+
end
205+
else if FRecognizeInfo.FStatus = 5 then // Çàïèñü íå ðàñïîçíàíà
206+
begin
207+
FRecognizeStatus := rsRecordingNotRecognized;
200208
Synchronize(StatusEvent);
201209
end;
202210
end
@@ -231,8 +239,8 @@ function TGoogleRecognizer.SendRecognizeRequest(AudioFile: String): TRecognizeIn
231239
FURL := Format(GoogleRecognizeURLv2MSpeech, [FRecognizeLang, FGoogleAPIKey, ProgramsName+'-'+ProgramsVer]);
232240
if not HTTPPostFile(FURL, 'userfile', FInputFileName, FInputStream, FResultList) then
233241
begin
234-
Result.FStatus := 1;
235-
Result.FTranscript := 'Error in procedure HTTPPostFile';
242+
Result.FStatus := 2;
243+
Result.FTranscript := 'Failed to get a response from the server in procedure HTTPPostFile';
236244
Exit;
237245
end;
238246
finally
@@ -275,6 +283,7 @@ function TGoogleRecognizer.HTTPPostFile(const URL, FieldName, FileName: String;
275283
var
276284
Bound, Str: String;
277285
begin
286+
Result := False;
278287
Bound := IntToHex(Random(MaxInt), 8) + '_Synapse_boundary';
279288
try
280289
if FUseProxy then

Global.pas

Lines changed: 271 additions & 789 deletions
Large diffs are not rendered by default.
-10.1 KB
Binary file not shown.

IMButtonGroupComponent/Demo/IMButtonGroupDemo.dpr

Lines changed: 0 additions & 14 deletions
This file was deleted.

IMButtonGroupComponent/Demo/IMButtonGroupDemo.dproj

Lines changed: 0 additions & 109 deletions
This file was deleted.
-90.1 KB
Binary file not shown.

0 commit comments

Comments
 (0)