echogarden 0.0.1 → 0.1.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 (295) hide show
  1. package/README.md +59 -1
  2. package/data/lexicons/heteronyms.json +674 -0
  3. package/data/schemas/options.json +1057 -0
  4. package/data/tables/lcid-table.json +7427 -0
  5. package/dist/alignment/DTWMfccSequenceAlignment.d.ts +2 -0
  6. package/dist/alignment/DTWMfccSequenceAlignment.js +26 -0
  7. package/dist/alignment/DTWMfccSequenceAlignment.js.map +1 -0
  8. package/dist/alignment/DTWSequenceAlignment.d.ts +5 -0
  9. package/dist/alignment/DTWSequenceAlignment.js +99 -0
  10. package/dist/alignment/DTWSequenceAlignment.js.map +1 -0
  11. package/dist/alignment/DTWSequenceAlignmentWindowed.d.ts +5 -0
  12. package/dist/alignment/DTWSequenceAlignmentWindowed.js +161 -0
  13. package/dist/alignment/DTWSequenceAlignmentWindowed.js.map +1 -0
  14. package/dist/alignment/LevenshteinSequenceAlignment.d.ts +5 -0
  15. package/dist/alignment/LevenshteinSequenceAlignment.js +102 -0
  16. package/dist/alignment/LevenshteinSequenceAlignment.js.map +1 -0
  17. package/dist/alignment/SpeechAlignment.d.ts +27 -0
  18. package/dist/alignment/SpeechAlignment.js +266 -0
  19. package/dist/alignment/SpeechAlignment.js.map +1 -0
  20. package/dist/api/API.d.ts +8 -0
  21. package/dist/api/API.js +10 -0
  22. package/dist/api/API.js.map +1 -0
  23. package/dist/api/APIOptions.d.ts +12 -0
  24. package/dist/api/APIOptions.js +2 -0
  25. package/dist/api/APIOptions.js.map +1 -0
  26. package/dist/api/Alignment.d.ts +32 -0
  27. package/dist/api/Alignment.js +134 -0
  28. package/dist/api/Alignment.js.map +1 -0
  29. package/dist/api/Denoising.d.ts +14 -0
  30. package/dist/api/Denoising.js +66 -0
  31. package/dist/api/Denoising.js.map +1 -0
  32. package/dist/api/Globals.d.ts +1 -0
  33. package/dist/api/Globals.js +2 -0
  34. package/dist/api/Globals.js.map +1 -0
  35. package/dist/api/LanguageDetection.d.ts +49 -0
  36. package/dist/api/LanguageDetection.js +118 -0
  37. package/dist/api/LanguageDetection.js.map +1 -0
  38. package/dist/api/Recognition.d.ts +49 -0
  39. package/dist/api/Recognition.js +162 -0
  40. package/dist/api/Recognition.js.map +1 -0
  41. package/dist/api/Synthesis.d.ts +125 -0
  42. package/dist/api/Synthesis.js +892 -0
  43. package/dist/api/Synthesis.js.map +1 -0
  44. package/dist/api/Translation.d.ts +25 -0
  45. package/dist/api/Translation.js +69 -0
  46. package/dist/api/Translation.js.map +1 -0
  47. package/dist/api/Vad.d.ts +25 -0
  48. package/dist/api/Vad.js +88 -0
  49. package/dist/api/Vad.js.map +1 -0
  50. package/dist/audio/AudioBufferConversion.d.ts +15 -0
  51. package/dist/audio/AudioBufferConversion.js +228 -0
  52. package/dist/audio/AudioBufferConversion.js.map +1 -0
  53. package/dist/audio/AudioPlayer.d.ts +9 -0
  54. package/dist/audio/AudioPlayer.js +232 -0
  55. package/dist/audio/AudioPlayer.js.map +1 -0
  56. package/dist/audio/AudioRecorder.d.ts +3 -0
  57. package/dist/audio/AudioRecorder.js +68 -0
  58. package/dist/audio/AudioRecorder.js.map +1 -0
  59. package/dist/audio/AudioUtilities.d.ts +48 -0
  60. package/dist/audio/AudioUtilities.js +209 -0
  61. package/dist/audio/AudioUtilities.js.map +1 -0
  62. package/dist/audio/SoxPath.d.ts +1 -0
  63. package/dist/audio/SoxPath.js +19 -0
  64. package/dist/audio/SoxPath.js.map +1 -0
  65. package/dist/cli/CLI.d.ts +8 -0
  66. package/dist/cli/CLI.js +860 -0
  67. package/dist/cli/CLI.js.map +1 -0
  68. package/dist/cli/CLIConfigFile.d.ts +3 -0
  69. package/dist/cli/CLIConfigFile.js +62 -0
  70. package/dist/cli/CLIConfigFile.js.map +1 -0
  71. package/dist/cli/CLILauncher.d.ts +2 -0
  72. package/dist/cli/CLILauncher.js +22 -0
  73. package/dist/cli/CLILauncher.js.map +1 -0
  74. package/dist/cli/CLIOptionsSchema.d.ts +5 -0
  75. package/dist/cli/CLIOptionsSchema.js +36 -0
  76. package/dist/cli/CLIOptionsSchema.js.map +1 -0
  77. package/dist/cli/CLIParser.d.ts +6 -0
  78. package/dist/cli/CLIParser.js +34 -0
  79. package/dist/cli/CLIParser.js.map +1 -0
  80. package/dist/cli/CLIStarter.d.ts +1 -0
  81. package/dist/cli/CLIStarter.js +3 -0
  82. package/dist/cli/CLIStarter.js.map +1 -0
  83. package/dist/codecs/FFMpegTranscoder.d.ts +20 -0
  84. package/dist/codecs/FFMpegTranscoder.js +169 -0
  85. package/dist/codecs/FFMpegTranscoder.js.map +1 -0
  86. package/dist/codecs/TIMITCodec.d.ts +9 -0
  87. package/dist/codecs/TIMITCodec.js +14 -0
  88. package/dist/codecs/TIMITCodec.js.map +1 -0
  89. package/dist/codecs/WaveCodec.d.ts +19 -0
  90. package/dist/codecs/WaveCodec.js +208 -0
  91. package/dist/codecs/WaveCodec.js.map +1 -0
  92. package/dist/denoising/RNNoise.d.ts +6 -0
  93. package/dist/denoising/RNNoise.js +68 -0
  94. package/dist/denoising/RNNoise.js.map +1 -0
  95. package/dist/dsp/BiquadFilter.d.ts +26 -0
  96. package/dist/dsp/BiquadFilter.js +399 -0
  97. package/dist/dsp/BiquadFilter.js.map +1 -0
  98. package/dist/dsp/FFT.d.ts +9 -0
  99. package/dist/dsp/FFT.js +135 -0
  100. package/dist/dsp/FFT.js.map +1 -0
  101. package/dist/dsp/MFCC.d.ts +25 -0
  102. package/dist/dsp/MFCC.js +162 -0
  103. package/dist/dsp/MFCC.js.map +1 -0
  104. package/dist/dsp/MelSpectogram.d.ts +19 -0
  105. package/dist/dsp/MelSpectogram.js +102 -0
  106. package/dist/dsp/MelSpectogram.js.map +1 -0
  107. package/dist/dsp/Rubberband.d.ts +52 -0
  108. package/dist/dsp/Rubberband.js +186 -0
  109. package/dist/dsp/Rubberband.js.map +1 -0
  110. package/dist/dsp/Sonic.d.ts +2 -0
  111. package/dist/dsp/Sonic.js +39 -0
  112. package/dist/dsp/Sonic.js.map +1 -0
  113. package/dist/dsp/SpeexResampler.d.ts +3 -0
  114. package/dist/dsp/SpeexResampler.js +53 -0
  115. package/dist/dsp/SpeexResampler.js.map +1 -0
  116. package/dist/math/VectorMath.d.ts +70 -0
  117. package/dist/math/VectorMath.js +564 -0
  118. package/dist/math/VectorMath.js.map +1 -0
  119. package/dist/nlp/ChineseSegmentation.d.ts +1 -0
  120. package/dist/nlp/ChineseSegmentation.js +53 -0
  121. package/dist/nlp/ChineseSegmentation.js.map +1 -0
  122. package/dist/nlp/CompromiseNLP.d.ts +15 -0
  123. package/dist/nlp/CompromiseNLP.js +66 -0
  124. package/dist/nlp/CompromiseNLP.js.map +1 -0
  125. package/dist/nlp/EspeakPhonemizer.d.ts +4 -0
  126. package/dist/nlp/EspeakPhonemizer.js +133 -0
  127. package/dist/nlp/EspeakPhonemizer.js.map +1 -0
  128. package/dist/nlp/IPA.d.ts +19 -0
  129. package/dist/nlp/IPA.js +113 -0
  130. package/dist/nlp/IPA.js.map +1 -0
  131. package/dist/nlp/JapaneseSegmentation.d.ts +1 -0
  132. package/dist/nlp/JapaneseSegmentation.js +40 -0
  133. package/dist/nlp/JapaneseSegmentation.js.map +1 -0
  134. package/dist/nlp/Lexicon.d.ts +17 -0
  135. package/dist/nlp/Lexicon.js +6 -0
  136. package/dist/nlp/Lexicon.js.map +1 -0
  137. package/dist/nlp/PhoneConversion.d.ts +6 -0
  138. package/dist/nlp/PhoneConversion.js +467 -0
  139. package/dist/nlp/PhoneConversion.js.map +1 -0
  140. package/dist/nlp/Segmentation.d.ts +41 -0
  141. package/dist/nlp/Segmentation.js +158 -0
  142. package/dist/nlp/Segmentation.js.map +1 -0
  143. package/dist/nlp/TextNormalizer.d.ts +4 -0
  144. package/dist/nlp/TextNormalizer.js +69 -0
  145. package/dist/nlp/TextNormalizer.js.map +1 -0
  146. package/dist/recognition/AmazonTranscribeSTT.d.ts +6 -0
  147. package/dist/recognition/AmazonTranscribeSTT.js +79 -0
  148. package/dist/recognition/AmazonTranscribeSTT.js.map +1 -0
  149. package/dist/recognition/AzureCognitiveServicesSTT.d.ts +7 -0
  150. package/dist/recognition/AzureCognitiveServicesSTT.js +51 -0
  151. package/dist/recognition/AzureCognitiveServicesSTT.js.map +1 -0
  152. package/dist/recognition/GoogleCloudSTT.d.ts +7 -0
  153. package/dist/recognition/GoogleCloudSTT.js +66 -0
  154. package/dist/recognition/GoogleCloudSTT.js.map +1 -0
  155. package/dist/recognition/SileroSTT.d.ts +9 -0
  156. package/dist/recognition/SileroSTT.js +125 -0
  157. package/dist/recognition/SileroSTT.js.map +1 -0
  158. package/dist/recognition/VoskSTT.d.ts +10 -0
  159. package/dist/recognition/VoskSTT.js +78 -0
  160. package/dist/recognition/VoskSTT.js.map +1 -0
  161. package/dist/recognition/WhisperSTT.d.ts +69 -0
  162. package/dist/recognition/WhisperSTT.js +977 -0
  163. package/dist/recognition/WhisperSTT.js.map +1 -0
  164. package/dist/server/Server.d.ts +1 -0
  165. package/dist/server/Server.js +18 -0
  166. package/dist/server/Server.js.map +1 -0
  167. package/dist/speech-language-detection/SileroLanguageDetection.d.ts +9 -0
  168. package/dist/speech-language-detection/SileroLanguageDetection.js +47 -0
  169. package/dist/speech-language-detection/SileroLanguageDetection.js.map +1 -0
  170. package/dist/subtitles/Subtitles.d.ts +25 -0
  171. package/dist/subtitles/Subtitles.js +286 -0
  172. package/dist/subtitles/Subtitles.js.map +1 -0
  173. package/dist/synthesis/AwsPollyTTS.d.ts +7 -0
  174. package/dist/synthesis/AwsPollyTTS.js +51 -0
  175. package/dist/synthesis/AwsPollyTTS.js.map +1 -0
  176. package/dist/synthesis/AzureCognitiveServicesTTS.d.ts +9 -0
  177. package/dist/synthesis/AzureCognitiveServicesTTS.js +103 -0
  178. package/dist/synthesis/AzureCognitiveServicesTTS.js.map +1 -0
  179. package/dist/synthesis/CoquiServerTTS.d.ts +6 -0
  180. package/dist/synthesis/CoquiServerTTS.js +22 -0
  181. package/dist/synthesis/CoquiServerTTS.js.map +1 -0
  182. package/dist/synthesis/ElevenLabsTTS.d.ts +8 -0
  183. package/dist/synthesis/ElevenLabsTTS.js +48 -0
  184. package/dist/synthesis/ElevenLabsTTS.js.map +1 -0
  185. package/dist/synthesis/EspeakTTS.d.ts +46 -0
  186. package/dist/synthesis/EspeakTTS.js +353 -0
  187. package/dist/synthesis/EspeakTTS.js.map +1 -0
  188. package/dist/synthesis/FliteTTS.d.ts +17 -0
  189. package/dist/synthesis/FliteTTS.js +326 -0
  190. package/dist/synthesis/FliteTTS.js.map +1 -0
  191. package/dist/synthesis/GoogleCloudTTS.d.ts +16 -0
  192. package/dist/synthesis/GoogleCloudTTS.js +72 -0
  193. package/dist/synthesis/GoogleCloudTTS.js.map +1 -0
  194. package/dist/synthesis/GoogleTranslateTTS.d.ts +13 -0
  195. package/dist/synthesis/GoogleTranslateTTS.js +177 -0
  196. package/dist/synthesis/GoogleTranslateTTS.js.map +1 -0
  197. package/dist/synthesis/MicrosoftEdgeTTS.d.ts +10 -0
  198. package/dist/synthesis/MicrosoftEdgeTTS.js +216 -0
  199. package/dist/synthesis/MicrosoftEdgeTTS.js.map +1 -0
  200. package/dist/synthesis/SamTTS.d.ts +4 -0
  201. package/dist/synthesis/SamTTS.js +21 -0
  202. package/dist/synthesis/SamTTS.js.map +1 -0
  203. package/dist/synthesis/SapiTTS.d.ts +9 -0
  204. package/dist/synthesis/SapiTTS.js +211 -0
  205. package/dist/synthesis/SapiTTS.js.map +1 -0
  206. package/dist/synthesis/StreamlabsPollyTTS.d.ts +12 -0
  207. package/dist/synthesis/StreamlabsPollyTTS.js +88 -0
  208. package/dist/synthesis/StreamlabsPollyTTS.js.map +1 -0
  209. package/dist/synthesis/SvoxPicoTTS.d.ts +11 -0
  210. package/dist/synthesis/SvoxPicoTTS.js +236 -0
  211. package/dist/synthesis/SvoxPicoTTS.js.map +1 -0
  212. package/dist/synthesis/VitsTTS.d.ts +27 -0
  213. package/dist/synthesis/VitsTTS.js +359 -0
  214. package/dist/synthesis/VitsTTS.js.map +1 -0
  215. package/dist/tests/Test.d.ts +1 -0
  216. package/dist/tests/Test.js +10 -0
  217. package/dist/tests/Test.js.map +1 -0
  218. package/dist/text-language-detection/FastTextLanguageDetection.d.ts +2 -0
  219. package/dist/text-language-detection/FastTextLanguageDetection.js +38 -0
  220. package/dist/text-language-detection/FastTextLanguageDetection.js.map +1 -0
  221. package/dist/text-language-detection/TinyLDLanguageDetection.d.ts +2 -0
  222. package/dist/text-language-detection/TinyLDLanguageDetection.js +12 -0
  223. package/dist/text-language-detection/TinyLDLanguageDetection.js.map +1 -0
  224. package/dist/utilities/BinaryArrayConversion.d.ts +15 -0
  225. package/dist/utilities/BinaryArrayConversion.js +115 -0
  226. package/dist/utilities/BinaryArrayConversion.js.map +1 -0
  227. package/dist/utilities/Compression.d.ts +4 -0
  228. package/dist/utilities/Compression.js +67 -0
  229. package/dist/utilities/Compression.js.map +1 -0
  230. package/dist/utilities/FileDownloader.d.ts +3 -0
  231. package/dist/utilities/FileDownloader.js +147 -0
  232. package/dist/utilities/FileDownloader.js.map +1 -0
  233. package/dist/utilities/FileSystem.d.ts +30 -0
  234. package/dist/utilities/FileSystem.js +141 -0
  235. package/dist/utilities/FileSystem.js.map +1 -0
  236. package/dist/utilities/Hashing.d.ts +10 -0
  237. package/dist/utilities/Hashing.js +169 -0
  238. package/dist/utilities/Hashing.js.map +1 -0
  239. package/dist/utilities/Locale.d.ts +9 -0
  240. package/dist/utilities/Locale.js +65 -0
  241. package/dist/utilities/Locale.js.map +1 -0
  242. package/dist/utilities/Logger.d.ts +11 -0
  243. package/dist/utilities/Logger.js +49 -0
  244. package/dist/utilities/Logger.js.map +1 -0
  245. package/dist/utilities/NdArrayUtilities.d.ts +3 -0
  246. package/dist/utilities/NdArrayUtilities.js +22 -0
  247. package/dist/utilities/NdArrayUtilities.js.map +1 -0
  248. package/dist/utilities/ObjectUtilities.d.ts +4 -0
  249. package/dist/utilities/ObjectUtilities.js +132 -0
  250. package/dist/utilities/ObjectUtilities.js.map +1 -0
  251. package/dist/utilities/OpenPromise.d.ts +6 -0
  252. package/dist/utilities/OpenPromise.js +12 -0
  253. package/dist/utilities/OpenPromise.js.map +1 -0
  254. package/dist/utilities/PackageManager.d.ts +4 -0
  255. package/dist/utilities/PackageManager.js +46 -0
  256. package/dist/utilities/PackageManager.js.map +1 -0
  257. package/dist/utilities/RandomGenerator.d.ts +35 -0
  258. package/dist/utilities/RandomGenerator.js +149 -0
  259. package/dist/utilities/RandomGenerator.js.map +1 -0
  260. package/dist/utilities/TarballMaker.d.ts +4 -0
  261. package/dist/utilities/TarballMaker.js +50 -0
  262. package/dist/utilities/TarballMaker.js.map +1 -0
  263. package/dist/utilities/Timeline.d.ts +20 -0
  264. package/dist/utilities/Timeline.js +110 -0
  265. package/dist/utilities/Timeline.js.map +1 -0
  266. package/dist/utilities/Timer.d.ts +13 -0
  267. package/dist/utilities/Timer.js +70 -0
  268. package/dist/utilities/Timer.js.map +1 -0
  269. package/dist/utilities/Utilities.d.ts +68 -0
  270. package/dist/utilities/Utilities.js +305 -0
  271. package/dist/utilities/Utilities.js.map +1 -0
  272. package/dist/utilities/WasmMemoryManager.d.ts +142 -0
  273. package/dist/utilities/WasmMemoryManager.js +407 -0
  274. package/dist/utilities/WasmMemoryManager.js.map +1 -0
  275. package/dist/utilities/WebReader.d.ts +1 -0
  276. package/dist/utilities/WebReader.js +47 -0
  277. package/dist/utilities/WebReader.js.map +1 -0
  278. package/dist/utilities/WikipediaReader.d.ts +1 -0
  279. package/dist/utilities/WikipediaReader.js +31 -0
  280. package/dist/utilities/WikipediaReader.js.map +1 -0
  281. package/dist/voice-activity-detection/SileroVAD.d.ts +13 -0
  282. package/dist/voice-activity-detection/SileroVAD.js +58 -0
  283. package/dist/voice-activity-detection/SileroVAD.js.map +1 -0
  284. package/dist/voice-activity-detection/WebRtcVAD.d.ts +3 -0
  285. package/dist/voice-activity-detection/WebRtcVAD.js +53 -0
  286. package/dist/voice-activity-detection/WebRtcVAD.js.map +1 -0
  287. package/docs/CLI.md +234 -0
  288. package/docs/Development.md +3 -0
  289. package/docs/Engines.md +80 -0
  290. package/docs/Licenses.md +37 -0
  291. package/docs/Options.md +192 -0
  292. package/docs/Roadmap.md +16 -0
  293. package/docs/Technical.md +72 -0
  294. package/package.json +119 -19
  295. package/cli.js +0 -3
@@ -0,0 +1,2 @@
1
+ export declare function alignMFCC_DTW(mfccFrames1: number[][], mfccFrames2: number[][], windowLength: number, distanceFunction?: "eucledian" | "cosine"): Promise<import("./SpeechAlignment.js").AlignmentPath>;
2
+ export declare function getCostMatrixMemorySizeMiB(sequence1Length: number, sequence2Length: number, windowLength: number): number;
@@ -0,0 +1,26 @@
1
+ import { cosineDistancePrecomputedMagnitudes, createVectorForIntegerRange, eucledianDistance, magnitude } from "../math/VectorMath.js";
2
+ import { logToStderr } from "../utilities/Utilities.js";
3
+ import { alignDTWWindowed } from "./DTWSequenceAlignmentWindowed.js";
4
+ const log = logToStderr;
5
+ export async function alignMFCC_DTW(mfccFrames1, mfccFrames2, windowLength, distanceFunction = "eucledian") {
6
+ if (distanceFunction == "eucledian") {
7
+ const { path } = await alignDTWWindowed(mfccFrames1, mfccFrames2, eucledianDistance, windowLength);
8
+ return path;
9
+ }
10
+ else if (distanceFunction == "cosine") {
11
+ const indexes1 = createVectorForIntegerRange(0, mfccFrames1.length);
12
+ const indexes2 = createVectorForIntegerRange(0, mfccFrames2.length);
13
+ const magnitudes1 = mfccFrames1.map(magnitude);
14
+ const magnitudes2 = mfccFrames2.map(magnitude);
15
+ const { path } = await alignDTWWindowed(indexes1, indexes2, (i, j) => cosineDistancePrecomputedMagnitudes(mfccFrames1[i], mfccFrames2[j], magnitudes1[i], magnitudes2[j]), windowLength);
16
+ return path;
17
+ }
18
+ else {
19
+ throw new Error("Invalid distance function");
20
+ }
21
+ }
22
+ export function getCostMatrixMemorySizeMiB(sequence1Length, sequence2Length, windowLength) {
23
+ const costMatrixMemorySizeMiB = sequence1Length * Math.min(sequence2Length, windowLength) * 4 / 1000000;
24
+ return costMatrixMemorySizeMiB;
25
+ }
26
+ //# sourceMappingURL=DTWMfccSequenceAlignment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DTWMfccSequenceAlignment.js","sourceRoot":"","sources":["../../src/alignment/DTWMfccSequenceAlignment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mCAAmC,EAAE,2BAA2B,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACtI,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAA;AAEpE,MAAM,GAAG,GAAG,WAAW,CAAA;AAEvB,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,WAAuB,EAAE,WAAuB,EAAE,YAAoB,EAAE,mBAA2C,WAAW;IACjK,IAAI,gBAAgB,IAAI,WAAW,EAAE;QACpC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,gBAAgB,CACtC,WAAW,EACX,WAAW,EACX,iBAAiB,EACjB,YAAY,CACZ,CAAA;QAED,OAAO,IAAI,CAAA;KACX;SAAM,IAAI,gBAAgB,IAAI,QAAQ,EAAE;QACxC,MAAM,QAAQ,GAAG,2BAA2B,CAAC,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;QACnE,MAAM,QAAQ,GAAG,2BAA2B,CAAC,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;QAEnE,MAAM,WAAW,GAAG,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;QAC9C,MAAM,WAAW,GAAG,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;QAE9C,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,gBAAgB,CACtC,QAAQ,EACR,QAAQ,EACR,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,mCAAmC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,EAC7G,YAAY,CACZ,CAAA;QAED,OAAO,IAAI,CAAA;KACX;SAAM;QACN,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAA;KAC5C;AACF,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,eAAuB,EAAE,eAAuB,EAAE,YAAoB;IAChH,MAAM,uBAAuB,GAAG,eAAe,GAAG,IAAI,CAAC,GAAG,CAAC,eAAe,EAAE,YAAY,CAAC,GAAG,CAAC,GAAG,OAAO,CAAA;IACvG,OAAO,uBAAuB,CAAA;AAC/B,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { AlignmentPath } from "./SpeechAlignment.js";
2
+ export declare function alignDTW<T, U>(sequence1: T[], sequence2: U[], costFunction: (a: T, b: U) => number, deletionEnabled?: boolean): {
3
+ path: AlignmentPath;
4
+ pathCost: number;
5
+ };
@@ -0,0 +1,99 @@
1
+ import { logToStderr } from "../utilities/Utilities.js";
2
+ const log = logToStderr;
3
+ export function alignDTW(sequence1, sequence2, costFunction, deletionEnabled = true) {
4
+ if (sequence1.length == 0 || sequence2.length == 0) {
5
+ return { path: [], pathCost: 0 };
6
+ }
7
+ const rowCount = sequence2.length;
8
+ const columnCount = sequence1.length;
9
+ // Compute accumulated cost matrix
10
+ const accumulatedCostMatrix = computeAccumulatedCostMatrix(sequence1, sequence2, costFunction, deletionEnabled);
11
+ // Find best path for the computed matrix
12
+ const path = computeBestPath(accumulatedCostMatrix, deletionEnabled);
13
+ // Best path cost is the bottom right element of the matrix
14
+ const pathCost = accumulatedCostMatrix[rowCount - 1][columnCount - 1];
15
+ return { path, pathCost };
16
+ }
17
+ function computeAccumulatedCostMatrix(sequence1, sequence2, costFunction, deletionEnabled = true) {
18
+ const rowCount = sequence2.length;
19
+ const columnCount = sequence1.length;
20
+ const accumulatedCostMatrix = new Array(rowCount);
21
+ // Initialize matrix
22
+ for (let rowIndex = 0; rowIndex < rowCount; rowIndex++) {
23
+ accumulatedCostMatrix[rowIndex] = new Float32Array(columnCount);
24
+ }
25
+ for (let i = 1; i < columnCount; i++) {
26
+ accumulatedCostMatrix[0][i] = Infinity;
27
+ }
28
+ for (let i = 1; i < rowCount; i++) {
29
+ accumulatedCostMatrix[i][0] = Infinity;
30
+ }
31
+ // Fill out the matrix, go row by row
32
+ for (let rowIndex = 1; rowIndex < rowCount; rowIndex++) {
33
+ const previousRow = accumulatedCostMatrix[rowIndex - 1];
34
+ const currentRow = accumulatedCostMatrix[rowIndex];
35
+ for (let columnIndex = 1; columnIndex < columnCount; columnIndex++) {
36
+ const cost = costFunction(sequence1[columnIndex], sequence2[rowIndex]);
37
+ const up = previousRow[columnIndex]; // insertion
38
+ const left = currentRow[columnIndex - 1]; // deletion
39
+ const upAndLeft = previousRow[columnIndex - 1]; // match
40
+ currentRow[columnIndex] = cost + minimumOf3(up, deletionEnabled ? left : Infinity, upAndLeft);
41
+ }
42
+ }
43
+ return accumulatedCostMatrix;
44
+ }
45
+ function computeBestPath(costMatrix, deletionEnabled = true) {
46
+ const rowCount = costMatrix.length;
47
+ const columnCount = costMatrix[0].length;
48
+ const bestPath = [];
49
+ let rowIndex = rowCount - 1;
50
+ let columnIndex = columnCount - 1;
51
+ bestPath.push({
52
+ source: columnIndex,
53
+ dest: rowIndex
54
+ });
55
+ while (rowIndex > 0 || columnIndex > 0) {
56
+ const up = costMatrix[rowIndex - 1][columnIndex];
57
+ const left = costMatrix[rowIndex][columnIndex - 1];
58
+ const upAndLeft = costMatrix[rowIndex - 1][columnIndex - 1];
59
+ const smallestCostDirection = argIndexOfMinimumOf3(up, deletionEnabled ? left : Infinity, upAndLeft);
60
+ if (smallestCostDirection == 1) {
61
+ rowIndex -= 1;
62
+ }
63
+ else if (smallestCostDirection == 2) {
64
+ columnIndex -= 1;
65
+ }
66
+ else {
67
+ rowIndex -= 1;
68
+ columnIndex -= 1;
69
+ }
70
+ bestPath.push({
71
+ source: columnIndex,
72
+ dest: rowIndex
73
+ });
74
+ }
75
+ return bestPath.reverse();
76
+ }
77
+ function minimumOf3(x1, x2, x3) {
78
+ if (x1 <= x2 && x1 <= x3) {
79
+ return x1;
80
+ }
81
+ else if (x2 <= x3) {
82
+ return x2;
83
+ }
84
+ else {
85
+ return x3;
86
+ }
87
+ }
88
+ function argIndexOfMinimumOf3(x1, x2, x3) {
89
+ if (x1 <= x2 && x1 <= x3) {
90
+ return 1;
91
+ }
92
+ else if (x2 <= x3) {
93
+ return 2;
94
+ }
95
+ else {
96
+ return 3;
97
+ }
98
+ }
99
+ //# sourceMappingURL=DTWSequenceAlignment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DTWSequenceAlignment.js","sourceRoot":"","sources":["../../src/alignment/DTWSequenceAlignment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAGvD,MAAM,GAAG,GAAG,WAAW,CAAA;AAEvB,MAAM,UAAU,QAAQ,CAAO,SAAc,EAAE,SAAc,EAAE,YAAoC,EAAE,eAAe,GAAG,IAAI;IAC1H,IAAI,SAAS,CAAC,MAAM,IAAI,CAAC,IAAI,SAAS,CAAC,MAAM,IAAI,CAAC,EAAE;QACnD,OAAO,EAAE,IAAI,EAAE,EAAmB,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAA;KACjD;IAED,MAAM,QAAQ,GAAG,SAAS,CAAC,MAAM,CAAA;IACjC,MAAM,WAAW,GAAG,SAAS,CAAC,MAAM,CAAA;IAEpC,kCAAkC;IAClC,MAAM,qBAAqB,GAAG,4BAA4B,CAAC,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,eAAe,CAAC,CAAA;IAE/G,yCAAyC;IACzC,MAAM,IAAI,GAAG,eAAe,CAAC,qBAAqB,EAAE,eAAe,CAAC,CAAA;IAEpE,2D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AC,CAAC,WAAW,GAAG,CAAC,CAAC,CAAA;QAE3D,MAAM,qBAAqB,GAAG,oBAAoB,CAAC,EAAE,EAAE,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAA;QAEpG,IAAI,qBAAqB,IAAI,CAAC,EAAE;YAC/B,QAAQ,IAAI,CAAC,CAAA;SACb;aAAM,IAAI,qBAAqB,IAAI,CAAC,EAAE;YACtC,WAAW,IAAI,CAAC,CAAA;SAChB;aAAM;YACN,QAAQ,IAAI,CAAC,CAAA;YACb,WAAW,IAAI,CAAC,CAAA;SAChB;QAED,QAAQ,CAAC,IAAI,CAAC;YACb,MAAM,EAAE,WAAW;YACnB,IAAI,EAAE,QAAQ;SACd,CAAC,CAAA;KACF;IAED,OAAO,QAAQ,CAAC,OAAO,EAAmB,CAAA;AAC3C,CAAC;AAED,SAAS,UAAU,CAAC,EAAU,EAAE,EAAU,EAAE,EAAU;IACrD,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;QACzB,OAAO,EAAE,CAAA;KACT;SAAM,IAAI,EAAE,IAAI,EAAE,EAAE;QACpB,OAAO,EAAE,CAAA;KACT;SAAM;QACN,OAAO,EAAE,CAAA;KACT;AACF,CAAC;AAED,SAAS,oBAAoB,CAAC,EAAU,EAAE,EAAU,EAAE,EAAU;IAC/D,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;QACzB,OAAO,CAAC,CAAA;KACR;SAAM,IAAI,EAAE,IAAI,EAAE,EAAE;QACpB,OAAO,CAAC,CAAA;KACR;SAAM;QACN,OAAO,CAAC,CAAA;KACR;AACF,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { AlignmentPath } from "./SpeechAlignment.js";
2
+ export declare function alignDTWWindowed<T, U>(sequence1: T[], sequence2: U[], costFunction: (a: T, b: U) => number, windowMaxLength: number): {
3
+ path: AlignmentPath;
4
+ pathCost: number;
5
+ };
@@ -0,0 +1,161 @@
1
+ import { logToStderr } from "../utilities/Utilities.js";
2
+ const log = logToStderr;
3
+ export function alignDTWWindowed(sequence1, sequence2, costFunction, windowMaxLength) {
4
+ if (windowMaxLength < 2) {
5
+ throw new Error("Window length must be greater or equal to 2");
6
+ }
7
+ if (sequence1.length == 0 || sequence2.length == 0) {
8
+ return { path: [], pathCost: 0 };
9
+ }
10
+ // Compute accumulated cost matrix (transposed)
11
+ const { accumulatedCostMatrixTransposed, windowStartOffsets } = computeAccumulatedCostMatrixTransposed(sequence1, sequence2, costFunction, windowMaxLength);
12
+ // Find best path for the computed matrix
13
+ const path = computeBestPathTransposed(accumulatedCostMatrixTransposed, windowStartOffsets);
14
+ // Best path cost is the bottom right element of the matrix
15
+ const columnCount = accumulatedCostMatrixTransposed.length;
16
+ const rowCount = accumulatedCostMatrixTransposed[0].length;
17
+ const pathCost = accumulatedCostMatrixTransposed[columnCount - 1][rowCount - 1];
18
+ // Return
19
+ return { path, pathCost };
20
+ }
21
+ function computeAccumulatedCostMatrixTransposed(sequence1, sequence2, costFunction, windowMaxLength) {
22
+ const halfWindowMaxLength = Math.floor(windowMaxLength / 2);
23
+ const columnCount = sequence1.length;
24
+ const rowCount = Math.min(windowMaxLength, sequence2.length);
25
+ const accumulatedCostMatrixTransposed = new Array(columnCount);
26
+ // Initialize window start offsets array
27
+ const windowStartOffsets = new Int32Array(columnCount);
28
+ // Compute matrix column by column
29
+ for (let columnIndex = 0; columnIndex < columnCount; columnIndex++) {
30
+ // Create new column and add it to the matrix
31
+ const currentColumn = new Float32Array(rowCount);
32
+ accumulatedCostMatrixTransposed[columnIndex] = currentColumn;
33
+ // Compute window center
34
+ const windowCenter = Math.floor((columnIndex / columnCount) * sequence2.length);
35
+ // Compute window start and end offsets
36
+ let windowStartOffset = Math.max(windowCenter - halfWindowMaxLength, 0);
37
+ let windowEndOffset = windowStartOffset + rowCount;
38
+ if (windowEndOffset > sequence2.length) {
39
+ windowEndOffset = sequence2.length;
40
+ windowStartOffset = windowEndOffset - rowCount;
41
+ }
42
+ // Store the start offset in the array
43
+ windowStartOffsets[columnIndex] = windowStartOffset;
44
+ // Get target sequence1 value
45
+ const targetSequence1Value = sequence1[columnIndex];
46
+ // If first column, fill it only using the 'up' neighbor
47
+ if (columnIndex == 0) {
48
+ for (let rowIndex = 1; rowIndex < rowCount; rowIndex++) {
49
+ const cost = costFunction(targetSequence1Value, sequence2[windowStartOffset + rowIndex]);
50
+ const upCost = currentColumn[rowIndex - 1];
51
+ currentColumn[rowIndex] = cost + upCost;
52
+ }
53
+ continue;
54
+ }
55
+ // If not first column
56
+ const leftColumn = accumulatedCostMatrixTransposed[columnIndex - 1];
57
+ // Compute the delta between the current window offset and previous column's window offset
58
+ const windowOffsetDelta = windowStartOffset - windowStartOffsets[columnIndex - 1];
59
+ for (let rowIndex = 0; rowIndex < rowCount; rowIndex++) {
60
+ // Compute the cost for current cell
61
+ const cost = costFunction(targetSequence1Value, sequence2[windowStartOffset + rowIndex]);
62
+ // Retrieve the cost for the 'up' (insertion) neighbor
63
+ let upCost = Infinity;
64
+ if (rowIndex > 0) {
65
+ upCost = currentColumn[rowIndex - 1];
66
+ }
67
+ // Retrieve the cost for the 'left' (deletion) neighbor
68
+ let leftCost = Infinity;
69
+ const leftRowIndex = rowIndex + windowOffsetDelta;
70
+ if (leftRowIndex < rowCount) {
71
+ leftCost = leftColumn[leftRowIndex];
72
+ }
73
+ // Retrieve the cost for the 'up and left' (match) neighbor
74
+ let upAndLeftCost = Infinity;
75
+ const upAndLeftRowIndex = leftRowIndex - 1;
76
+ if (upAndLeftRowIndex >= 0 && upAndLeftRowIndex < rowCount) {
77
+ upAndLeftCost = leftColumn[upAndLeftRowIndex];
78
+ }
79
+ // Write cost + minimum neighbor cost to the current column
80
+ currentColumn[rowIndex] = cost + minimumOf3(upCost, leftCost, upAndLeftCost);
81
+ }
82
+ }
83
+ return { accumulatedCostMatrixTransposed, windowStartOffsets };
84
+ }
85
+ function computeBestPathTransposed(accumulatedCostMatrixTransposed, windowStartOffsets) {
86
+ const columnCount = accumulatedCostMatrixTransposed.length;
87
+ const rowCount = accumulatedCostMatrixTransposed[0].length;
88
+ const bestPath = [];
89
+ let columnIndex = columnCount - 1;
90
+ let rowIndex = rowCount - 1;
91
+ while (columnIndex > 0 || rowIndex > 0) {
92
+ const windowStartIndex = windowStartOffsets[columnIndex];
93
+ const windowStartDelta = columnIndex > 0 ? windowStartIndex - windowStartOffsets[columnIndex - 1] : 0;
94
+ bestPath.push({
95
+ source: columnIndex,
96
+ dest: windowStartIndex + rowIndex
97
+ });
98
+ const upRowIndex = rowIndex - 1;
99
+ const upColumnIndex = columnIndex;
100
+ let upCost = Infinity;
101
+ if (upRowIndex >= 0) {
102
+ upCost = accumulatedCostMatrixTransposed[upColumnIndex][upRowIndex]; // insertion
103
+ }
104
+ const leftRowIndex = rowIndex + windowStartDelta;
105
+ const leftColumnIndex = columnIndex - 1;
106
+ let leftCost = Infinity;
107
+ if (leftColumnIndex >= 0 && leftRowIndex < rowCount) {
108
+ leftCost = accumulatedCostMatrixTransposed[leftColumnIndex][leftRowIndex]; // deletion
109
+ }
110
+ const upAndLeftRowIndex = rowIndex - 1 + windowStartDelta;
111
+ const upAndLeftColumnIndex = columnIndex - 1;
112
+ let upAndLeftCost = Infinity;
113
+ if (upAndLeftColumnIndex >= 0 && upAndLeftRowIndex >= 0 && upAndLeftRowIndex < rowCount) {
114
+ upAndLeftCost = accumulatedCostMatrixTransposed[upAndLeftColumnIndex][upAndLeftRowIndex]; // match
115
+ }
116
+ if (upCost == Infinity && leftCost == Infinity && upAndLeftCost == Infinity) {
117
+ log(`computeBestPath: Unexpected - all cost directions are equal to infinity (${columnIndex}, ${rowIndex}).`);
118
+ }
119
+ const smallestCostDirection = argIndexOfMinimumOf3(upCost, leftCost, upAndLeftCost);
120
+ if (smallestCostDirection == 1) {
121
+ rowIndex = upRowIndex;
122
+ columnIndex = upColumnIndex;
123
+ }
124
+ else if (smallestCostDirection == 2) {
125
+ rowIndex = leftRowIndex;
126
+ columnIndex = leftColumnIndex;
127
+ }
128
+ else {
129
+ rowIndex = upAndLeftRowIndex;
130
+ columnIndex = upAndLeftColumnIndex;
131
+ }
132
+ }
133
+ bestPath.push({
134
+ source: 0,
135
+ dest: 0
136
+ });
137
+ return bestPath.reverse();
138
+ }
139
+ function minimumOf3(x1, x2, x3) {
140
+ if (x1 <= x2 && x1 <= x3) {
141
+ return x1;
142
+ }
143
+ else if (x2 <= x3) {
144
+ return x2;
145
+ }
146
+ else {
147
+ return x3;
148
+ }
149
+ }
150
+ function argIndexOfMinimumOf3(x1, x2, x3) {
151
+ if (x1 <= x2 && x1 <= x3) {
152
+ return 1;
153
+ }
154
+ else if (x2 <= x3) {
155
+ return 2;
156
+ }
157
+ else {
158
+ return 3;
159
+ }
160
+ }
161
+ //# sourceMappingURL=DTWSequenceAlignmentWindowed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DTWSequenceAlignmentWindowed.js","sourceRoot":"","sources":["../../src/alignment/DTWSequenceAlignmentWindowed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAGvD,MAAM,GAAG,GAAG,WAAW,CAAA;AAEvB,MAAM,UAAU,gBAAgB,CAAO,SAAc,EAAE,SAAc,EAAE,YAAoC,EAAE,eAAuB;IACnI,IAAI,eAAe,GAAG,CAAC,EAAE;QACxB,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAA;KAC9D;IAED,IAAI,SAAS,CAAC,MAAM,IAAI,CAAC,IAAI,SAAS,CAAC,MAAM,IAAI,CAAC,EAAE;QACnD,OAAO,EAAE,IAAI,EAAE,EAAmB,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAA;KACjD;IAED,+CAA+C;IAC/C,MAAM,EAAE,+BAA+B,EAAE,kBAAkB,EAAE,GAAG,sCAAsC,CAAC,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,eAAe,CA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,CAAC,CAAA;SAC7G;QAED,MAAM,qBAAqB,GAAG,oBAAoB,CAAC,MAAM,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAA;QAEnF,IAAI,qBAAqB,IAAI,CAAC,EAAE;YAC/B,QAAQ,GAAG,UAAU,CAAA;YACrB,WAAW,GAAG,aAAa,CAAA;SAC3B;aAAM,IAAI,qBAAqB,IAAI,CAAC,EAAE;YACtC,QAAQ,GAAG,YAAY,CAAA;YACvB,WAAW,GAAG,eAAe,CAAA;SAC7B;aAAM;YACN,QAAQ,GAAG,iBAAiB,CAAA;YAC5B,WAAW,GAAG,oBAAoB,CAAA;SAClC;KACD;IAED,QAAQ,CAAC,IAAI,CAAC;QACb,MAAM,EAAE,CAAC;QACT,IAAI,EAAE,CAAC;KACP,CAAC,CAAA;IAEF,OAAO,QAAQ,CAAC,OAAO,EAAmB,CAAA;AAC3C,CAAC;AAED,SAAS,UAAU,CAAC,EAAU,EAAE,EAAU,EAAE,EAAU;IACrD,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;QACzB,OAAO,EAAE,CAAA;KACT;SAAM,IAAI,EAAE,IAAI,EAAE,EAAE;QACpB,OAAO,EAAE,CAAA;KACT;SAAM;QACN,OAAO,EAAE,CAAA;KACT;AACF,CAAC;AAED,SAAS,oBAAoB,CAAC,EAAU,EAAE,EAAU,EAAE,EAAU;IAC/D,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;QACzB,OAAO,CAAC,CAAA;KACR;SAAM,IAAI,EAAE,IAAI,EAAE,EAAE;QACpB,OAAO,CAAC,CAAA;KACR;SAAM;QACN,OAAO,CAAC,CAAA;KACR;AACF,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { AlignmentPath } from "./SpeechAlignment.js";
2
+ export declare function alignLevenshtein<T, U>(sequence1: T[], sequence2: U[], getSubstitutionCost: (a: T, b: U) => number): {
3
+ path: AlignmentPath;
4
+ pathCost: number;
5
+ };
@@ -0,0 +1,102 @@
1
+ import { logToStderr } from "../utilities/Utilities.js";
2
+ const log = logToStderr;
3
+ export function alignLevenshtein(sequence1, sequence2, getSubstitutionCost) {
4
+ const rowCount = sequence2.length + 1;
5
+ const columnCount = sequence1.length + 1;
6
+ // Compute accumulated cost matrix
7
+ const accumulatedCostMatrix = computeAccumulatedCostMatrix(sequence1, sequence2, getSubstitutionCost);
8
+ // Find best path for the computed matrix
9
+ const path = computeBestPath(accumulatedCostMatrix);
10
+ // Best path cost is the bottom right element of the matrix
11
+ const pathCost = accumulatedCostMatrix[rowCount - 1][columnCount - 1];
12
+ return { path, pathCost };
13
+ }
14
+ function computeAccumulatedCostMatrix(sequence1, sequence2, getSubstitutionCost) {
15
+ const rowCount = sequence2.length + 1;
16
+ const columnCount = sequence1.length + 1;
17
+ const accumulatedCostMatrix = new Array(rowCount);
18
+ // Allocate rows and initialize first column
19
+ for (let rowIndex = 0; rowIndex < rowCount; rowIndex++) {
20
+ const newRow = new Float32Array(columnCount);
21
+ newRow[0] = rowIndex;
22
+ accumulatedCostMatrix[rowIndex] = newRow;
23
+ }
24
+ // Initialize first row
25
+ for (let columnIndex = 0; columnIndex < columnCount; columnIndex++) {
26
+ accumulatedCostMatrix[0][columnIndex] = columnIndex;
27
+ }
28
+ // Fill out the rest of the matrix, go row by row
29
+ for (let rowIndex = 1; rowIndex < rowCount; rowIndex++) {
30
+ const previousRow = accumulatedCostMatrix[rowIndex - 1];
31
+ const currentRow = accumulatedCostMatrix[rowIndex];
32
+ for (let columnIndex = 1; columnIndex < columnCount; columnIndex++) {
33
+ const upAndLeft = previousRow[columnIndex - 1];
34
+ const up = previousRow[columnIndex];
35
+ const left = currentRow[columnIndex - 1];
36
+ const smallestCostDirection = argIndexOfSmallestOf3(upAndLeft, up, left);
37
+ let computedCostForCurrentElement;
38
+ if (smallestCostDirection == 1) {
39
+ const subtitutionCost = getSubstitutionCost(sequence1[columnIndex - 1], sequence2[rowIndex - 1]);
40
+ computedCostForCurrentElement = upAndLeft + subtitutionCost;
41
+ }
42
+ else if (smallestCostDirection == 2) {
43
+ computedCostForCurrentElement = up + 1;
44
+ }
45
+ else {
46
+ computedCostForCurrentElement = left + 1;
47
+ }
48
+ currentRow[columnIndex] = computedCostForCurrentElement;
49
+ }
50
+ }
51
+ return accumulatedCostMatrix;
52
+ }
53
+ function computeBestPath(costMatrix) {
54
+ const bestPath = [];
55
+ let rowIndex = costMatrix.length - 1;
56
+ let columnIndex = costMatrix[0].length - 1;
57
+ while (rowIndex > 1 || columnIndex > 1) {
58
+ bestPath.push({
59
+ source: columnIndex - 1,
60
+ dest: rowIndex - 1
61
+ });
62
+ if (rowIndex == 1) {
63
+ columnIndex -= 1;
64
+ continue;
65
+ }
66
+ if (columnIndex == 1) {
67
+ rowIndex -= 1;
68
+ continue;
69
+ }
70
+ const upAndLeft = costMatrix[rowIndex - 1][columnIndex - 1];
71
+ const up = costMatrix[rowIndex - 1][columnIndex];
72
+ const left = costMatrix[rowIndex][columnIndex - 1];
73
+ const smallestCostDirection = argIndexOfSmallestOf3(upAndLeft, up, left);
74
+ if (smallestCostDirection == 1) {
75
+ rowIndex -= 1;
76
+ columnIndex -= 1;
77
+ }
78
+ else if (smallestCostDirection == 2) {
79
+ rowIndex -= 1;
80
+ }
81
+ else {
82
+ columnIndex -= 1;
83
+ }
84
+ }
85
+ bestPath.push({
86
+ source: 0,
87
+ dest: 0
88
+ });
89
+ return bestPath.reverse();
90
+ }
91
+ function argIndexOfSmallestOf3(x1, x2, x3) {
92
+ if (x1 <= x2 && x1 <= x3) {
93
+ return 1;
94
+ }
95
+ else if (x2 <= x3) {
96
+ return 2;
97
+ }
98
+ else {
99
+ return 3;
100
+ }
101
+ }
102
+ //# sourceMappingURL=LevenshteinSequenceAlignment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LevenshteinSequenceAlignment.js","sourceRoot":"","sources":["../../src/alignment/LevenshteinSequenceAlignment.ts"],"names":[],"mappings":"AAAA,OAAO,EAA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AAC,EAAU,EAAE,EAAU,EAAE,EAAU;IAChE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;QACzB,OAAO,CAAC,CAAA;KACR;SAAM,IAAI,EAAE,IAAI,EAAE,EAAE;QACpB,OAAO,CAAC,CAAA;KACR;SAAM;QACN,OAAO,CAAC,CAAA;KACR;AACF,CAAC"}
@@ -0,0 +1,27 @@
1
+ import * as API from "../api/API.js";
2
+ import { Timeline, TimelineEntry } from "../utilities/Timeline.js";
3
+ import { RawAudio } from "../audio/AudioUtilities.js";
4
+ export declare function alignUsingDtw(sourceRawAudio: RawAudio, referenceRawAudio: RawAudio, referenceTimeline: Timeline, windowDuration?: number): Promise<TimelineEntry[]>;
5
+ export declare function alignUsingDtwWithRecognition(sourceRawAudio: RawAudio, referenceRawAudio: RawAudio, referenceTimeline: Timeline, recognitionTimeline: Timeline, espeakVoice?: string, phoneAlignmentMethod?: API.PhoneAlignmentMethod, windowDuration?: number): Promise<Timeline>;
6
+ export declare function interpolatePhoneTimelines(sourceTimeline: Timeline, referenceTimeline: Timeline): Promise<Timeline>;
7
+ export declare function alignPhoneTimelines(sourceRawAudio: RawAudio, sourceWordTimeline: Timeline, referenceRawAudio: RawAudio, referenceTimeline: Timeline): Promise<Timeline>;
8
+ export declare function createAlignmentReferenceUsingEspeak(text: string, language: string, voice: string, insertSeparators?: boolean, rate?: number, pitch?: number, pitchRange?: number): Promise<{
9
+ rawAudio: RawAudio;
10
+ timeline: Timeline;
11
+ events: import("../synthesis/EspeakTTS.js").EspeakEvent[];
12
+ }>;
13
+ export declare function createAlignmentReferenceUsingEspeakForFragments(fragments: string[], voice: string, insertSeparators?: boolean, rate?: number, pitch?: number, pitchRange?: number): Promise<{
14
+ rawAudio: RawAudio;
15
+ timeline: Timeline;
16
+ events: import("../synthesis/EspeakTTS.js").EspeakEvent[];
17
+ }>;
18
+ export type AlignmentPath = AlignmentPathEntry[];
19
+ export type AlignmentPathEntry = {
20
+ source: number;
21
+ dest: number;
22
+ };
23
+ export type CompactedPath = CompactedPathEntry[];
24
+ export type CompactedPathEntry = {
25
+ first: number;
26
+ last: number;
27
+ };