echogarden 2.10.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (595) hide show
  1. package/LICENSE.MIT.md +7 -0
  2. package/README.md +9 -1
  3. package/data/lexicons/heteronyms.en.json +44 -10
  4. package/data/lexicons/words.en.json +726 -22
  5. package/data/schemas/options.json +91 -153
  6. package/dist/alignment/DTWMfccSequenceAlignment.d.ts +1 -0
  7. package/dist/alignment/DTWMfccSequenceAlignment.d.ts.map +1 -0
  8. package/dist/alignment/DTWMfccSequenceAlignment.js.map +1 -1
  9. package/dist/alignment/DTWSequenceAlignment.d.ts +1 -0
  10. package/dist/alignment/DTWSequenceAlignment.d.ts.map +1 -0
  11. package/dist/alignment/DTWSequenceAlignmentWindowed.d.ts +1 -0
  12. package/dist/alignment/DTWSequenceAlignmentWindowed.d.ts.map +1 -0
  13. package/dist/alignment/LevenshteinSequenceAlignment.d.ts +1 -0
  14. package/dist/alignment/LevenshteinSequenceAlignment.d.ts.map +1 -0
  15. package/dist/alignment/SemanticTextAlignment.d.ts +5 -2
  16. package/dist/alignment/SemanticTextAlignment.d.ts.map +1 -0
  17. package/dist/alignment/SemanticTextAlignment.js +7 -7
  18. package/dist/alignment/SemanticTextAlignment.js.map +1 -1
  19. package/dist/alignment/SpeechAlignment.d.ts +10 -10
  20. package/dist/alignment/SpeechAlignment.d.ts.map +1 -0
  21. package/dist/alignment/SpeechAlignment.js +23 -96
  22. package/dist/alignment/SpeechAlignment.js.map +1 -1
  23. package/dist/api/API.d.ts +1 -0
  24. package/dist/api/API.d.ts.map +1 -0
  25. package/dist/api/APIOptions.d.ts +2 -1
  26. package/dist/api/APIOptions.d.ts.map +1 -0
  27. package/dist/api/Alignment.d.ts +9 -6
  28. package/dist/api/Alignment.d.ts.map +1 -0
  29. package/dist/api/Alignment.js +31 -40
  30. package/dist/api/Alignment.js.map +1 -1
  31. package/dist/api/Common.d.ts +8 -0
  32. package/dist/api/Common.d.ts.map +1 -0
  33. package/dist/api/Common.js.map +1 -1
  34. package/dist/api/Denoising.d.ts +6 -2
  35. package/dist/api/Denoising.d.ts.map +1 -0
  36. package/dist/api/Denoising.js +15 -15
  37. package/dist/api/Denoising.js.map +1 -1
  38. package/dist/api/GlobalOptions.d.ts +3 -8
  39. package/dist/api/GlobalOptions.d.ts.map +1 -0
  40. package/dist/api/GlobalOptions.js +2 -13
  41. package/dist/api/GlobalOptions.js.map +1 -1
  42. package/dist/api/LanguageDetectionCommon.d.ts +1 -0
  43. package/dist/api/LanguageDetectionCommon.d.ts.map +1 -0
  44. package/dist/api/Recognition.d.ts +12 -12
  45. package/dist/api/Recognition.d.ts.map +1 -0
  46. package/dist/api/Recognition.js +32 -82
  47. package/dist/api/Recognition.js.map +1 -1
  48. package/dist/api/SourceSeparation.d.ts +8 -2
  49. package/dist/api/SourceSeparation.d.ts.map +1 -0
  50. package/dist/api/SourceSeparation.js +12 -10
  51. package/dist/api/SourceSeparation.js.map +1 -1
  52. package/dist/api/SpeechLanguageDetection.d.ts +12 -7
  53. package/dist/api/SpeechLanguageDetection.d.ts.map +1 -0
  54. package/dist/api/SpeechLanguageDetection.js +37 -30
  55. package/dist/api/SpeechLanguageDetection.js.map +1 -1
  56. package/dist/api/SpeechSearch.d.ts +5 -1
  57. package/dist/api/SpeechSearch.d.ts.map +1 -0
  58. package/dist/api/SpeechSearch.js.map +1 -1
  59. package/dist/api/SpeechTranslation.d.ts +11 -6
  60. package/dist/api/SpeechTranslation.d.ts.map +1 -0
  61. package/dist/api/SpeechTranslation.js +28 -26
  62. package/dist/api/SpeechTranslation.js.map +1 -1
  63. package/dist/api/Synthesis.d.ts +14 -8
  64. package/dist/api/Synthesis.d.ts.map +1 -0
  65. package/dist/api/Synthesis.js +67 -89
  66. package/dist/api/Synthesis.js.map +1 -1
  67. package/dist/api/TextLanguageDetection.d.ts +5 -2
  68. package/dist/api/TextLanguageDetection.d.ts.map +1 -0
  69. package/dist/api/TextLanguageDetection.js +4 -7
  70. package/dist/api/TextLanguageDetection.js.map +1 -1
  71. package/dist/api/TextTranslation.d.ts +5 -2
  72. package/dist/api/TextTranslation.d.ts.map +1 -0
  73. package/dist/api/TextTranslation.js +13 -24
  74. package/dist/api/TextTranslation.js.map +1 -1
  75. package/dist/api/TimelineTranslationAlignment.d.ts +7 -3
  76. package/dist/api/TimelineTranslationAlignment.d.ts.map +1 -0
  77. package/dist/api/TimelineTranslationAlignment.js +20 -11
  78. package/dist/api/TimelineTranslationAlignment.js.map +1 -1
  79. package/dist/api/TranscriptAndTranslationAlignment.d.ts +7 -4
  80. package/dist/api/TranscriptAndTranslationAlignment.d.ts.map +1 -0
  81. package/dist/api/TranscriptAndTranslationAlignment.js +11 -12
  82. package/dist/api/TranscriptAndTranslationAlignment.js.map +1 -1
  83. package/dist/api/TranslationAlignment.d.ts +7 -4
  84. package/dist/api/TranslationAlignment.d.ts.map +1 -0
  85. package/dist/api/TranslationAlignment.js +20 -21
  86. package/dist/api/TranslationAlignment.js.map +1 -1
  87. package/dist/api/VoiceActivityDetection.d.ts +10 -8
  88. package/dist/api/VoiceActivityDetection.d.ts.map +1 -0
  89. package/dist/api/VoiceActivityDetection.js +20 -43
  90. package/dist/api/VoiceActivityDetection.js.map +1 -1
  91. package/dist/audio/AudioBufferConversion.d.ts +1 -0
  92. package/dist/audio/AudioBufferConversion.d.ts.map +1 -0
  93. package/dist/audio/AudioBufferConversion.js.map +1 -1
  94. package/dist/audio/AudioPlayer.d.ts +2 -3
  95. package/dist/audio/AudioPlayer.d.ts.map +1 -0
  96. package/dist/audio/AudioPlayer.js +3 -188
  97. package/dist/audio/AudioPlayer.js.map +1 -1
  98. package/dist/audio/AudioUtilities.d.ts +3 -1
  99. package/dist/audio/AudioUtilities.d.ts.map +1 -0
  100. package/dist/audio/AudioUtilities.js +2 -2
  101. package/dist/audio/AudioUtilities.js.map +1 -1
  102. package/dist/build-tools/MakeTarballsForInstalledPackages.d.ts +1 -0
  103. package/dist/build-tools/MakeTarballsForInstalledPackages.d.ts.map +1 -0
  104. package/dist/build-tools/MakeTarballsForInstalledPackages.js +3 -3
  105. package/dist/build-tools/MakeTarballsForInstalledPackages.js.map +1 -1
  106. package/dist/cli/CLI.d.ts +1 -0
  107. package/dist/cli/CLI.d.ts.map +1 -0
  108. package/dist/cli/CLI.js +139 -92
  109. package/dist/cli/CLI.js.map +1 -1
  110. package/dist/cli/CLIConfigFile.d.ts +1 -0
  111. package/dist/cli/CLIConfigFile.d.ts.map +1 -0
  112. package/dist/cli/CLILauncher.d.ts +1 -0
  113. package/dist/cli/CLILauncher.d.ts.map +1 -0
  114. package/dist/cli/CLIOptions.d.ts +1 -0
  115. package/dist/cli/CLIOptions.d.ts.map +1 -0
  116. package/dist/cli/CLIOptionsSchema.d.ts +1 -0
  117. package/dist/cli/CLIOptionsSchema.d.ts.map +1 -0
  118. package/dist/cli/CLIParser.d.ts +1 -0
  119. package/dist/cli/CLIParser.d.ts.map +1 -0
  120. package/dist/cli/CLIStarter.d.ts +1 -0
  121. package/dist/cli/CLIStarter.d.ts.map +1 -0
  122. package/dist/codecs/FFMpegTranscoder.d.ts +5 -3
  123. package/dist/codecs/FFMpegTranscoder.d.ts.map +1 -0
  124. package/dist/codecs/FFMpegTranscoder.js +16 -14
  125. package/dist/codecs/FFMpegTranscoder.js.map +1 -1
  126. package/dist/codecs/TIMITCodec.d.ts +1 -0
  127. package/dist/codecs/TIMITCodec.d.ts.map +1 -0
  128. package/dist/data-structures/DynamicTypedArray.d.ts +1 -0
  129. package/dist/data-structures/DynamicTypedArray.d.ts.map +1 -0
  130. package/dist/data-structures/DynamicTypedArray.js.map +1 -1
  131. package/dist/data-structures/Queue.d.ts +1 -0
  132. package/dist/data-structures/Queue.d.ts.map +1 -0
  133. package/dist/data-structures/WindowedList.d.ts +1 -0
  134. package/dist/data-structures/WindowedList.d.ts.map +1 -0
  135. package/dist/data-structures/WindowedList.js.map +1 -1
  136. package/dist/denoising/NSNet2.d.ts +4 -2
  137. package/dist/denoising/NSNet2.d.ts.map +1 -0
  138. package/dist/denoising/NSNet2.js +4 -4
  139. package/dist/denoising/NSNet2.js.map +1 -1
  140. package/dist/denoising/RNNoise.d.ts +3 -1
  141. package/dist/denoising/RNNoise.d.ts.map +1 -0
  142. package/dist/denoising/RNNoise.js +10 -6
  143. package/dist/denoising/RNNoise.js.map +1 -1
  144. package/dist/dsp/BiquadFilter.d.ts +1 -0
  145. package/dist/dsp/BiquadFilter.d.ts.map +1 -0
  146. package/dist/dsp/DecayingPeakEstimator.d.ts +1 -0
  147. package/dist/dsp/DecayingPeakEstimator.d.ts.map +1 -0
  148. package/dist/dsp/DecayingPeakEstimator.js.map +1 -1
  149. package/dist/dsp/FFT.d.ts +1 -0
  150. package/dist/dsp/FFT.d.ts.map +1 -0
  151. package/dist/dsp/FFT.js +2 -1
  152. package/dist/dsp/FFT.js.map +1 -1
  153. package/dist/dsp/KWeightingFilter.d.ts +1 -0
  154. package/dist/dsp/KWeightingFilter.d.ts.map +1 -0
  155. package/dist/dsp/KWeightingFilter.js.map +1 -1
  156. package/dist/dsp/LoudnessEstimator.d.ts +1 -0
  157. package/dist/dsp/LoudnessEstimator.d.ts.map +1 -0
  158. package/dist/dsp/LoudnessEstimator.js.map +1 -1
  159. package/dist/dsp/MFCC.d.ts +4 -2
  160. package/dist/dsp/MFCC.d.ts.map +1 -0
  161. package/dist/dsp/MFCC.js +4 -4
  162. package/dist/dsp/MFCC.js.map +1 -1
  163. package/dist/dsp/MelSpectrogram.d.ts +11 -8
  164. package/dist/dsp/MelSpectrogram.d.ts.map +1 -0
  165. package/dist/dsp/MelSpectrogram.js +31 -34
  166. package/dist/dsp/MelSpectrogram.js.map +1 -1
  167. package/dist/dsp/Rubberband.d.ts +1 -0
  168. package/dist/dsp/Rubberband.d.ts.map +1 -0
  169. package/dist/dsp/Rubberband.js +8 -3
  170. package/dist/dsp/Rubberband.js.map +1 -1
  171. package/dist/dsp/Sonic.d.ts +1 -0
  172. package/dist/dsp/Sonic.d.ts.map +1 -0
  173. package/dist/dsp/Sonic.js +1 -1
  174. package/dist/dsp/Sonic.js.map +1 -1
  175. package/dist/dsp/SpeexResampler.d.ts +1 -0
  176. package/dist/dsp/SpeexResampler.d.ts.map +1 -0
  177. package/dist/dsp/SpeexResampler.js +1 -1
  178. package/dist/dsp/SpeexResampler.js.map +1 -1
  179. package/dist/encodings/Ascii.d.ts +2 -1
  180. package/dist/encodings/Ascii.d.ts.map +1 -0
  181. package/dist/encodings/Base64.d.ts +1 -0
  182. package/dist/encodings/Base64.d.ts.map +1 -0
  183. package/dist/encodings/Base64.js.map +1 -1
  184. package/dist/encodings/Hex.d.ts +1 -0
  185. package/dist/encodings/Hex.d.ts.map +1 -0
  186. package/dist/encodings/HtmlEscape.d.ts +1 -0
  187. package/dist/encodings/HtmlEscape.d.ts.map +1 -0
  188. package/dist/encodings/LEB128.d.ts +1 -0
  189. package/dist/encodings/LEB128.d.ts.map +1 -0
  190. package/dist/encodings/TextEncodingsCommon.d.ts +1 -0
  191. package/dist/encodings/TextEncodingsCommon.d.ts.map +1 -0
  192. package/dist/encodings/Utf16.d.ts +1 -0
  193. package/dist/encodings/Utf16.d.ts.map +1 -0
  194. package/dist/encodings/Utf32.d.ts +1 -0
  195. package/dist/encodings/Utf32.d.ts.map +1 -0
  196. package/dist/encodings/Utf8.d.ts +1 -0
  197. package/dist/encodings/Utf8.d.ts.map +1 -0
  198. package/dist/math/MedianFilter.d.ts +1 -0
  199. package/dist/math/MedianFilter.d.ts.map +1 -0
  200. package/dist/math/VectorMath.d.ts +2 -0
  201. package/dist/math/VectorMath.d.ts.map +1 -0
  202. package/dist/math/VectorMath.js +9 -5
  203. package/dist/math/VectorMath.js.map +1 -1
  204. package/dist/nlp/ChineseSegmentation.d.ts +2 -1
  205. package/dist/nlp/ChineseSegmentation.d.ts.map +1 -0
  206. package/dist/nlp/EspeakPhonemizer.d.ts +2 -1
  207. package/dist/nlp/EspeakPhonemizer.d.ts.map +1 -0
  208. package/dist/nlp/EspeakPhonemizer.js +2 -2
  209. package/dist/nlp/EspeakPhonemizer.js.map +1 -1
  210. package/dist/nlp/IPA.d.ts +3 -2
  211. package/dist/nlp/IPA.d.ts.map +1 -0
  212. package/dist/nlp/JapaneseSegmentation.d.ts +1 -0
  213. package/dist/nlp/JapaneseSegmentation.d.ts.map +1 -0
  214. package/dist/nlp/Lexicon.d.ts +1 -0
  215. package/dist/nlp/Lexicon.d.ts.map +1 -0
  216. package/dist/nlp/PhoneConversion.d.ts +1 -0
  217. package/dist/nlp/PhoneConversion.d.ts.map +1 -0
  218. package/dist/nlp/Segmentation.d.ts +2 -1
  219. package/dist/nlp/Segmentation.d.ts.map +1 -0
  220. package/dist/nlp/Segmentation.js +8 -4
  221. package/dist/nlp/Segmentation.js.map +1 -1
  222. package/dist/nlp/TextNormalizer.d.ts +1 -0
  223. package/dist/nlp/TextNormalizer.d.ts.map +1 -0
  224. package/dist/recognition/AmazonTranscribeSTT.d.ts +3 -1
  225. package/dist/recognition/AmazonTranscribeSTT.d.ts.map +1 -0
  226. package/dist/recognition/AmazonTranscribeSTT.js +3 -3
  227. package/dist/recognition/AmazonTranscribeSTT.js.map +1 -1
  228. package/dist/recognition/AzureCognitiveServicesSTT.d.ts +3 -1
  229. package/dist/recognition/AzureCognitiveServicesSTT.d.ts.map +1 -0
  230. package/dist/recognition/AzureCognitiveServicesSTT.js +4 -4
  231. package/dist/recognition/AzureCognitiveServicesSTT.js.map +1 -1
  232. package/dist/recognition/DeepgramSTT.d.ts +3 -1
  233. package/dist/recognition/DeepgramSTT.d.ts.map +1 -0
  234. package/dist/recognition/DeepgramSTT.js +12 -13
  235. package/dist/recognition/DeepgramSTT.js.map +1 -1
  236. package/dist/recognition/GoogleCloudSTT.d.ts +3 -1
  237. package/dist/recognition/GoogleCloudSTT.d.ts.map +1 -0
  238. package/dist/recognition/GoogleCloudSTT.js +11 -10
  239. package/dist/recognition/GoogleCloudSTT.js.map +1 -1
  240. package/dist/recognition/OpenAICloudSTT.d.ts +3 -1
  241. package/dist/recognition/OpenAICloudSTT.d.ts.map +1 -0
  242. package/dist/recognition/OpenAICloudSTT.js +6 -6
  243. package/dist/recognition/OpenAICloudSTT.js.map +1 -1
  244. package/dist/recognition/WhisperCommon.d.ts +9 -0
  245. package/dist/recognition/WhisperCommon.d.ts.map +1 -0
  246. package/dist/recognition/WhisperCommon.js +52 -0
  247. package/dist/recognition/WhisperCommon.js.map +1 -0
  248. package/dist/recognition/{WhisperCppSTT.d.ts → WhisperCppCliSTT.d.ts} +14 -15
  249. package/dist/recognition/WhisperCppCliSTT.d.ts.map +1 -0
  250. package/dist/recognition/{WhisperCppSTT.js → WhisperCppCliSTT.js} +55 -84
  251. package/dist/recognition/WhisperCppCliSTT.js.map +1 -0
  252. package/dist/recognition/WhisperSTT.d.ts +73 -85
  253. package/dist/recognition/WhisperSTT.d.ts.map +1 -0
  254. package/dist/recognition/WhisperSTT.js +384 -519
  255. package/dist/recognition/WhisperSTT.js.map +1 -1
  256. package/dist/server/Client.d.ts +3 -2
  257. package/dist/server/Client.d.ts.map +1 -0
  258. package/dist/server/Client.js.map +1 -1
  259. package/dist/server/Server.d.ts +1 -0
  260. package/dist/server/Server.d.ts.map +1 -0
  261. package/dist/server/ServerStarter.d.ts +1 -0
  262. package/dist/server/ServerStarter.d.ts.map +1 -0
  263. package/dist/server/Worker.d.ts +7 -7
  264. package/dist/server/Worker.d.ts.map +1 -0
  265. package/dist/server/Worker.js +42 -44
  266. package/dist/server/Worker.js.map +1 -1
  267. package/dist/server/WorkerStarter.d.ts +1 -0
  268. package/dist/server/WorkerStarter.d.ts.map +1 -0
  269. package/dist/source-separation/MDXNetSourceSeparation.d.ts +4 -2
  270. package/dist/source-separation/MDXNetSourceSeparation.d.ts.map +1 -0
  271. package/dist/source-separation/MDXNetSourceSeparation.js +10 -8
  272. package/dist/source-separation/MDXNetSourceSeparation.js.map +1 -1
  273. package/dist/speech-embeddings/WavToVec2BertFeatureEmbeddings.d.ts +4 -2
  274. package/dist/speech-embeddings/WavToVec2BertFeatureEmbeddings.d.ts.map +1 -0
  275. package/dist/speech-embeddings/WavToVec2BertFeatureEmbeddings.js +5 -5
  276. package/dist/speech-embeddings/WavToVec2BertFeatureEmbeddings.js.map +1 -1
  277. package/dist/speech-language-detection/SileroLanguageDetection.d.ts +6 -3
  278. package/dist/speech-language-detection/SileroLanguageDetection.d.ts.map +1 -0
  279. package/dist/speech-language-detection/SileroLanguageDetection.js +8 -8
  280. package/dist/speech-language-detection/SileroLanguageDetection.js.map +1 -1
  281. package/dist/speech-search/DTWSpeechSearch.d.ts +3 -1
  282. package/dist/speech-search/DTWSpeechSearch.d.ts.map +1 -0
  283. package/dist/speech-search/DTWSpeechSearch.js +4 -4
  284. package/dist/speech-search/DTWSpeechSearch.js.map +1 -1
  285. package/dist/subtitles/Subtitles.d.ts +14 -1
  286. package/dist/subtitles/Subtitles.d.ts.map +1 -0
  287. package/dist/subtitles/Subtitles.js +22 -22
  288. package/dist/subtitles/Subtitles.js.map +1 -1
  289. package/dist/synthesis/AwsPollyTTS.d.ts +4 -2
  290. package/dist/synthesis/AwsPollyTTS.d.ts.map +1 -0
  291. package/dist/synthesis/AwsPollyTTS.js +5 -5
  292. package/dist/synthesis/AwsPollyTTS.js.map +1 -1
  293. package/dist/synthesis/AzureCognitiveServicesTTS.d.ts +3 -1
  294. package/dist/synthesis/AzureCognitiveServicesTTS.d.ts.map +1 -0
  295. package/dist/synthesis/AzureCognitiveServicesTTS.js +3 -3
  296. package/dist/synthesis/AzureCognitiveServicesTTS.js.map +1 -1
  297. package/dist/synthesis/CoquiServerTTS.d.ts +3 -1
  298. package/dist/synthesis/CoquiServerTTS.d.ts.map +1 -0
  299. package/dist/synthesis/CoquiServerTTS.js +7 -8
  300. package/dist/synthesis/CoquiServerTTS.js.map +1 -1
  301. package/dist/synthesis/DeepgramTTS.d.ts +3 -2
  302. package/dist/synthesis/DeepgramTTS.d.ts.map +1 -0
  303. package/dist/synthesis/DeepgramTTS.js +13 -13
  304. package/dist/synthesis/DeepgramTTS.js.map +1 -1
  305. package/dist/synthesis/ElevenLabsTTS.d.ts +4 -3
  306. package/dist/synthesis/ElevenLabsTTS.d.ts.map +1 -0
  307. package/dist/synthesis/ElevenLabsTTS.js +22 -21
  308. package/dist/synthesis/ElevenLabsTTS.js.map +1 -1
  309. package/dist/synthesis/EspeakTTS.d.ts +12 -9
  310. package/dist/synthesis/EspeakTTS.d.ts.map +1 -0
  311. package/dist/synthesis/EspeakTTS.js +118 -68
  312. package/dist/synthesis/EspeakTTS.js.map +1 -1
  313. package/dist/synthesis/FliteTTS.d.ts +3 -2
  314. package/dist/synthesis/FliteTTS.d.ts.map +1 -0
  315. package/dist/synthesis/FliteTTS.js +2 -2
  316. package/dist/synthesis/FliteTTS.js.map +1 -1
  317. package/dist/synthesis/GnuSpeechTTS.d.ts +3 -2
  318. package/dist/synthesis/GnuSpeechTTS.d.ts.map +1 -0
  319. package/dist/synthesis/GnuSpeechTTS.js +1 -1
  320. package/dist/synthesis/GnuSpeechTTS.js.map +1 -1
  321. package/dist/synthesis/GoogleCloudTTS.d.ts +4 -2
  322. package/dist/synthesis/GoogleCloudTTS.d.ts.map +1 -0
  323. package/dist/synthesis/GoogleCloudTTS.js +15 -14
  324. package/dist/synthesis/GoogleCloudTTS.js.map +1 -1
  325. package/dist/synthesis/GoogleTranslateTTS.d.ts +4 -2
  326. package/dist/synthesis/GoogleTranslateTTS.d.ts.map +1 -0
  327. package/dist/synthesis/GoogleTranslateTTS.js +11 -11
  328. package/dist/synthesis/GoogleTranslateTTS.js.map +1 -1
  329. package/dist/synthesis/KokoroTTS.d.ts +5 -4
  330. package/dist/synthesis/KokoroTTS.d.ts.map +1 -0
  331. package/dist/synthesis/KokoroTTS.js +11 -10
  332. package/dist/synthesis/KokoroTTS.js.map +1 -1
  333. package/dist/synthesis/MicrosoftEdgeTTS.d.ts +5 -3
  334. package/dist/synthesis/MicrosoftEdgeTTS.d.ts.map +1 -0
  335. package/dist/synthesis/MicrosoftEdgeTTS.js +41 -20
  336. package/dist/synthesis/MicrosoftEdgeTTS.js.map +1 -1
  337. package/dist/synthesis/OpenAICloudTTS.d.ts +3 -2
  338. package/dist/synthesis/OpenAICloudTTS.d.ts.map +1 -0
  339. package/dist/synthesis/OpenAICloudTTS.js +6 -5
  340. package/dist/synthesis/OpenAICloudTTS.js.map +1 -1
  341. package/dist/synthesis/SamTTS.d.ts +3 -1
  342. package/dist/synthesis/SamTTS.d.ts.map +1 -0
  343. package/dist/synthesis/SamTTS.js +2 -2
  344. package/dist/synthesis/SamTTS.js.map +1 -1
  345. package/dist/synthesis/SapiTTS.d.ts +3 -2
  346. package/dist/synthesis/SapiTTS.d.ts.map +1 -0
  347. package/dist/synthesis/SapiTTS.js +2 -2
  348. package/dist/synthesis/SapiTTS.js.map +1 -1
  349. package/dist/synthesis/SvoxPicoTTS.d.ts +3 -2
  350. package/dist/synthesis/SvoxPicoTTS.d.ts.map +1 -0
  351. package/dist/synthesis/SvoxPicoTTS.js +3 -3
  352. package/dist/synthesis/SvoxPicoTTS.js.map +1 -1
  353. package/dist/synthesis/VitsTTS.d.ts +4 -3
  354. package/dist/synthesis/VitsTTS.d.ts.map +1 -0
  355. package/dist/synthesis/VitsTTS.js +14 -11
  356. package/dist/synthesis/VitsTTS.js.map +1 -1
  357. package/dist/tests/Test.d.ts +1 -0
  358. package/dist/tests/Test.d.ts.map +1 -0
  359. package/dist/text-language-detection/FastTextLanguageDetection.d.ts +1 -0
  360. package/dist/text-language-detection/FastTextLanguageDetection.d.ts.map +1 -0
  361. package/dist/text-language-detection/TinyLDLanguageDetection.d.ts +1 -0
  362. package/dist/text-language-detection/TinyLDLanguageDetection.d.ts.map +1 -0
  363. package/dist/text-translation/DeepLTextTranslation.d.ts +3 -2
  364. package/dist/text-translation/DeepLTextTranslation.d.ts.map +1 -0
  365. package/dist/text-translation/DeepLTextTranslation.js +10 -9
  366. package/dist/text-translation/DeepLTextTranslation.js.map +1 -1
  367. package/dist/text-translation/GoogleTranslateTextTranslation.d.ts +5 -4
  368. package/dist/text-translation/GoogleTranslateTextTranslation.d.ts.map +1 -0
  369. package/dist/text-translation/GoogleTranslateTextTranslation.js +20 -18
  370. package/dist/text-translation/GoogleTranslateTextTranslation.js.map +1 -1
  371. package/dist/text-translation/NLLBTextTranslation.d.ts +3 -2
  372. package/dist/text-translation/NLLBTextTranslation.d.ts.map +1 -0
  373. package/dist/text-translation/NLLBTextTranslation.js +4 -6
  374. package/dist/text-translation/NLLBTextTranslation.js.map +1 -1
  375. package/dist/typings/TypedArray.d.ts +1 -0
  376. package/dist/typings/TypedArray.d.ts.map +1 -0
  377. package/dist/utilities/BrowserRequestHeaders.d.ts +1 -0
  378. package/dist/utilities/BrowserRequestHeaders.d.ts.map +1 -0
  379. package/dist/utilities/Compression.d.ts +5 -3
  380. package/dist/utilities/Compression.d.ts.map +1 -0
  381. package/dist/utilities/Compression.js +9 -9
  382. package/dist/utilities/Compression.js.map +1 -1
  383. package/dist/utilities/FileDownloader.d.ts +7 -3
  384. package/dist/utilities/FileDownloader.d.ts.map +1 -0
  385. package/dist/utilities/FileDownloader.js +25 -21
  386. package/dist/utilities/FileDownloader.js.map +1 -1
  387. package/dist/utilities/FileReader.d.ts +1 -0
  388. package/dist/utilities/FileReader.d.ts.map +1 -0
  389. package/dist/utilities/FileReader.js.map +1 -1
  390. package/dist/utilities/FileSystem.d.ts +1 -0
  391. package/dist/utilities/FileSystem.d.ts.map +1 -0
  392. package/dist/utilities/FileSystem.js +1 -1
  393. package/dist/utilities/FileSystem.js.map +1 -1
  394. package/dist/utilities/FileWriter.d.ts +1 -0
  395. package/dist/utilities/FileWriter.d.ts.map +1 -0
  396. package/dist/utilities/FileWriter.js.map +1 -1
  397. package/dist/utilities/Hashing.d.ts +1 -0
  398. package/dist/utilities/Hashing.d.ts.map +1 -0
  399. package/dist/utilities/Hashing.js.map +1 -1
  400. package/dist/utilities/Locale.d.ts +1 -0
  401. package/dist/utilities/Locale.d.ts.map +1 -0
  402. package/dist/utilities/Locale.js.map +1 -1
  403. package/dist/utilities/Logger.d.ts +18 -9
  404. package/dist/utilities/Logger.d.ts.map +1 -0
  405. package/dist/utilities/Logger.js +50 -35
  406. package/dist/utilities/Logger.js.map +1 -1
  407. package/dist/utilities/NpmUtilities.d.ts +1 -0
  408. package/dist/utilities/NpmUtilities.d.ts.map +1 -0
  409. package/dist/utilities/NpmUtilities.js +4 -5
  410. package/dist/utilities/NpmUtilities.js.map +1 -1
  411. package/dist/utilities/ObjectUtilities.d.ts +1 -0
  412. package/dist/utilities/ObjectUtilities.d.ts.map +1 -0
  413. package/dist/utilities/ObjectUtilities.js.map +1 -1
  414. package/dist/utilities/OnnxUtilities.d.ts +1 -0
  415. package/dist/utilities/OnnxUtilities.d.ts.map +1 -0
  416. package/dist/utilities/OpenPromise.d.ts +1 -0
  417. package/dist/utilities/OpenPromise.d.ts.map +1 -0
  418. package/dist/utilities/OpenPromise.js.map +1 -1
  419. package/dist/utilities/PackageManager.d.ts +5 -1
  420. package/dist/utilities/PackageManager.d.ts.map +1 -0
  421. package/dist/utilities/PackageManager.js +37 -22
  422. package/dist/utilities/PackageManager.js.map +1 -1
  423. package/dist/utilities/PathUtilities.d.ts +3 -0
  424. package/dist/utilities/PathUtilities.d.ts.map +1 -0
  425. package/dist/utilities/PathUtilities.js +5 -2
  426. package/dist/utilities/PathUtilities.js.map +1 -1
  427. package/dist/utilities/RandomGenerator.d.ts +1 -0
  428. package/dist/utilities/RandomGenerator.d.ts.map +1 -0
  429. package/dist/utilities/SignalChannel.d.ts +1 -0
  430. package/dist/utilities/SignalChannel.d.ts.map +1 -0
  431. package/dist/utilities/SmoothEstimator.d.ts +1 -0
  432. package/dist/utilities/SmoothEstimator.d.ts.map +1 -0
  433. package/dist/utilities/SmoothEstimator.js.map +1 -1
  434. package/dist/utilities/StringBuilder.d.ts +1 -0
  435. package/dist/utilities/StringBuilder.d.ts.map +1 -0
  436. package/dist/utilities/StringUtilities.d.ts +1 -0
  437. package/dist/utilities/StringUtilities.d.ts.map +1 -0
  438. package/dist/utilities/TarballMaker.d.ts +5 -3
  439. package/dist/utilities/TarballMaker.d.ts.map +1 -0
  440. package/dist/utilities/TarballMaker.js +6 -6
  441. package/dist/utilities/TarballMaker.js.map +1 -1
  442. package/dist/utilities/Timeline.d.ts +1 -0
  443. package/dist/utilities/Timeline.d.ts.map +1 -0
  444. package/dist/utilities/Timeline.js.map +1 -1
  445. package/dist/utilities/Timer.d.ts +1 -0
  446. package/dist/utilities/Timer.d.ts.map +1 -0
  447. package/dist/utilities/Utilities.d.ts +10 -7
  448. package/dist/utilities/Utilities.d.ts.map +1 -0
  449. package/dist/utilities/Utilities.js +49 -31
  450. package/dist/utilities/Utilities.js.map +1 -1
  451. package/dist/utilities/VirtualFileReadStream.d.ts +1 -0
  452. package/dist/utilities/VirtualFileReadStream.d.ts.map +1 -0
  453. package/dist/utilities/WebReader.d.ts +3 -1
  454. package/dist/utilities/WebReader.d.ts.map +1 -0
  455. package/dist/utilities/WebReader.js +7 -6
  456. package/dist/utilities/WebReader.js.map +1 -1
  457. package/dist/utilities/WikipediaReader.d.ts +3 -1
  458. package/dist/utilities/WikipediaReader.d.ts.map +1 -0
  459. package/dist/utilities/WikipediaReader.js +1 -5
  460. package/dist/utilities/WikipediaReader.js.map +1 -1
  461. package/dist/voice-activity-detection/AdaptiveGateVAD.d.ts +3 -1
  462. package/dist/voice-activity-detection/AdaptiveGateVAD.d.ts.map +1 -0
  463. package/dist/voice-activity-detection/AdaptiveGateVAD.js +1 -1
  464. package/dist/voice-activity-detection/AdaptiveGateVAD.js.map +1 -1
  465. package/dist/voice-activity-detection/SileroVAD.d.ts +1 -0
  466. package/dist/voice-activity-detection/SileroVAD.d.ts.map +1 -0
  467. package/dist/voice-activity-detection/SileroVAD.js.map +1 -1
  468. package/dist/voice-activity-detection/WebRtcVAD.d.ts +1 -0
  469. package/dist/voice-activity-detection/WebRtcVAD.d.ts.map +1 -0
  470. package/dist/voice-activity-detection/WebRtcVAD.js +1 -1
  471. package/dist/voice-activity-detection/WebRtcVAD.js.map +1 -1
  472. package/docs/API.md +62 -17
  473. package/docs/CUDA.md +4 -3
  474. package/docs/Engines.md +8 -7
  475. package/docs/Licenses.md +0 -3
  476. package/docs/Options.md +27 -31
  477. package/docs/Server.md +1 -0
  478. package/docs/Tasklist.md +2 -1
  479. package/docs/Technical.md +2 -2
  480. package/package.json +45 -35
  481. package/src/alignment/SemanticTextAlignment.ts +14 -7
  482. package/src/alignment/SpeechAlignment.ts +47 -150
  483. package/src/api/APIOptions.ts +1 -1
  484. package/src/api/Alignment.ts +95 -61
  485. package/src/api/Common.ts +11 -0
  486. package/src/api/Denoising.ts +22 -17
  487. package/src/api/GlobalOptions.ts +4 -20
  488. package/src/api/Recognition.ts +106 -123
  489. package/src/api/SourceSeparation.ts +39 -21
  490. package/src/api/SpeechLanguageDetection.ts +77 -37
  491. package/src/api/SpeechSearch.ts +6 -1
  492. package/src/api/SpeechTranslation.ts +75 -38
  493. package/src/api/Synthesis.ts +220 -116
  494. package/src/api/TextLanguageDetection.ts +10 -12
  495. package/src/api/TextTranslation.ts +43 -26
  496. package/src/api/TimelineTranslationAlignment.ts +41 -13
  497. package/src/api/TranscriptAndTranslationAlignment.ts +28 -15
  498. package/src/api/TranslationAlignment.ts +53 -24
  499. package/src/api/VoiceActivityDetection.ts +33 -68
  500. package/src/audio/AudioPlayer.ts +4 -232
  501. package/src/audio/AudioUtilities.ts +9 -2
  502. package/src/build-tools/MakeTarballsForInstalledPackages.ts +4 -3
  503. package/src/cli/CLI.ts +209 -101
  504. package/src/codecs/FFMpegTranscoder.ts +18 -16
  505. package/src/denoising/NSNet2.ts +5 -4
  506. package/src/denoising/RNNoise.ts +14 -6
  507. package/src/dsp/FFT.ts +2 -1
  508. package/src/dsp/MFCC.ts +7 -5
  509. package/src/dsp/MelSpectrogram.ts +56 -36
  510. package/src/dsp/Rubberband.ts +10 -3
  511. package/src/dsp/Sonic.ts +2 -1
  512. package/src/dsp/SpeexResampler.ts +2 -1
  513. package/src/encodings/Ascii.ts +1 -1
  514. package/src/encodings/Base64.ts +1 -1
  515. package/src/math/VectorMath.ts +10 -6
  516. package/src/nlp/EspeakPhonemizer.ts +2 -2
  517. package/src/nlp/Segmentation.ts +9 -4
  518. package/src/recognition/AmazonTranscribeSTT.ts +4 -3
  519. package/src/recognition/AzureCognitiveServicesSTT.ts +5 -4
  520. package/src/recognition/DeepgramSTT.ts +16 -16
  521. package/src/recognition/GoogleCloudSTT.ts +14 -12
  522. package/src/recognition/OpenAICloudSTT.ts +12 -6
  523. package/src/recognition/WhisperCommon.ts +130 -0
  524. package/src/recognition/{WhisperCppSTT.ts → WhisperCppCliSTT.ts} +73 -133
  525. package/src/recognition/WhisperSTT.ts +569 -718
  526. package/src/server/Client.ts +4 -4
  527. package/src/server/Worker.ts +59 -59
  528. package/src/source-separation/MDXNetSourceSeparation.ts +15 -10
  529. package/src/speech-embeddings/WavToVec2BertFeatureEmbeddings.ts +7 -5
  530. package/src/speech-language-detection/SileroLanguageDetection.ts +18 -9
  531. package/src/speech-search/DTWSpeechSearch.ts +6 -5
  532. package/src/subtitles/Subtitles.ts +22 -22
  533. package/src/synthesis/AwsPollyTTS.ts +12 -5
  534. package/src/synthesis/AzureCognitiveServicesTTS.ts +11 -3
  535. package/src/synthesis/CoquiServerTTS.ts +8 -7
  536. package/src/synthesis/DeepgramTTS.ts +21 -15
  537. package/src/synthesis/ElevenLabsTTS.ts +33 -23
  538. package/src/synthesis/EspeakTTS.ts +145 -69
  539. package/src/synthesis/FliteTTS.ts +3 -3
  540. package/src/synthesis/GnuSpeechTTS.ts +2 -2
  541. package/src/synthesis/GoogleCloudTTS.ts +23 -14
  542. package/src/synthesis/GoogleTranslateTTS.ts +19 -11
  543. package/src/synthesis/KokoroTTS.ts +37 -14
  544. package/src/synthesis/MicrosoftEdgeTTS.ts +71 -23
  545. package/src/synthesis/OpenAICloudTTS.ts +7 -6
  546. package/src/synthesis/SamTTS.ts +3 -2
  547. package/src/synthesis/SapiTTS.ts +3 -3
  548. package/src/synthesis/SvoxPicoTTS.ts +4 -5
  549. package/src/synthesis/VitsTTS.ts +43 -15
  550. package/src/text-translation/DeepLTextTranslation.ts +12 -10
  551. package/src/text-translation/GoogleTranslateTextTranslation.ts +35 -21
  552. package/src/text-translation/NLLBTextTranslation.ts +5 -9
  553. package/src/typings/Fillers.d.ts +0 -60
  554. package/src/typings/TypedArray.ts +12 -1
  555. package/src/utilities/Compression.ts +10 -9
  556. package/src/utilities/FileDownloader.ts +38 -23
  557. package/src/utilities/FileSystem.ts +1 -1
  558. package/src/utilities/Logger.ts +59 -42
  559. package/src/utilities/NpmUtilities.ts +4 -6
  560. package/src/utilities/OpenPromise.ts +1 -2
  561. package/src/utilities/PackageManager.ts +53 -26
  562. package/src/utilities/PathUtilities.ts +6 -2
  563. package/src/utilities/TarballMaker.ts +7 -7
  564. package/src/utilities/Utilities.ts +58 -39
  565. package/src/utilities/WebReader.ts +11 -6
  566. package/src/utilities/WikipediaReader.ts +2 -8
  567. package/src/voice-activity-detection/AdaptiveGateVAD.ts +13 -8
  568. package/src/voice-activity-detection/WebRtcVAD.ts +1 -2
  569. package/tsconfig.json +53 -94
  570. package/dist/audio/AudioRecorder.d.ts +0 -3
  571. package/dist/audio/AudioRecorder.js +0 -68
  572. package/dist/audio/AudioRecorder.js.map +0 -1
  573. package/dist/audio/SoxPath.d.ts +0 -1
  574. package/dist/audio/SoxPath.js +0 -24
  575. package/dist/audio/SoxPath.js.map +0 -1
  576. package/dist/recognition/SileroSTT.d.ts +0 -29
  577. package/dist/recognition/SileroSTT.js +0 -152
  578. package/dist/recognition/SileroSTT.js.map +0 -1
  579. package/dist/recognition/VoskSTT.d.ts +0 -10
  580. package/dist/recognition/VoskSTT.js +0 -72
  581. package/dist/recognition/VoskSTT.js.map +0 -1
  582. package/dist/recognition/WhisperCppSTT.js.map +0 -1
  583. package/dist/synthesis/StreamlabsPollyTTS.d.ts +0 -11
  584. package/dist/synthesis/StreamlabsPollyTTS.js +0 -88
  585. package/dist/synthesis/StreamlabsPollyTTS.js.map +0 -1
  586. package/dist/utilities/BinaryUtilities.d.ts +0 -13
  587. package/dist/utilities/BinaryUtilities.js +0 -113
  588. package/dist/utilities/BinaryUtilities.js.map +0 -1
  589. package/src/audio/AudioRecorder.ts +0 -91
  590. package/src/audio/SoxPath.ts +0 -31
  591. package/src/recognition/SileroSTT.ts +0 -222
  592. package/src/recognition/VoskSTT.ts +0 -112
  593. package/src/synthesis/StreamlabsPollyTTS.ts +0 -114
  594. package/src/utilities/BinaryUtilities.ts +0 -138
  595. /package/{LICENSE.md → LICENSE.GPLv3.md} +0 -0
@@ -1,88 +0,0 @@
1
- import { request } from 'gaxios';
2
- import { trimAudioEnd } from '../audio/AudioUtilities.js';
3
- import * as FFMpegTranscoder from '../codecs/FFMpegTranscoder.js';
4
- import { Phrase, splitToFragments } from '../nlp/Segmentation.js';
5
- import { Logger } from '../utilities/Logger.js';
6
- import { concatFloat32Arrays, logToStderr } from '../utilities/Utilities.js';
7
- const log = logToStderr;
8
- const maxTextLengthPerRequest = 200;
9
- export async function synthesizeLongText(text, voice, languageCode, sentenceEndPause = 0.75, segmentEndPause = 1.0) {
10
- if (text.length == 0) {
11
- throw new Error('Text is empty');
12
- }
13
- const logger = new Logger();
14
- logger.start('Prepare and split text');
15
- const fragments = await splitToFragments(text, maxTextLengthPerRequest, languageCode);
16
- const audioFragments = [];
17
- let fragmentsSampleRate = 0;
18
- const timeline = [];
19
- for (let i = 0; i < fragments.length; i++) {
20
- const fragment = fragments[i];
21
- logger.start(`Request synthesis for text fragment ${i + 1}/${fragments.length} from Streamslabs Polly`);
22
- const fragmentMp3Stream = await synthesizeFragment(fragment.text, voice);
23
- if (fragmentMp3Stream.length == 0) {
24
- continue;
25
- }
26
- const rawAudio = await FFMpegTranscoder.decodeToChannels(fragmentMp3Stream, 24000, 1);
27
- fragmentsSampleRate = rawAudio.sampleRate;
28
- let targetEndingSilenceTime;
29
- if (fragment.lastSegment?.isSentenceFinalizer) {
30
- targetEndingSilenceTime = sentenceEndPause;
31
- }
32
- else if (fragment.lastSegment instanceof Phrase) {
33
- targetEndingSilenceTime = segmentEndPause;
34
- }
35
- else {
36
- targetEndingSilenceTime = 0;
37
- }
38
- const trimmedAudio = trimAudioEnd(rawAudio.audioChannels[0], targetEndingSilenceTime * rawAudio.sampleRate);
39
- audioFragments.push(trimmedAudio);
40
- const startTime = timeline.length == 0 ? 0 : timeline[timeline.length - 1].endTime;
41
- const endTime = startTime + (trimmedAudio.length / fragmentsSampleRate);
42
- timeline.push({
43
- type: 'segment',
44
- text: fragment.text,
45
- startTime,
46
- endTime
47
- });
48
- }
49
- const rawAudio = { audioChannels: [concatFloat32Arrays(audioFragments)], sampleRate: fragmentsSampleRate };
50
- logger.end();
51
- return {
52
- rawAudio,
53
- timeline
54
- };
55
- }
56
- export async function synthesizeFragment(text, voice) {
57
- const response = await request({
58
- url: `https://streamlabs.com/polly/speak`,
59
- method: 'POST',
60
- data: {
61
- voice,
62
- text,
63
- },
64
- responseType: 'json'
65
- });
66
- const responseObject = response.data;
67
- const audioUrl = responseObject.speak_url;
68
- const audioUrlResponse = await request({ url: audioUrl, responseType: 'arraybuffer' });
69
- return new Uint8Array(audioUrlResponse.data);
70
- }
71
- export const voiceList = [
72
- { name: 'Brian', languages: ['en-GB', 'en'], gender: 'male' },
73
- { name: 'Emma', languages: ['en-GB', 'en'], gender: 'female' },
74
- { name: 'Russell', languages: ['en-AU', 'en'], gender: 'male' },
75
- { name: 'Joey', languages: ['en-US', 'en'], gender: 'male' },
76
- { name: 'Matthew', languages: ['en-US', 'en'], gender: 'male' },
77
- { name: 'Joanna', languages: ['en-US', 'en'], gender: 'female' },
78
- { name: 'Kimberly', languages: ['en-US', 'en'], gender: 'female' },
79
- { name: 'Amy', languages: ['en-GB', 'en'], gender: 'female' },
80
- { name: 'Geraint', languages: ['en-GB-WLS', 'en-GB', 'en'], gender: 'male' },
81
- { name: 'Nicole', languages: ['en-AU', 'en'], gender: 'female' },
82
- { name: 'Justin', languages: ['en-US', 'en'], gender: 'male' },
83
- { name: 'Ivy', languages: ['en-US', 'en'], gender: 'female' },
84
- { name: 'Kendra', languages: ['en-US', 'en'], gender: 'female' },
85
- { name: 'Salli', languages: ['en-US', 'en'], gender: 'female' },
86
- { name: 'Raveena', languages: ['en-IN', 'en'], gender: 'female' },
87
- ];
88
- //# sourceMappingURL=StreamlabsPollyTTS.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"StreamlabsPollyTTS.js","sourceRoot":"","sources":["../../src/synthesis/StreamlabsPollyTTS.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAEhC,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,KAAK,gBAAgB,MAAM,+BAA+B,CAAA;AACjE,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAG5E,MAAM,GAAG,GAAG,WAAW,CAAA;AAEvB,MAAM,uBAAuB,GAAG,GAAG,CAAA;AAEnC,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,IAAY,EAAE,KAAa,EAAE,YAAoB,EAAE,gBAAgB,GAAG,IAAI,EAAE,eAAe,GAAG,GAAG;IACzI,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAA;IACjC,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,MAAM,EAAE,CAAA;IAC3B,MAAM,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAA;IAEtC,MAAM,SAAS,GAAG,MAAM,gBAAgB,CAAC,IAAI,E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E,QAAQ,EAAE;IAC7D,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE;IAChE,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE;IAC/D,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE;CACjE,CAAA"}
@@ -1,13 +0,0 @@
1
- export declare function readUint8(buffer: Uint8Array, offset: number): number;
2
- export declare function writeUint8(buffer: Uint8Array, value: number, offset: number): void;
3
- export declare function readUint16LE(buffer: Uint8Array, offset: number): number;
4
- export declare function writeUint16LE(buffer: Uint8Array, value: number, offset: number): void;
5
- export declare function readUint32LE(buffer: Uint8Array, offset: number): number;
6
- export declare function writeUint32LE(buffer: Uint8Array, value: number, offset: number): void;
7
- export declare function readInt8(buffer: Uint8Array, offset: number): number;
8
- export declare function writeInt8(buffer: Uint8Array, value: number, offset: number): void;
9
- export declare function readInt16LE(buffer: Uint8Array, offset: number): number;
10
- export declare function writeInt16LE(buffer: Uint8Array, value: number, offset: number): void;
11
- export declare function readInt32LE(buffer: Uint8Array, offset: number): number;
12
- export declare function writeInt32LE(buffer: Uint8Array, value: number, offset: number): void;
13
- export declare function writeAscii(buffer: Uint8Array, asciiString: string, writeStartOffset: number): void;
@@ -1,113 +0,0 @@
1
- /////////////////////////////////////////////////////////////////////////////////////
2
- // Unsigned operations
3
- /////////////////////////////////////////////////////////////////////////////////////
4
- export function readUint8(buffer, offset) {
5
- return buffer[offset];
6
- }
7
- export function writeUint8(buffer, value, offset) {
8
- if (value < 0 || value > 255) {
9
- throw new Error(`Value ${value} is outside the range of an 8-bit unsigned integer`);
10
- }
11
- buffer[offset] = value;
12
- }
13
- export function readUint16LE(buffer, offset) {
14
- return (buffer[offset]) | (buffer[offset + 1] << 8);
15
- }
16
- export function writeUint16LE(buffer, value, offset) {
17
- if (value < 0 || value > 65535) {
18
- throw new Error(`Value ${value} is outside the range of a 16-bit unsigned integer`);
19
- }
20
- buffer[offset] = value & 0xff;
21
- buffer[offset + 1] = (value >>> 8) & 0xff;
22
- }
23
- export function readUint32LE(buffer, offset) {
24
- return readInt32LE(buffer, offset) >>> 0;
25
- }
26
- export function writeUint32LE(buffer, value, offset) {
27
- if (value < 0 || value > 4294967295) {
28
- throw new Error(`Value ${value} is outside the range of a 32-bit unsigned integer`);
29
- }
30
- buffer[offset] = value & 0xff;
31
- buffer[offset + 1] = (value >>> 8) & 0xff;
32
- buffer[offset + 2] = (value >>> 16) & 0xff;
33
- buffer[offset + 3] = (value >>> 24) & 0xff;
34
- }
35
- /////////////////////////////////////////////////////////////////////////////////////
36
- // Signed operations
37
- /////////////////////////////////////////////////////////////////////////////////////
38
- export function readInt8(buffer, offset) {
39
- const unsignedValue = buffer[offset];
40
- if (unsignedValue < 128) {
41
- return unsignedValue;
42
- }
43
- else {
44
- return unsignedValue - 256;
45
- }
46
- }
47
- export function writeInt8(buffer, value, offset) {
48
- if (value < -128 || value > 127) {
49
- throw new Error(`Value ${value} is outside the range of an 8-bit signed integer`);
50
- }
51
- let unsignedValue;
52
- if (value >= 0) {
53
- unsignedValue = value;
54
- }
55
- else {
56
- unsignedValue = value + 256;
57
- }
58
- buffer[offset] = unsignedValue;
59
- }
60
- export function readInt16LE(buffer, offset) {
61
- const unsignedValue = readUint16LE(buffer, offset);
62
- if (unsignedValue < 32768) {
63
- return unsignedValue;
64
- }
65
- else {
66
- return unsignedValue - 65536;
67
- }
68
- }
69
- export function writeInt16LE(buffer, value, offset) {
70
- if (value < -32768 || value > 32767) {
71
- throw new Error(`Value ${value} is outside the range of a 16-bit signed integer`);
72
- }
73
- let unsignedValue;
74
- if (value >= 0) {
75
- unsignedValue = value;
76
- }
77
- else {
78
- unsignedValue = value + 65536;
79
- }
80
- writeUint16LE(buffer, unsignedValue, offset);
81
- }
82
- export function readInt32LE(buffer, offset) {
83
- const value = (buffer[offset]) |
84
- (buffer[offset + 1] << 8) |
85
- (buffer[offset + 2] << 16) |
86
- (buffer[offset + 3] << 24);
87
- return value;
88
- }
89
- export function writeInt32LE(buffer, value, offset) {
90
- if (value < -2147483648 || value > 2147483647) {
91
- throw new Error(`Value ${value} is outside the range of a 32-bit signed integer`);
92
- }
93
- buffer[offset] = value & 0xff;
94
- buffer[offset + 1] = (value >> 8) & 0xff;
95
- buffer[offset + 2] = (value >> 16) & 0xff;
96
- buffer[offset + 3] = (value >> 24) & 0xff;
97
- }
98
- /////////////////////////////////////////////////////////////////////////////////////
99
- // Misc operations
100
- /////////////////////////////////////////////////////////////////////////////////////
101
- export function writeAscii(buffer, asciiString, writeStartOffset) {
102
- const writeEndOffset = Math.min(writeStartOffset + asciiString.length, buffer.length);
103
- let readOffset = 0;
104
- let writeOffset = writeStartOffset;
105
- while (writeOffset < writeEndOffset) {
106
- const charCode = asciiString.charCodeAt(readOffset++);
107
- if (charCode >= 128) {
108
- throw new Error(`Character '${asciiString[readOffset]}' (code: ${charCode}) can't be encoded as ASCII`);
109
- }
110
- buffer[writeOffset++] = charCode;
111
- }
112
- }
113
- //# sourceMappingURL=BinaryUtilities.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BinaryUtilities.js","sourceRoot":"","sources":["../../src/utilities/BinaryUtilities.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,sBAAsB;AACtB,qFAAqF;AACrF,MAAM,UAAU,SAAS,CAAC,MAAkB,EAAE,MAAc;IAC3D,OAAO,MAAM,CAAC,MAAM,CAAC,CAAA;AACtB,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,MAAkB,EAAE,KAAa,EAAE,MAAc;IAC3E,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,GAAG,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,SAAS,KAAK,oDA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AAI,CAAA;AAC1C,CAAC;AAED,qFAAqF;AACrF,kBAAkB;AAClB,qFAAqF;AACrF,MAAM,UAAU,UAAU,CAAC,MAAkB,EAAE,WAAmB,EAAE,gBAAwB;IAC3F,MAAM,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,gBAAgB,GAAG,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;IAErF,IAAI,UAAU,GAAG,CAAC,CAAA;IAClB,IAAI,WAAW,GAAG,gBAAgB,CAAA;IAElC,OAAO,WAAW,GAAG,cAAc,EAAE,CAAC;QACrC,MAAM,QAAQ,GAAG,WAAW,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC,CAAA;QAErD,IAAI,QAAQ,IAAI,GAAG,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,cAAc,WAAW,CAAC,UAAU,CAAC,YAAY,QAAQ,6BAA6B,CAAC,CAAA;QACxG,CAAC;QAED,MAAM,CAAC,WAAW,EAAE,CAAC,GAAG,QAAQ,CAAA;IACjC,CAAC;AACF,CAAC"}
@@ -1,91 +0,0 @@
1
- import { spawn } from 'child_process'
2
-
3
- import { RawAudio, concatAudioSegments } from './AudioUtilities.js'
4
- import * as AudioBufferConversion from './AudioBufferConversion.js'
5
-
6
- import { Timer } from '../utilities/Timer.js'
7
- import { logToStderr } from '../utilities/Utilities.js'
8
- import { OpenPromise } from '../utilities/OpenPromise.js'
9
- import { tryResolvingSoxPath } from './SoxPath.js'
10
- import { SampleFormat } from './AudioBufferConversion.js'
11
-
12
- const log = logToStderr
13
-
14
- export async function recordAudioInput(channelCount = 1, sampleRate = 48000, maxTime = 10) {
15
- const audioSegments: Float32Array[][] = []
16
-
17
- await captureAudioInput(channelCount, sampleRate, maxTime, (rawAudio) => {
18
- audioSegments.push(rawAudio)
19
- })
20
-
21
- const mergedAudio = concatAudioSegments(audioSegments)
22
-
23
- const rawAudio: RawAudio = {
24
- audioChannels: mergedAudio,
25
- sampleRate
26
- }
27
-
28
- return rawAudio
29
- }
30
-
31
- export function captureAudioInput(channelCount = 1, sampleRate = 48000, maxTime = -1, onAudioSamples?: (rawAudio: Float32Array[]) => void) {
32
- return new Promise<void>(async (resolve, reject) => {
33
- const timer = new Timer()
34
-
35
- const recorderSpawnedOpenPromise = new OpenPromise<null>()
36
-
37
- const soxPath = await tryResolvingSoxPath()
38
-
39
- if (!soxPath) {
40
- throw new Error('Could not resolve a SoX executable')
41
- }
42
-
43
- let args: string[]
44
-
45
- if (process.platform == 'win32') {
46
- args = ['-b', `${16}`, '--endian', 'little',
47
- '-c', `${channelCount}`, '-r', `${sampleRate}`, '-e', 'signed',
48
- '-t', 'waveaudio', 'default', '-t', 'raw', '-']
49
- } else if (process.platform == 'darwin') {
50
- args = ['-b', `${16}`, '--endian', 'little',
51
- '-c', `${channelCount}`, '-r', `${sampleRate}`, '-e', 'signed',
52
- '-t', 'raw', '-']
53
- } else {
54
- throw new Error('')
55
- }
56
-
57
- const recorder = spawn(
58
- soxPath,
59
- args,
60
- {}
61
- )
62
-
63
- recorder.once('spawn', () => {
64
- recorderSpawnedOpenPromise.resolve(null)
65
- timer.restart()
66
- })
67
-
68
- recorder.once('close', () => {
69
- resolve()
70
- })
71
-
72
- recorder.stderr.on('data', (chunk) => {
73
- //log(chunk.toString('utf8'))
74
- })
75
-
76
- recorder.stdout.on('data', (chunk) => {
77
- //log(chunk)
78
-
79
- const audioChannels = AudioBufferConversion.decodeToChannels(chunk, channelCount, 16, SampleFormat.PCM)
80
-
81
- if (onAudioSamples) {
82
- onAudioSamples(audioChannels)
83
- }
84
-
85
- if (maxTime >= 0 && timer.elapsedTimeSeconds >= maxTime) {
86
- recorder.kill()
87
- resolve()
88
- }
89
- })
90
- })
91
- }
@@ -1,31 +0,0 @@
1
- import { loadPackage } from '../utilities/PackageManager.js'
2
- import { commandExists } from '../utilities/Utilities.js'
3
- import { getGlobalOption } from '../api/GlobalOptions.js'
4
- import { joinPath } from '../utilities/PathUtilities.js'
5
-
6
- export async function tryResolvingSoxPath() {
7
- if (getGlobalOption('soxPath')) {
8
- return getGlobalOption('soxPath')
9
- }
10
-
11
- const platform = process.platform
12
- const arch = process.arch
13
-
14
- if (platform === 'win32') {
15
- const soxPackagePath = await loadPackage('sox-14.4.1a-win32')
16
-
17
- return joinPath(soxPackagePath, 'sox.exe')
18
- }
19
-
20
- if (await commandExists('sox')) {
21
- return 'sox'
22
- }
23
-
24
- if (platform === 'linux' && arch === 'x64') {
25
- const soxPackagePath = await loadPackage('sox-14.4.2-linux-minimal')
26
-
27
- return joinPath(soxPackagePath, 'sox')
28
- }
29
-
30
- return undefined
31
- }
@@ -1,222 +0,0 @@
1
- import { indexOfMax } from '../math/VectorMath.js'
2
- import { wordCharacterRegExp } from '../nlp/Segmentation.js'
3
- import { Logger } from '../utilities/Logger.js'
4
- import { logToStderr } from '../utilities/Utilities.js'
5
- import { Timeline } from '../utilities/Timeline.js'
6
- import { RawAudio, getRawAudioDuration } from '../audio/AudioUtilities.js'
7
- import { readAndParseJsonFile } from '../utilities/FileSystem.js'
8
-
9
- import type * as Onnx from 'onnxruntime-node'
10
- import { OnnxExecutionProvider, getOnnxSessionOptions } from '../utilities/OnnxUtilities.js'
11
- import { joinPath } from '../utilities/PathUtilities.js'
12
-
13
- const log = logToStderr
14
-
15
- export async function recognize(
16
- rawAudio: RawAudio,
17
- modelDirectoryPath: string,
18
- executionProviders: OnnxExecutionProvider[]) {
19
-
20
- const silero = new SileroSTT(modelDirectoryPath, executionProviders)
21
-
22
- const result = await silero.recognize(rawAudio)
23
-
24
- return result
25
- }
26
-
27
- export class SileroSTT {
28
- session?: Onnx.InferenceSession
29
- labels?: string[]
30
-
31
- constructor(
32
- public readonly modelDirectoryPath: string,
33
- public readonly executionProviders: OnnxExecutionProvider[]
34
- ) {
35
- }
36
-
37
- async recognize(rawAudio: RawAudio) {
38
- const logger = new Logger()
39
-
40
- await this.initializeIfNeeded()
41
-
42
- logger.start('Recognize with silero model')
43
-
44
- const audioSamples = rawAudio.audioChannels[0]
45
-
46
- const Onnx = await import('onnxruntime-node')
47
-
48
- const inputTensor = new Onnx.Tensor('float32', audioSamples, [1, audioSamples.length])
49
- const inputs = { input: inputTensor }
50
-
51
- const results = await this.session!.run(inputs)
52
-
53
- const rawResultValues = results['output'].data as Float32Array
54
-
55
- const labels = this.labels!
56
-
57
- const tokenResults: Float32Array[] = []
58
-
59
- for (let i = 0; i < rawResultValues.length; i += labels.length) {
60
- tokenResults.push(rawResultValues.subarray(i, i + labels.length))
61
- }
62
-
63
- const tokens: string[] = []
64
-
65
- for (const tokenResult of tokenResults) {
66
- const bestCandidateIndex = indexOfMax(new Array(...tokenResult))
67
- tokens.push(labels[bestCandidateIndex])
68
- }
69
-
70
- //log(tokens.join('|'))
71
-
72
- const result = this.tokensToTimeline(tokens, getRawAudioDuration(rawAudio))
73
-
74
- logger.end()
75
-
76
- return result
77
- }
78
-
79
- private async initializeIfNeeded() {
80
- if (this.session) {
81
- return
82
- }
83
-
84
- const logger = new Logger()
85
-
86
- logger.start('Create ONNX inference session')
87
-
88
- const Onnx = await import('onnxruntime-node')
89
-
90
- const modelPath = joinPath(this.modelDirectoryPath, 'model.onnx')
91
- const labelsPath = joinPath(this.modelDirectoryPath, 'labels.json')
92
-
93
- this.labels = await readAndParseJsonFile(labelsPath)
94
-
95
- const onnxSessionOptions = getOnnxSessionOptions({ executionProviders: this.executionProviders })
96
-
97
- this.session = await Onnx.InferenceSession.create(modelPath, onnxSessionOptions)
98
-
99
- logger.end()
100
- }
101
-
102
- private tokensToTimeline(tokens: string[], totalDuration: number) {
103
- const tokenCount = tokens.length
104
-
105
- const decodedTokens: string[] = []
106
- let tokenGroupIndexes: number[][] = [[]]
107
-
108
- for (let i = 0; i < tokenCount; i++) {
109
- const token = tokens[i]
110
-
111
- if (token == '2') {
112
- if (decodedTokens.length > 0) {
113
- const previousDecodedToken = decodedTokens[decodedTokens.length - 1]
114
- decodedTokens.push('$')
115
- decodedTokens.push(previousDecodedToken)
116
-
117
- tokenGroupIndexes[tokenGroupIndexes.length - 1].push(i)
118
- } else {
119
- decodedTokens.push(' ')
120
- tokenGroupIndexes.push([])
121
- }
122
-
123
- continue
124
- }
125
-
126
- if (token == '_') {
127
- continue
128
- }
129
-
130
- decodedTokens.push(token)
131
-
132
- if (token == ' ') {
133
- tokenGroupIndexes.push([])
134
- } else {
135
- tokenGroupIndexes[tokenGroupIndexes.length - 1].push(i)
136
- }
137
- }
138
-
139
- let decodedString = ''
140
-
141
- for (let i = 0; i < decodedTokens.length; i++) {
142
- const currentToken = decodedTokens[i]
143
- const previousToken = decodedTokens[i - 1]
144
-
145
- if (currentToken != '$' && (previousToken != currentToken || previousToken == undefined)) {
146
- decodedString += currentToken
147
- }
148
- }
149
-
150
- decodedString = decodedString.trim()
151
-
152
- tokenGroupIndexes = tokenGroupIndexes.filter(group => group.length > 0)
153
-
154
- if (tokenGroupIndexes.length > 0) {
155
- let currentCorrection = Math.min(tokenGroupIndexes[0][0], 1.5)
156
-
157
- for (let i = 0; i < tokenGroupIndexes.length; i++) {
158
- const group = tokenGroupIndexes[i]
159
-
160
- if (group.length == 1) {
161
- group.push(group[0])
162
- }
163
-
164
- group[0] -= currentCorrection
165
-
166
- if (i == tokenGroupIndexes.length - 1) {
167
- currentCorrection = Math.min(tokenCount - i, 1.5)
168
- } else {
169
- currentCorrection = Math.min((tokenGroupIndexes[i + 1][0] - group[group.length - 1]) / 2, 1.5)
170
- }
171
-
172
- group[group.length - 1] += currentCorrection
173
- }
174
- }
175
-
176
- const words = decodedString.split(' ')
177
-
178
- const timeMultiplier = totalDuration / tokenCount
179
-
180
- const timeline: Timeline = []
181
-
182
- for (let i = 0; i < words.length; i++) {
183
- const text = words[i]
184
-
185
- if (!wordCharacterRegExp.test(text)) {
186
- continue
187
- }
188
-
189
- const group = tokenGroupIndexes[i]
190
- const startTime = group[0] * timeMultiplier
191
- const endTime = group[group.length - 1] * timeMultiplier
192
-
193
- timeline.push({
194
- type: 'word',
195
- text: text,
196
- startTime,
197
- endTime,
198
- })
199
- }
200
-
201
- timeline[timeline.length - 1].endTime = totalDuration
202
-
203
- return { transcript: decodedString, timeline }
204
- }
205
- }
206
-
207
- export const languageCodeToPackageName: { [languageCode: string]: string } = {
208
- 'en': 'silero-en-v5',
209
- 'es': 'silero-es-v1',
210
- 'de': 'silero-de-v1',
211
- 'uk': 'silero-ua-v3',
212
- }
213
-
214
- export interface SileroRecognitionOptions {
215
- modelPath?: string
216
- provider?: OnnxExecutionProvider
217
- }
218
-
219
- export const defaultSileroRecognitionOptions: SileroRecognitionOptions = {
220
- modelPath: undefined,
221
- provider: undefined,
222
- }