Fangjun Kuang
Committed by GitHub

Fix building for Pascal (#2305)

@@ -7,3 +7,13 @@ for how to build the project in this directory. @@ -7,3 +7,13 @@ for how to build the project in this directory.
7 You can find pre-built APPs from this directory at 7 You can find pre-built APPs from this directory at
8 https://k2-fsa.github.io/sherpa/onnx/lazarus/pre-built-app.html 8 https://k2-fsa.github.io/sherpa/onnx/lazarus/pre-built-app.html
9 9
  10 +
  11 +
  12 +## notes for developers
  13 +
  14 +By default, it uses static libs for Linux and macOS. To change that,
  15 +open Lazarus IDE, select `Project`, `Project options`, `Compiler options`,
  16 +change the `Build modes` to `Release-Linux`.
  17 +
  18 +The `Release-Linux` mode is defined in the file `generate_subtitles.lpi`.
  19 +It defines a macro `SHERPA_ONNX_USE_SHARED_LIBS`.
@@ -196,6 +196,24 @@ def get_models(): @@ -196,6 +196,24 @@ def get_models():
196 popd 196 popd
197 """, 197 """,
198 ), 198 ),
  199 + Model(
  200 + model_name="sherpa-onnx-nemo-parakeet-tdt-0.6b-v2-int8",
  201 + lang="en",
  202 + short_name="parakeet_tdt_0.6b_v2",
  203 + cmd="""
  204 + pushd $model_name
  205 +
  206 + rm -rfv test_wavs
  207 +
  208 + mv -v encoder.int8.onnx nemo-transducer-encoder.onnx
  209 + mv -v decoder.int8.onnx nemo-transducer-decoder.onnx
  210 + mv -v joiner.int8.onnx nemo-transducer-joiner.onnx
  211 +
  212 + ls -lh
  213 +
  214 + popd
  215 + """,
  216 + ),
199 ] 217 ]
200 return models 218 return models
201 219
@@ -195,6 +195,13 @@ type @@ -195,6 +195,13 @@ type
195 class operator Initialize({$IFDEF FPC}var{$ELSE}out{$ENDIF} Dest: TSherpaOnnxOnlineCtcFstDecoderConfig); 195 class operator Initialize({$IFDEF FPC}var{$ELSE}out{$ENDIF} Dest: TSherpaOnnxOnlineCtcFstDecoderConfig);
196 end; 196 end;
197 197
  198 + TSherpaOnnxHomophoneReplacerConfig = record
  199 + DictDir: AnsiString;
  200 + Lexicon: AnsiString;
  201 + RuleFsts: AnsiString;
  202 + function ToString: AnsiString;
  203 + end;
  204 +
198 TSherpaOnnxOnlineRecognizerConfig = record 205 TSherpaOnnxOnlineRecognizerConfig = record
199 FeatConfig: TSherpaOnnxFeatureConfig; 206 FeatConfig: TSherpaOnnxFeatureConfig;
200 ModelConfig: TSherpaOnnxOnlineModelConfig; 207 ModelConfig: TSherpaOnnxOnlineModelConfig;
@@ -212,6 +219,7 @@ type @@ -212,6 +219,7 @@ type
212 BlankPenalty: Single; 219 BlankPenalty: Single;
213 HotwordsBuf: AnsiString; 220 HotwordsBuf: AnsiString;
214 HotwordsBufSize: Integer; 221 HotwordsBufSize: Integer;
  222 + Hr: TSherpaOnnxHomophoneReplacerConfig;
215 function ToString: AnsiString; 223 function ToString: AnsiString;
216 class operator Initialize({$IFDEF FPC}var{$ELSE}out{$ENDIF} Dest: TSherpaOnnxOnlineRecognizerConfig); 224 class operator Initialize({$IFDEF FPC}var{$ELSE}out{$ENDIF} Dest: TSherpaOnnxOnlineRecognizerConfig);
217 end; 225 end;
@@ -352,6 +360,7 @@ type @@ -352,6 +360,7 @@ type
352 RuleFsts: AnsiString; 360 RuleFsts: AnsiString;
353 RuleFars: AnsiString; 361 RuleFars: AnsiString;
354 BlankPenalty: Single; 362 BlankPenalty: Single;
  363 + Hr: TSherpaOnnxHomophoneReplacerConfig;
355 class operator Initialize({$IFDEF FPC}var{$ELSE}out{$ENDIF} Dest: TSherpaOnnxOfflineRecognizerConfig); 364 class operator Initialize({$IFDEF FPC}var{$ELSE}out{$ENDIF} Dest: TSherpaOnnxOfflineRecognizerConfig);
356 function ToString: AnsiString; 365 function ToString: AnsiString;
357 end; 366 end;
@@ -601,6 +610,7 @@ const @@ -601,6 +610,7 @@ const
601 {$linklib sherpa-onnx-kaldifst-core} 610 {$linklib sherpa-onnx-kaldifst-core}
602 {$linklib sherpa-onnx-fstfar} 611 {$linklib sherpa-onnx-fstfar}
603 {$linklib sherpa-onnx-fst} 612 {$linklib sherpa-onnx-fst}
  613 + {$linklib kissfft-float}
604 {$linklib kaldi-native-fbank-core} 614 {$linklib kaldi-native-fbank-core}
605 {$linklib piper_phonemize} 615 {$linklib piper_phonemize}
606 {$linklib espeak-ng} 616 {$linklib espeak-ng}
@@ -668,6 +678,13 @@ type @@ -668,6 +678,13 @@ type
668 Graph: PAnsiChar; 678 Graph: PAnsiChar;
669 MaxActive: cint32; 679 MaxActive: cint32;
670 end; 680 end;
  681 +
  682 + SherpaOnnxHomophoneReplacerConfig = record
  683 + DictDir: PAnsiChar;
  684 + Lexicon: PAnsiChar;
  685 + RuleFsts: PAnsiChar;
  686 + end;
  687 +
671 SherpaOnnxOnlineRecognizerConfig = record 688 SherpaOnnxOnlineRecognizerConfig = record
672 FeatConfig: SherpaOnnxFeatureConfig; 689 FeatConfig: SherpaOnnxFeatureConfig;
673 ModelConfig: SherpaOnnxOnlineModelConfig; 690 ModelConfig: SherpaOnnxOnlineModelConfig;
@@ -685,6 +702,7 @@ type @@ -685,6 +702,7 @@ type
685 BlankPenalty: cfloat; 702 BlankPenalty: cfloat;
686 HotwordsBuf: PAnsiChar; 703 HotwordsBuf: PAnsiChar;
687 HotwordsBufSize: cint32; 704 HotwordsBufSize: cint32;
  705 + Hr: SherpaOnnxHomophoneReplacerConfig;
688 end; 706 end;
689 707
690 PSherpaOnnxOnlineRecognizerConfig = ^SherpaOnnxOnlineRecognizerConfig; 708 PSherpaOnnxOnlineRecognizerConfig = ^SherpaOnnxOnlineRecognizerConfig;
@@ -763,6 +781,7 @@ type @@ -763,6 +781,7 @@ type
763 RuleFsts: PAnsiChar; 781 RuleFsts: PAnsiChar;
764 RuleFars: PAnsiChar; 782 RuleFars: PAnsiChar;
765 BlankPenalty: cfloat; 783 BlankPenalty: cfloat;
  784 + Hr: SherpaOnnxHomophoneReplacerConfig;
766 end; 785 end;
767 786
768 PSherpaOnnxOfflineRecognizerConfig = ^SherpaOnnxOfflineRecognizerConfig; 787 PSherpaOnnxOfflineRecognizerConfig = ^SherpaOnnxOfflineRecognizerConfig;
@@ -1238,6 +1257,12 @@ begin @@ -1238,6 +1257,12 @@ begin
1238 [Self.Graph, Self.MaxActive]); 1257 [Self.Graph, Self.MaxActive]);
1239 end; 1258 end;
1240 1259
  1260 +function TSherpaOnnxHomophoneReplacerConfig.ToString: AnsiString;
  1261 +begin
  1262 + Result := Format('TSherpaOnnxHomophoneReplacerConfig(DictDir := %s, Lexicon := %s, RuleFsts := %s)',
  1263 + [Self.DictDir, Self.Lexicon, Self.RuleFsts]);
  1264 +end;
  1265 +
1241 function TSherpaOnnxOnlineRecognizerConfig.ToString: AnsiString; 1266 function TSherpaOnnxOnlineRecognizerConfig.ToString: AnsiString;
1242 begin 1267 begin
1243 Result := Format('TSherpaOnnxOnlineRecognizerConfig(FeatConfig := %s, ' + 1268 Result := Format('TSherpaOnnxOnlineRecognizerConfig(FeatConfig := %s, ' +
@@ -1253,7 +1278,8 @@ begin @@ -1253,7 +1278,8 @@ begin
1253 'CtcFstDecoderConfig := %s, ' + 1278 'CtcFstDecoderConfig := %s, ' +
1254 'RuleFsts := %s, ' + 1279 'RuleFsts := %s, ' +
1255 'RuleFars := %s, ' + 1280 'RuleFars := %s, ' +
1256 - 'BlankPenalty := %.1f' + 1281 + 'BlankPenalty := %.1f, ' +
  1282 + 'Hr := %s' +
1257 ')' 1283 ')'
1258 , 1284 ,
1259 [Self.FeatConfig.ToString, Self.ModelConfig.ToString, 1285 [Self.FeatConfig.ToString, Self.ModelConfig.ToString,
@@ -1261,7 +1287,7 @@ begin @@ -1261,7 +1287,7 @@ begin
1261 Self.Rule1MinTrailingSilence, Self.Rule2MinTrailingSilence, 1287 Self.Rule1MinTrailingSilence, Self.Rule2MinTrailingSilence,
1262 Self.Rule3MinUtteranceLength, Self.HotwordsFile, Self.HotwordsScore, 1288 Self.Rule3MinUtteranceLength, Self.HotwordsFile, Self.HotwordsScore,
1263 Self.CtcFstDecoderConfig.ToString, Self.RuleFsts, Self.RuleFars, 1289 Self.CtcFstDecoderConfig.ToString, Self.RuleFsts, Self.RuleFars,
1264 - Self.BlankPenalty 1290 + Self.BlankPenalty, Self.Hr.ToString
1265 ]); 1291 ]);
1266 end; 1292 end;
1267 1293
@@ -1336,6 +1362,9 @@ begin @@ -1336,6 +1362,9 @@ begin
1336 C.RuleFsts := PAnsiChar(Config.RuleFsts); 1362 C.RuleFsts := PAnsiChar(Config.RuleFsts);
1337 C.RuleFars := PAnsiChar(Config.RuleFars); 1363 C.RuleFars := PAnsiChar(Config.RuleFars);
1338 C.BlankPenalty := Config.BlankPenalty; 1364 C.BlankPenalty := Config.BlankPenalty;
  1365 + C.Hr.DictDir := PAnsiChar(Config.Hr.DictDir);
  1366 + C.Hr.Lexicon := PAnsiChar(Config.Hr.Lexicon);
  1367 + C.Hr.RuleFsts := PAnsiChar(Config.Hr.RuleFsts);
1339 1368
1340 Self.Handle := SherpaOnnxCreateOnlineRecognizer(@C); 1369 Self.Handle := SherpaOnnxCreateOnlineRecognizer(@C);
1341 Self._Config := Config; 1370 Self._Config := Config;
@@ -1574,12 +1603,13 @@ begin @@ -1574,12 +1603,13 @@ begin
1574 'HotwordsScore := %.1f, ' + 1603 'HotwordsScore := %.1f, ' +
1575 'RuleFsts := %s, ' + 1604 'RuleFsts := %s, ' +
1576 'RuleFars := %s, ' + 1605 'RuleFars := %s, ' +
1577 - 'BlankPenalty := %1.f' + 1606 + 'BlankPenalty := %1.f, ' +
  1607 + 'Hr := %s' +
1578 ')', 1608 ')',
1579 [Self.FeatConfig.ToString, Self.ModelConfig.ToString, 1609 [Self.FeatConfig.ToString, Self.ModelConfig.ToString,
1580 Self.LMConfig.ToString, Self.DecodingMethod, Self.MaxActivePaths, 1610 Self.LMConfig.ToString, Self.DecodingMethod, Self.MaxActivePaths,
1581 Self.HotwordsFile, Self.HotwordsScore, Self.RuleFsts, Self.RuleFars, 1611 Self.HotwordsFile, Self.HotwordsScore, Self.RuleFsts, Self.RuleFars,
1582 - Self.BlankPenalty 1612 + Self.BlankPenalty, Self.Hr.ToString
1583 ]); 1613 ]);
1584 end; 1614 end;
1585 1615
@@ -1640,6 +1670,10 @@ begin @@ -1640,6 +1670,10 @@ begin
1640 C.RuleFars := PAnsiChar(Config.RuleFars); 1670 C.RuleFars := PAnsiChar(Config.RuleFars);
1641 C.BlankPenalty := Config.BlankPenalty; 1671 C.BlankPenalty := Config.BlankPenalty;
1642 1672
  1673 + C.Hr.DictDir := PAnsiChar(Config.Hr.DictDir);
  1674 + C.Hr.Lexicon := PAnsiChar(Config.Hr.Lexicon);
  1675 + C.Hr.RuleFsts := PAnsiChar(Config.Hr.RuleFsts);
  1676 +
1643 Self.Handle := SherpaOnnxCreateOfflineRecognizer(@C); 1677 Self.Handle := SherpaOnnxCreateOfflineRecognizer(@C);
1644 Self._Config := Config; 1678 Self._Config := Config;
1645 end; 1679 end;