echogarden 0.11.12 → 0.11.13
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.
- package/data/schemas/options.json +16 -0
- package/dist/api/Alignment.js +2 -2
- package/dist/api/Alignment.js.map +1 -1
- package/dist/api/Recognition.js +2 -2
- package/dist/api/Recognition.js.map +1 -1
- package/dist/api/Synthesis.js +5 -4
- package/dist/api/Synthesis.js.map +1 -1
- package/dist/api/Translation.js +2 -2
- package/dist/api/Translation.js.map +1 -1
- package/dist/audio/AudioUtilities.d.ts +1 -0
- package/dist/audio/AudioUtilities.js +25 -7
- package/dist/audio/AudioUtilities.js.map +1 -1
- package/dist/cli/CLI.js +2 -2
- package/dist/cli/CLI.js.map +1 -1
- package/dist/recognition/WhisperSTT.js +2 -2
- package/dist/recognition/WhisperSTT.js.map +1 -1
- package/dist/subtitles/Subtitles.d.ts +10 -7
- package/dist/subtitles/Subtitles.js +268 -207
- package/dist/subtitles/Subtitles.js.map +1 -1
- package/docs/Options.md +4 -2
- package/package.json +7 -6
- package/src/alignment/DTWMfccSequenceAlignment.ts +43 -0
- package/src/alignment/DTWSequenceAlignment.ts +121 -0
- package/src/alignment/DTWSequenceAlignmentWindowed.ts +210 -0
- package/src/alignment/LevenshteinSequenceAlignment.ts +126 -0
- package/src/alignment/SpeechAlignment.ts +488 -0
- package/src/api/API.ts +12 -0
- package/src/api/APIOptions.ts +15 -0
- package/src/api/Alignment.ts +329 -0
- package/src/api/Common.ts +16 -0
- package/src/api/Denoising.ts +120 -0
- package/src/api/LanguageDetection.ts +286 -0
- package/src/api/Recognition.ts +344 -0
- package/src/api/Synthesis.ts +1735 -0
- package/src/api/Translation.ts +143 -0
- package/src/api/Vad.ts +172 -0
- package/src/audio/AudioBufferConversion.ts +248 -0
- package/src/audio/AudioPlayer.ts +358 -0
- package/src/audio/AudioRecorder.ts +91 -0
- package/src/audio/AudioUtilities.ts +392 -0
- package/src/audio/SoxPath.ts +24 -0
- package/src/cli/CLI.ts +1360 -0
- package/src/cli/CLIConfigFile.ts +91 -0
- package/src/cli/CLILauncher.ts +26 -0
- package/src/cli/CLIOptionsSchema.ts +54 -0
- package/src/cli/CLIParser.ts +41 -0
- package/src/cli/CLIStarter.ts +40 -0
- package/src/codecs/FFMpegTranscoder.ts +214 -0
- package/src/codecs/TIMITCodec.ts +17 -0
- package/src/codecs/WaveCodec.ts +260 -0
- package/src/denoising/RNNoise.ts +95 -0
- package/src/dsp/BiquadFilter.ts +488 -0
- package/src/dsp/FFT.ts +187 -0
- package/src/dsp/MFCC.ts +227 -0
- package/src/dsp/MelSpectogram.ts +145 -0
- package/src/dsp/Rubberband.ts +249 -0
- package/src/dsp/Sonic.ts +59 -0
- package/src/dsp/SpeexResampler.ts +79 -0
- package/src/math/VectorMath.ts +812 -0
- package/src/nlp/ChineseSegmentation.ts +68 -0
- package/src/nlp/CompromiseNLP.ts +113 -0
- package/src/nlp/EspeakPhonemizer.ts +168 -0
- package/src/nlp/IPA.ts +139 -0
- package/src/nlp/JapaneseSegmentation.ts +53 -0
- package/src/nlp/Lexicon.ts +119 -0
- package/src/nlp/PhoneConversion.ts +508 -0
- package/src/nlp/Segmentation.ts +237 -0
- package/src/nlp/TextNormalizer.ts +160 -0
- package/src/recognition/AmazonTranscribeSTT.ts +112 -0
- package/src/recognition/AzureCognitiveServicesSTT.ts +76 -0
- package/src/recognition/GoogleCloudSTT.ts +92 -0
- package/src/recognition/SileroSTT.ts +173 -0
- package/src/recognition/VoskSTT.ts +112 -0
- package/src/recognition/WhisperSTT.ts +1518 -0
- package/src/server/Client.ts +297 -0
- package/src/server/Server.ts +178 -0
- package/src/server/ServerStarter.ts +12 -0
- package/src/server/Worker.ts +400 -0
- package/src/server/WorkerStarter.ts +38 -0
- package/src/speech-language-detection/SileroLanguageDetection.ts +105 -0
- package/src/subtitles/Subtitles.ts +478 -0
- package/src/synthesis/AwsPollyTTS.ts +78 -0
- package/src/synthesis/AzureCognitiveServicesTTS.ts +146 -0
- package/src/synthesis/CoquiServerTTS.ts +29 -0
- package/src/synthesis/ElevenLabsTTS.ts +104 -0
- package/src/synthesis/EspeakTTS.ts +552 -0
- package/src/synthesis/FliteTTS.ts +387 -0
- package/src/synthesis/GoogleCloudTTS.ts +112 -0
- package/src/synthesis/GoogleTranslateTTS.ts +210 -0
- package/src/synthesis/MicrosoftEdgeTTS.ts +298 -0
- package/src/synthesis/SamTTS.ts +30 -0
- package/src/synthesis/SapiTTS.ts +222 -0
- package/src/synthesis/StreamlabsPollyTTS.ts +114 -0
- package/src/synthesis/SvoxPicoTTS.ts +318 -0
- package/src/synthesis/VitsTTS.ts +734 -0
- package/src/tests/Test.ts +24 -0
- package/src/text-language-detection/FastTextLanguageDetection.ts +53 -0
- package/src/text-language-detection/TinyLDLanguageDetection.ts +16 -0
- package/src/typings/Fillers.d.ts +41 -0
- package/src/utilities/BinaryArrayConversion.ts +159 -0
- package/src/utilities/Compression.ts +91 -0
- package/src/utilities/FileDownloader.ts +201 -0
- package/src/utilities/FileSystem.ts +265 -0
- package/src/utilities/Hashing.ts +230 -0
- package/src/utilities/Locale.ts +119 -0
- package/src/utilities/Logger.ts +72 -0
- package/src/utilities/NdArrayUtilities.ts +31 -0
- package/src/utilities/ObjectUtilities.ts +169 -0
- package/src/utilities/OpenPromise.ts +13 -0
- package/src/utilities/PackageManager.ts +97 -0
- package/src/utilities/Queue.ts +17 -0
- package/src/utilities/RandomGenerator.ts +237 -0
- package/src/utilities/SignalChannel.ts +22 -0
- package/src/utilities/TarballMaker.ts +68 -0
- package/src/utilities/Timeline.ts +231 -0
- package/src/utilities/Timer.ts +93 -0
- package/src/utilities/Utilities.ts +574 -0
- package/src/utilities/WasmMemoryManager.ts +516 -0
- package/src/utilities/WebReader.ts +55 -0
- package/src/utilities/WikipediaReader.ts +41 -0
- package/src/voice-activity-detection/SileroVAD.ts +86 -0
- package/src/voice-activity-detection/WebRtcVAD.ts +76 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { RawAudio, cloneRawAudio } from "../audio/AudioUtilities.js"
|
|
2
|
+
import { WasmMemoryManager } from "../utilities/WasmMemoryManager.js"
|
|
3
|
+
|
|
4
|
+
let speexResamplerInstance: any
|
|
5
|
+
|
|
6
|
+
export async function resampleAudioSpeex(rawAudio: RawAudio, outSampleRate: number, quality = 0) {
|
|
7
|
+
const channelCount = rawAudio.audioChannels.length
|
|
8
|
+
const inSampleRate = rawAudio.sampleRate
|
|
9
|
+
|
|
10
|
+
if (inSampleRate == outSampleRate) {
|
|
11
|
+
return cloneRawAudio(rawAudio)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const m = await getSpeexResamplerInstance()
|
|
15
|
+
const wasmMemory = new WasmMemoryManager(m)
|
|
16
|
+
|
|
17
|
+
function speexResultCodeToString(resultCode: number) {
|
|
18
|
+
const errorStrPtr = m._speex_resampler_strerror(resultCode)
|
|
19
|
+
const errorStrRef = wasmMemory.wrapUint8Array(errorStrPtr, 1024)
|
|
20
|
+
const message = errorStrRef.readAsNullTerminatedUtf8String()
|
|
21
|
+
|
|
22
|
+
return message
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const initErrRef = wasmMemory.allocInt32()
|
|
26
|
+
const resamplerState = m._speex_resampler_init(channelCount, inSampleRate, outSampleRate, quality, initErrRef.address)
|
|
27
|
+
let resultCode = initErrRef.value
|
|
28
|
+
|
|
29
|
+
if (resultCode != 0) {
|
|
30
|
+
throw new Error(`Speex resampler failed while initializing with code ${resultCode}: ${speexResultCodeToString(resultCode)}`)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const resampledAudio: RawAudio = { audioChannels: [], sampleRate: outSampleRate }
|
|
34
|
+
|
|
35
|
+
for (let channelIndex = 0; channelIndex < channelCount; channelIndex++) {
|
|
36
|
+
const channelSamples = rawAudio.audioChannels[channelIndex]
|
|
37
|
+
|
|
38
|
+
const inputLatency = m._speex_resampler_get_input_latency(resamplerState)
|
|
39
|
+
const outputLatency = m._speex_resampler_get_output_latency(resamplerState)
|
|
40
|
+
|
|
41
|
+
const inSampleCount = channelSamples.length
|
|
42
|
+
const inSampleCountRef = wasmMemory.allocInt32()
|
|
43
|
+
inSampleCountRef.value = inSampleCount + inputLatency
|
|
44
|
+
|
|
45
|
+
const inSamplesRef = wasmMemory.allocFloat32Array(inSampleCountRef.value)
|
|
46
|
+
inSamplesRef.view.set(channelSamples)
|
|
47
|
+
|
|
48
|
+
const outSampleCount = Math.floor((inSampleCount / inSampleRate) * outSampleRate)
|
|
49
|
+
const outSampleCountRef = wasmMemory.allocInt32()
|
|
50
|
+
outSampleCountRef.value = outSampleCount + outputLatency
|
|
51
|
+
|
|
52
|
+
const outSamplesRef = wasmMemory.allocFloat32Array(outSampleCountRef.value)
|
|
53
|
+
|
|
54
|
+
resultCode = m._speex_resampler_process_float(resamplerState, channelIndex, inSamplesRef.address, inSampleCountRef.address, outSamplesRef.address, outSampleCountRef.address)
|
|
55
|
+
|
|
56
|
+
if (resultCode != 0) {
|
|
57
|
+
throw new Error(`Speex resampler failed while resampling with code ${resultCode}: ${speexResultCodeToString(resultCode)}`)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const resampledChannelAudio = outSamplesRef.view.slice(outputLatency)
|
|
61
|
+
|
|
62
|
+
resampledAudio.audioChannels.push(resampledChannelAudio)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
m._speex_resampler_destroy(resamplerState)
|
|
66
|
+
wasmMemory.freeAll()
|
|
67
|
+
|
|
68
|
+
return resampledAudio
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export async function getSpeexResamplerInstance() {
|
|
72
|
+
if (!speexResamplerInstance) {
|
|
73
|
+
const { default: SpeexResamplerInitializer } = await import('@echogarden/speex-resampler-wasm')
|
|
74
|
+
|
|
75
|
+
speexResamplerInstance = await SpeexResamplerInitializer()
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return speexResamplerInstance
|
|
79
|
+
}
|