echogarden 2.10.2 → 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.
- package/LICENSE.MIT.md +7 -0
- package/README.md +9 -1
- package/data/lexicons/heteronyms.en.json +44 -10
- package/data/lexicons/words.en.json +726 -22
- package/data/schemas/options.json +91 -153
- package/dist/alignment/DTWMfccSequenceAlignment.js.map +1 -1
- package/dist/alignment/SemanticTextAlignment.d.ts +4 -2
- package/dist/alignment/SemanticTextAlignment.d.ts.map +1 -1
- package/dist/alignment/SemanticTextAlignment.js +7 -7
- package/dist/alignment/SemanticTextAlignment.js.map +1 -1
- package/dist/alignment/SpeechAlignment.d.ts +9 -10
- package/dist/alignment/SpeechAlignment.d.ts.map +1 -1
- package/dist/alignment/SpeechAlignment.js +23 -96
- package/dist/alignment/SpeechAlignment.js.map +1 -1
- package/dist/api/APIOptions.d.ts +1 -1
- package/dist/api/APIOptions.d.ts.map +1 -1
- package/dist/api/Alignment.d.ts +8 -6
- package/dist/api/Alignment.d.ts.map +1 -1
- package/dist/api/Alignment.js +31 -40
- package/dist/api/Alignment.js.map +1 -1
- package/dist/api/Common.d.ts +7 -0
- package/dist/api/Common.d.ts.map +1 -1
- package/dist/api/Common.js.map +1 -1
- package/dist/api/Denoising.d.ts +5 -2
- package/dist/api/Denoising.d.ts.map +1 -1
- package/dist/api/Denoising.js +15 -15
- package/dist/api/Denoising.js.map +1 -1
- package/dist/api/GlobalOptions.d.ts +2 -8
- package/dist/api/GlobalOptions.d.ts.map +1 -1
- package/dist/api/GlobalOptions.js +2 -13
- package/dist/api/GlobalOptions.js.map +1 -1
- package/dist/api/Recognition.d.ts +11 -12
- package/dist/api/Recognition.d.ts.map +1 -1
- package/dist/api/Recognition.js +32 -82
- package/dist/api/Recognition.js.map +1 -1
- package/dist/api/SourceSeparation.d.ts +7 -2
- package/dist/api/SourceSeparation.d.ts.map +1 -1
- package/dist/api/SourceSeparation.js +12 -10
- package/dist/api/SourceSeparation.js.map +1 -1
- package/dist/api/SpeechLanguageDetection.d.ts +11 -7
- package/dist/api/SpeechLanguageDetection.d.ts.map +1 -1
- package/dist/api/SpeechLanguageDetection.js +37 -30
- package/dist/api/SpeechLanguageDetection.js.map +1 -1
- package/dist/api/SpeechSearch.d.ts +4 -1
- package/dist/api/SpeechSearch.d.ts.map +1 -1
- package/dist/api/SpeechSearch.js.map +1 -1
- package/dist/api/SpeechTranslation.d.ts +10 -6
- package/dist/api/SpeechTranslation.d.ts.map +1 -1
- package/dist/api/SpeechTranslation.js +28 -26
- package/dist/api/SpeechTranslation.js.map +1 -1
- package/dist/api/Synthesis.d.ts +13 -8
- package/dist/api/Synthesis.d.ts.map +1 -1
- package/dist/api/Synthesis.js +67 -89
- package/dist/api/Synthesis.js.map +1 -1
- package/dist/api/TextLanguageDetection.d.ts +4 -2
- package/dist/api/TextLanguageDetection.d.ts.map +1 -1
- package/dist/api/TextLanguageDetection.js +4 -7
- package/dist/api/TextLanguageDetection.js.map +1 -1
- package/dist/api/TextTranslation.d.ts +4 -2
- package/dist/api/TextTranslation.d.ts.map +1 -1
- package/dist/api/TextTranslation.js +13 -24
- package/dist/api/TextTranslation.js.map +1 -1
- package/dist/api/TimelineTranslationAlignment.d.ts +6 -3
- package/dist/api/TimelineTranslationAlignment.d.ts.map +1 -1
- package/dist/api/TimelineTranslationAlignment.js +20 -11
- package/dist/api/TimelineTranslationAlignment.js.map +1 -1
- package/dist/api/TranscriptAndTranslationAlignment.d.ts +6 -4
- package/dist/api/TranscriptAndTranslationAlignment.d.ts.map +1 -1
- package/dist/api/TranscriptAndTranslationAlignment.js +11 -12
- package/dist/api/TranscriptAndTranslationAlignment.js.map +1 -1
- package/dist/api/TranslationAlignment.d.ts +6 -4
- package/dist/api/TranslationAlignment.d.ts.map +1 -1
- package/dist/api/TranslationAlignment.js +20 -21
- package/dist/api/TranslationAlignment.js.map +1 -1
- package/dist/api/VoiceActivityDetection.d.ts +9 -8
- package/dist/api/VoiceActivityDetection.d.ts.map +1 -1
- package/dist/api/VoiceActivityDetection.js +20 -43
- package/dist/api/VoiceActivityDetection.js.map +1 -1
- package/dist/audio/AudioBufferConversion.js.map +1 -1
- package/dist/audio/AudioPlayer.d.ts +1 -3
- package/dist/audio/AudioPlayer.d.ts.map +1 -1
- package/dist/audio/AudioPlayer.js +3 -188
- package/dist/audio/AudioPlayer.js.map +1 -1
- package/dist/audio/AudioUtilities.d.ts +2 -1
- package/dist/audio/AudioUtilities.d.ts.map +1 -1
- package/dist/audio/AudioUtilities.js +2 -2
- package/dist/audio/AudioUtilities.js.map +1 -1
- package/dist/build-tools/MakeTarballsForInstalledPackages.js +3 -3
- package/dist/build-tools/MakeTarballsForInstalledPackages.js.map +1 -1
- package/dist/cli/CLI.d.ts.map +1 -1
- package/dist/cli/CLI.js +139 -92
- package/dist/cli/CLI.js.map +1 -1
- package/dist/codecs/FFMpegTranscoder.d.ts +4 -3
- package/dist/codecs/FFMpegTranscoder.d.ts.map +1 -1
- package/dist/codecs/FFMpegTranscoder.js +16 -14
- package/dist/codecs/FFMpegTranscoder.js.map +1 -1
- package/dist/codecs/TIMITCodec.d.ts.map +1 -1
- package/dist/data-structures/DynamicTypedArray.d.ts.map +1 -1
- package/dist/data-structures/DynamicTypedArray.js.map +1 -1
- package/dist/data-structures/Queue.d.ts.map +1 -1
- package/dist/data-structures/WindowedList.d.ts.map +1 -1
- package/dist/data-structures/WindowedList.js.map +1 -1
- package/dist/denoising/NSNet2.d.ts +3 -2
- package/dist/denoising/NSNet2.d.ts.map +1 -1
- package/dist/denoising/NSNet2.js +4 -4
- package/dist/denoising/NSNet2.js.map +1 -1
- package/dist/denoising/RNNoise.d.ts +2 -1
- package/dist/denoising/RNNoise.d.ts.map +1 -1
- package/dist/denoising/RNNoise.js +10 -6
- package/dist/denoising/RNNoise.js.map +1 -1
- package/dist/dsp/BiquadFilter.d.ts.map +1 -1
- package/dist/dsp/DecayingPeakEstimator.d.ts.map +1 -1
- package/dist/dsp/DecayingPeakEstimator.js.map +1 -1
- package/dist/dsp/FFT.d.ts.map +1 -1
- package/dist/dsp/FFT.js +2 -1
- package/dist/dsp/FFT.js.map +1 -1
- package/dist/dsp/KWeightingFilter.d.ts.map +1 -1
- package/dist/dsp/KWeightingFilter.js.map +1 -1
- package/dist/dsp/LoudnessEstimator.d.ts.map +1 -1
- package/dist/dsp/LoudnessEstimator.js.map +1 -1
- package/dist/dsp/MFCC.d.ts +3 -2
- package/dist/dsp/MFCC.d.ts.map +1 -1
- package/dist/dsp/MFCC.js +4 -4
- package/dist/dsp/MFCC.js.map +1 -1
- package/dist/dsp/MelSpectrogram.d.ts +10 -8
- package/dist/dsp/MelSpectrogram.d.ts.map +1 -1
- package/dist/dsp/MelSpectrogram.js +31 -34
- package/dist/dsp/MelSpectrogram.js.map +1 -1
- package/dist/dsp/Rubberband.d.ts.map +1 -1
- package/dist/dsp/Rubberband.js +8 -3
- package/dist/dsp/Rubberband.js.map +1 -1
- package/dist/dsp/Sonic.d.ts.map +1 -1
- package/dist/dsp/Sonic.js +1 -1
- package/dist/dsp/Sonic.js.map +1 -1
- package/dist/dsp/SpeexResampler.d.ts.map +1 -1
- package/dist/dsp/SpeexResampler.js +1 -1
- package/dist/dsp/SpeexResampler.js.map +1 -1
- package/dist/encodings/Ascii.d.ts +1 -1
- package/dist/encodings/Ascii.d.ts.map +1 -1
- package/dist/encodings/Base64.js.map +1 -1
- package/dist/encodings/Utf16.d.ts.map +1 -1
- package/dist/encodings/Utf8.d.ts.map +1 -1
- package/dist/math/VectorMath.d.ts +1 -0
- package/dist/math/VectorMath.d.ts.map +1 -1
- package/dist/math/VectorMath.js +9 -5
- package/dist/math/VectorMath.js.map +1 -1
- package/dist/nlp/ChineseSegmentation.d.ts +1 -1
- package/dist/nlp/ChineseSegmentation.d.ts.map +1 -1
- package/dist/nlp/EspeakPhonemizer.d.ts +1 -1
- package/dist/nlp/EspeakPhonemizer.d.ts.map +1 -1
- package/dist/nlp/EspeakPhonemizer.js +2 -2
- package/dist/nlp/EspeakPhonemizer.js.map +1 -1
- package/dist/nlp/IPA.d.ts +2 -2
- package/dist/nlp/Segmentation.d.ts +1 -1
- package/dist/nlp/Segmentation.d.ts.map +1 -1
- package/dist/nlp/Segmentation.js +8 -4
- package/dist/nlp/Segmentation.js.map +1 -1
- package/dist/recognition/AmazonTranscribeSTT.d.ts +2 -1
- package/dist/recognition/AmazonTranscribeSTT.d.ts.map +1 -1
- package/dist/recognition/AmazonTranscribeSTT.js +3 -3
- package/dist/recognition/AmazonTranscribeSTT.js.map +1 -1
- package/dist/recognition/AzureCognitiveServicesSTT.d.ts +2 -1
- package/dist/recognition/AzureCognitiveServicesSTT.d.ts.map +1 -1
- package/dist/recognition/AzureCognitiveServicesSTT.js +4 -4
- package/dist/recognition/AzureCognitiveServicesSTT.js.map +1 -1
- package/dist/recognition/DeepgramSTT.d.ts +2 -1
- package/dist/recognition/DeepgramSTT.d.ts.map +1 -1
- package/dist/recognition/DeepgramSTT.js +12 -13
- package/dist/recognition/DeepgramSTT.js.map +1 -1
- package/dist/recognition/GoogleCloudSTT.d.ts +2 -1
- package/dist/recognition/GoogleCloudSTT.d.ts.map +1 -1
- package/dist/recognition/GoogleCloudSTT.js +11 -10
- package/dist/recognition/GoogleCloudSTT.js.map +1 -1
- package/dist/recognition/OpenAICloudSTT.d.ts +2 -1
- package/dist/recognition/OpenAICloudSTT.d.ts.map +1 -1
- package/dist/recognition/OpenAICloudSTT.js +6 -6
- package/dist/recognition/OpenAICloudSTT.js.map +1 -1
- package/dist/recognition/WhisperCommon.d.ts +9 -0
- package/dist/recognition/WhisperCommon.d.ts.map +1 -0
- package/dist/recognition/WhisperCommon.js +52 -0
- package/dist/recognition/WhisperCommon.js.map +1 -0
- package/dist/recognition/{WhisperCppSTT.d.ts → WhisperCppCliSTT.d.ts} +14 -16
- package/dist/recognition/WhisperCppCliSTT.d.ts.map +1 -0
- package/dist/recognition/{WhisperCppSTT.js → WhisperCppCliSTT.js} +55 -84
- package/dist/recognition/WhisperCppCliSTT.js.map +1 -0
- package/dist/recognition/WhisperSTT.d.ts +72 -85
- package/dist/recognition/WhisperSTT.d.ts.map +1 -1
- package/dist/recognition/WhisperSTT.js +384 -519
- package/dist/recognition/WhisperSTT.js.map +1 -1
- package/dist/server/Client.d.ts +2 -2
- package/dist/server/Client.d.ts.map +1 -1
- package/dist/server/Client.js.map +1 -1
- package/dist/server/Worker.d.ts +6 -7
- package/dist/server/Worker.d.ts.map +1 -1
- package/dist/server/Worker.js +42 -44
- package/dist/server/Worker.js.map +1 -1
- package/dist/source-separation/MDXNetSourceSeparation.d.ts +3 -2
- package/dist/source-separation/MDXNetSourceSeparation.d.ts.map +1 -1
- package/dist/source-separation/MDXNetSourceSeparation.js +10 -8
- package/dist/source-separation/MDXNetSourceSeparation.js.map +1 -1
- package/dist/speech-embeddings/WavToVec2BertFeatureEmbeddings.d.ts +3 -2
- package/dist/speech-embeddings/WavToVec2BertFeatureEmbeddings.d.ts.map +1 -1
- package/dist/speech-embeddings/WavToVec2BertFeatureEmbeddings.js +5 -5
- package/dist/speech-embeddings/WavToVec2BertFeatureEmbeddings.js.map +1 -1
- package/dist/speech-language-detection/SileroLanguageDetection.d.ts +5 -3
- package/dist/speech-language-detection/SileroLanguageDetection.d.ts.map +1 -1
- package/dist/speech-language-detection/SileroLanguageDetection.js +8 -8
- package/dist/speech-language-detection/SileroLanguageDetection.js.map +1 -1
- package/dist/speech-search/DTWSpeechSearch.d.ts +2 -1
- package/dist/speech-search/DTWSpeechSearch.d.ts.map +1 -1
- package/dist/speech-search/DTWSpeechSearch.js +4 -4
- package/dist/speech-search/DTWSpeechSearch.js.map +1 -1
- package/dist/subtitles/Subtitles.d.ts +13 -1
- package/dist/subtitles/Subtitles.d.ts.map +1 -1
- package/dist/subtitles/Subtitles.js +22 -22
- package/dist/subtitles/Subtitles.js.map +1 -1
- package/dist/synthesis/AwsPollyTTS.d.ts +3 -2
- package/dist/synthesis/AwsPollyTTS.d.ts.map +1 -1
- package/dist/synthesis/AwsPollyTTS.js +5 -5
- package/dist/synthesis/AwsPollyTTS.js.map +1 -1
- package/dist/synthesis/AzureCognitiveServicesTTS.d.ts +2 -1
- package/dist/synthesis/AzureCognitiveServicesTTS.d.ts.map +1 -1
- package/dist/synthesis/AzureCognitiveServicesTTS.js +3 -3
- package/dist/synthesis/AzureCognitiveServicesTTS.js.map +1 -1
- package/dist/synthesis/CoquiServerTTS.d.ts +2 -1
- package/dist/synthesis/CoquiServerTTS.d.ts.map +1 -1
- package/dist/synthesis/CoquiServerTTS.js +7 -8
- package/dist/synthesis/CoquiServerTTS.js.map +1 -1
- package/dist/synthesis/DeepgramTTS.d.ts +2 -2
- package/dist/synthesis/DeepgramTTS.d.ts.map +1 -1
- package/dist/synthesis/DeepgramTTS.js +13 -13
- package/dist/synthesis/DeepgramTTS.js.map +1 -1
- package/dist/synthesis/ElevenLabsTTS.d.ts +3 -3
- package/dist/synthesis/ElevenLabsTTS.d.ts.map +1 -1
- package/dist/synthesis/ElevenLabsTTS.js +22 -21
- package/dist/synthesis/ElevenLabsTTS.js.map +1 -1
- package/dist/synthesis/EspeakTTS.d.ts +11 -9
- package/dist/synthesis/EspeakTTS.d.ts.map +1 -1
- package/dist/synthesis/EspeakTTS.js +118 -68
- package/dist/synthesis/EspeakTTS.js.map +1 -1
- package/dist/synthesis/FliteTTS.d.ts +2 -2
- package/dist/synthesis/FliteTTS.d.ts.map +1 -1
- package/dist/synthesis/FliteTTS.js +2 -2
- package/dist/synthesis/FliteTTS.js.map +1 -1
- package/dist/synthesis/GnuSpeechTTS.d.ts +2 -2
- package/dist/synthesis/GnuSpeechTTS.d.ts.map +1 -1
- package/dist/synthesis/GnuSpeechTTS.js +1 -1
- package/dist/synthesis/GnuSpeechTTS.js.map +1 -1
- package/dist/synthesis/GoogleCloudTTS.d.ts +3 -2
- package/dist/synthesis/GoogleCloudTTS.d.ts.map +1 -1
- package/dist/synthesis/GoogleCloudTTS.js +15 -14
- package/dist/synthesis/GoogleCloudTTS.js.map +1 -1
- package/dist/synthesis/GoogleTranslateTTS.d.ts +3 -2
- package/dist/synthesis/GoogleTranslateTTS.d.ts.map +1 -1
- package/dist/synthesis/GoogleTranslateTTS.js +11 -11
- package/dist/synthesis/GoogleTranslateTTS.js.map +1 -1
- package/dist/synthesis/KokoroTTS.d.ts +4 -4
- package/dist/synthesis/KokoroTTS.d.ts.map +1 -1
- package/dist/synthesis/KokoroTTS.js +11 -10
- package/dist/synthesis/KokoroTTS.js.map +1 -1
- package/dist/synthesis/MicrosoftEdgeTTS.d.ts +4 -3
- package/dist/synthesis/MicrosoftEdgeTTS.d.ts.map +1 -1
- package/dist/synthesis/MicrosoftEdgeTTS.js +41 -20
- package/dist/synthesis/MicrosoftEdgeTTS.js.map +1 -1
- package/dist/synthesis/OpenAICloudTTS.d.ts +2 -2
- package/dist/synthesis/OpenAICloudTTS.d.ts.map +1 -1
- package/dist/synthesis/OpenAICloudTTS.js +6 -5
- package/dist/synthesis/OpenAICloudTTS.js.map +1 -1
- package/dist/synthesis/SamTTS.d.ts +2 -1
- package/dist/synthesis/SamTTS.d.ts.map +1 -1
- package/dist/synthesis/SamTTS.js +2 -2
- package/dist/synthesis/SamTTS.js.map +1 -1
- package/dist/synthesis/SapiTTS.d.ts +2 -2
- package/dist/synthesis/SapiTTS.d.ts.map +1 -1
- package/dist/synthesis/SapiTTS.js +2 -2
- package/dist/synthesis/SapiTTS.js.map +1 -1
- package/dist/synthesis/SvoxPicoTTS.d.ts +2 -2
- package/dist/synthesis/SvoxPicoTTS.d.ts.map +1 -1
- package/dist/synthesis/SvoxPicoTTS.js +3 -3
- package/dist/synthesis/SvoxPicoTTS.js.map +1 -1
- package/dist/synthesis/VitsTTS.d.ts +3 -3
- package/dist/synthesis/VitsTTS.d.ts.map +1 -1
- package/dist/synthesis/VitsTTS.js +14 -11
- package/dist/synthesis/VitsTTS.js.map +1 -1
- package/dist/text-translation/DeepLTextTranslation.d.ts +2 -2
- package/dist/text-translation/DeepLTextTranslation.d.ts.map +1 -1
- package/dist/text-translation/DeepLTextTranslation.js +10 -9
- package/dist/text-translation/DeepLTextTranslation.js.map +1 -1
- package/dist/text-translation/GoogleTranslateTextTranslation.d.ts +4 -4
- package/dist/text-translation/GoogleTranslateTextTranslation.d.ts.map +1 -1
- package/dist/text-translation/GoogleTranslateTextTranslation.js +20 -18
- package/dist/text-translation/GoogleTranslateTextTranslation.js.map +1 -1
- package/dist/text-translation/NLLBTextTranslation.d.ts +2 -2
- package/dist/text-translation/NLLBTextTranslation.d.ts.map +1 -1
- package/dist/text-translation/NLLBTextTranslation.js +4 -6
- package/dist/text-translation/NLLBTextTranslation.js.map +1 -1
- package/dist/typings/TypedArray.d.ts.map +1 -1
- package/dist/utilities/Compression.d.ts +4 -3
- package/dist/utilities/Compression.d.ts.map +1 -1
- package/dist/utilities/Compression.js +9 -9
- package/dist/utilities/Compression.js.map +1 -1
- package/dist/utilities/FileDownloader.d.ts +6 -3
- package/dist/utilities/FileDownloader.d.ts.map +1 -1
- package/dist/utilities/FileDownloader.js +25 -21
- package/dist/utilities/FileDownloader.js.map +1 -1
- package/dist/utilities/FileReader.d.ts.map +1 -1
- package/dist/utilities/FileReader.js.map +1 -1
- package/dist/utilities/FileSystem.js +1 -1
- package/dist/utilities/FileSystem.js.map +1 -1
- package/dist/utilities/FileWriter.d.ts.map +1 -1
- package/dist/utilities/FileWriter.js.map +1 -1
- package/dist/utilities/Hashing.d.ts.map +1 -1
- package/dist/utilities/Hashing.js.map +1 -1
- package/dist/utilities/Locale.js.map +1 -1
- package/dist/utilities/Logger.d.ts +17 -9
- package/dist/utilities/Logger.d.ts.map +1 -1
- package/dist/utilities/Logger.js +50 -35
- package/dist/utilities/Logger.js.map +1 -1
- package/dist/utilities/NpmUtilities.d.ts.map +1 -1
- package/dist/utilities/NpmUtilities.js +4 -5
- package/dist/utilities/NpmUtilities.js.map +1 -1
- package/dist/utilities/ObjectUtilities.js.map +1 -1
- package/dist/utilities/OpenPromise.d.ts.map +1 -1
- package/dist/utilities/OpenPromise.js.map +1 -1
- package/dist/utilities/PackageManager.d.ts +4 -1
- package/dist/utilities/PackageManager.d.ts.map +1 -1
- package/dist/utilities/PackageManager.js +37 -22
- package/dist/utilities/PackageManager.js.map +1 -1
- package/dist/utilities/PathUtilities.d.ts +2 -0
- package/dist/utilities/PathUtilities.d.ts.map +1 -1
- package/dist/utilities/PathUtilities.js +5 -2
- package/dist/utilities/PathUtilities.js.map +1 -1
- package/dist/utilities/RandomGenerator.d.ts.map +1 -1
- package/dist/utilities/SignalChannel.d.ts.map +1 -1
- package/dist/utilities/SmoothEstimator.d.ts.map +1 -1
- package/dist/utilities/SmoothEstimator.js.map +1 -1
- package/dist/utilities/StringBuilder.d.ts.map +1 -1
- package/dist/utilities/TarballMaker.d.ts +4 -3
- package/dist/utilities/TarballMaker.d.ts.map +1 -1
- package/dist/utilities/TarballMaker.js +6 -6
- package/dist/utilities/TarballMaker.js.map +1 -1
- package/dist/utilities/Timeline.js.map +1 -1
- package/dist/utilities/Timer.d.ts.map +1 -1
- package/dist/utilities/Utilities.d.ts +9 -7
- package/dist/utilities/Utilities.d.ts.map +1 -1
- package/dist/utilities/Utilities.js +49 -33
- package/dist/utilities/Utilities.js.map +1 -1
- package/dist/utilities/VirtualFileReadStream.d.ts.map +1 -1
- package/dist/utilities/WebReader.d.ts +2 -1
- package/dist/utilities/WebReader.d.ts.map +1 -1
- package/dist/utilities/WebReader.js +7 -6
- package/dist/utilities/WebReader.js.map +1 -1
- package/dist/utilities/WikipediaReader.d.ts +2 -1
- package/dist/utilities/WikipediaReader.d.ts.map +1 -1
- package/dist/utilities/WikipediaReader.js +1 -5
- package/dist/utilities/WikipediaReader.js.map +1 -1
- package/dist/voice-activity-detection/AdaptiveGateVAD.d.ts +2 -1
- package/dist/voice-activity-detection/AdaptiveGateVAD.d.ts.map +1 -1
- package/dist/voice-activity-detection/AdaptiveGateVAD.js +1 -1
- package/dist/voice-activity-detection/AdaptiveGateVAD.js.map +1 -1
- package/dist/voice-activity-detection/SileroVAD.d.ts.map +1 -1
- package/dist/voice-activity-detection/SileroVAD.js.map +1 -1
- package/dist/voice-activity-detection/WebRtcVAD.d.ts.map +1 -1
- package/dist/voice-activity-detection/WebRtcVAD.js +1 -1
- package/dist/voice-activity-detection/WebRtcVAD.js.map +1 -1
- package/docs/API.md +62 -17
- package/docs/CUDA.md +4 -3
- package/docs/Engines.md +8 -7
- package/docs/Licenses.md +0 -3
- package/docs/Options.md +27 -31
- package/docs/Server.md +1 -0
- package/docs/Tasklist.md +2 -1
- package/docs/Technical.md +2 -2
- package/package.json +45 -35
- package/src/alignment/SemanticTextAlignment.ts +14 -7
- package/src/alignment/SpeechAlignment.ts +47 -150
- package/src/api/APIOptions.ts +1 -1
- package/src/api/Alignment.ts +95 -61
- package/src/api/Common.ts +11 -0
- package/src/api/Denoising.ts +22 -17
- package/src/api/GlobalOptions.ts +4 -20
- package/src/api/Recognition.ts +106 -123
- package/src/api/SourceSeparation.ts +39 -21
- package/src/api/SpeechLanguageDetection.ts +77 -37
- package/src/api/SpeechSearch.ts +6 -1
- package/src/api/SpeechTranslation.ts +75 -38
- package/src/api/Synthesis.ts +220 -116
- package/src/api/TextLanguageDetection.ts +10 -12
- package/src/api/TextTranslation.ts +43 -26
- package/src/api/TimelineTranslationAlignment.ts +41 -13
- package/src/api/TranscriptAndTranslationAlignment.ts +28 -15
- package/src/api/TranslationAlignment.ts +53 -24
- package/src/api/VoiceActivityDetection.ts +33 -68
- package/src/audio/AudioPlayer.ts +4 -232
- package/src/audio/AudioUtilities.ts +9 -2
- package/src/build-tools/MakeTarballsForInstalledPackages.ts +4 -3
- package/src/cli/CLI.ts +209 -101
- package/src/codecs/FFMpegTranscoder.ts +18 -16
- package/src/denoising/NSNet2.ts +5 -4
- package/src/denoising/RNNoise.ts +14 -6
- package/src/dsp/FFT.ts +2 -1
- package/src/dsp/MFCC.ts +7 -5
- package/src/dsp/MelSpectrogram.ts +56 -36
- package/src/dsp/Rubberband.ts +10 -3
- package/src/dsp/Sonic.ts +2 -1
- package/src/dsp/SpeexResampler.ts +2 -1
- package/src/encodings/Ascii.ts +1 -1
- package/src/encodings/Base64.ts +1 -1
- package/src/math/VectorMath.ts +10 -6
- package/src/nlp/EspeakPhonemizer.ts +2 -2
- package/src/nlp/Segmentation.ts +9 -4
- package/src/recognition/AmazonTranscribeSTT.ts +4 -3
- package/src/recognition/AzureCognitiveServicesSTT.ts +5 -4
- package/src/recognition/DeepgramSTT.ts +16 -16
- package/src/recognition/GoogleCloudSTT.ts +14 -12
- package/src/recognition/OpenAICloudSTT.ts +12 -6
- package/src/recognition/WhisperCommon.ts +130 -0
- package/src/recognition/{WhisperCppSTT.ts → WhisperCppCliSTT.ts} +73 -133
- package/src/recognition/WhisperSTT.ts +569 -718
- package/src/server/Client.ts +4 -4
- package/src/server/Worker.ts +59 -59
- package/src/source-separation/MDXNetSourceSeparation.ts +15 -10
- package/src/speech-embeddings/WavToVec2BertFeatureEmbeddings.ts +7 -5
- package/src/speech-language-detection/SileroLanguageDetection.ts +18 -9
- package/src/speech-search/DTWSpeechSearch.ts +6 -5
- package/src/subtitles/Subtitles.ts +22 -22
- package/src/synthesis/AwsPollyTTS.ts +12 -5
- package/src/synthesis/AzureCognitiveServicesTTS.ts +11 -3
- package/src/synthesis/CoquiServerTTS.ts +8 -7
- package/src/synthesis/DeepgramTTS.ts +21 -15
- package/src/synthesis/ElevenLabsTTS.ts +33 -23
- package/src/synthesis/EspeakTTS.ts +145 -69
- package/src/synthesis/FliteTTS.ts +3 -3
- package/src/synthesis/GnuSpeechTTS.ts +2 -2
- package/src/synthesis/GoogleCloudTTS.ts +23 -14
- package/src/synthesis/GoogleTranslateTTS.ts +19 -11
- package/src/synthesis/KokoroTTS.ts +37 -14
- package/src/synthesis/MicrosoftEdgeTTS.ts +71 -23
- package/src/synthesis/OpenAICloudTTS.ts +7 -6
- package/src/synthesis/SamTTS.ts +3 -2
- package/src/synthesis/SapiTTS.ts +3 -3
- package/src/synthesis/SvoxPicoTTS.ts +4 -5
- package/src/synthesis/VitsTTS.ts +43 -15
- package/src/text-translation/DeepLTextTranslation.ts +12 -10
- package/src/text-translation/GoogleTranslateTextTranslation.ts +35 -21
- package/src/text-translation/NLLBTextTranslation.ts +5 -9
- package/src/typings/Fillers.d.ts +0 -60
- package/src/typings/TypedArray.ts +12 -1
- package/src/utilities/Compression.ts +10 -9
- package/src/utilities/FileDownloader.ts +38 -23
- package/src/utilities/FileSystem.ts +1 -1
- package/src/utilities/Logger.ts +59 -42
- package/src/utilities/NpmUtilities.ts +4 -6
- package/src/utilities/OpenPromise.ts +1 -2
- package/src/utilities/PackageManager.ts +53 -26
- package/src/utilities/PathUtilities.ts +6 -2
- package/src/utilities/TarballMaker.ts +7 -7
- package/src/utilities/Utilities.ts +58 -41
- package/src/utilities/WebReader.ts +11 -6
- package/src/utilities/WikipediaReader.ts +2 -8
- package/src/voice-activity-detection/AdaptiveGateVAD.ts +13 -8
- package/src/voice-activity-detection/WebRtcVAD.ts +1 -2
- package/tsconfig.json +53 -54
- package/dist/audio/AudioRecorder.d.ts +0 -4
- package/dist/audio/AudioRecorder.d.ts.map +0 -1
- package/dist/audio/AudioRecorder.js +0 -68
- package/dist/audio/AudioRecorder.js.map +0 -1
- package/dist/audio/SoxPath.d.ts +0 -2
- package/dist/audio/SoxPath.d.ts.map +0 -1
- package/dist/audio/SoxPath.js +0 -24
- package/dist/audio/SoxPath.js.map +0 -1
- package/dist/recognition/SileroSTT.d.ts +0 -30
- package/dist/recognition/SileroSTT.d.ts.map +0 -1
- package/dist/recognition/SileroSTT.js +0 -152
- package/dist/recognition/SileroSTT.js.map +0 -1
- package/dist/recognition/VoskSTT.d.ts +0 -11
- package/dist/recognition/VoskSTT.d.ts.map +0 -1
- package/dist/recognition/VoskSTT.js +0 -72
- package/dist/recognition/VoskSTT.js.map +0 -1
- package/dist/recognition/WhisperCppSTT.d.ts.map +0 -1
- package/dist/recognition/WhisperCppSTT.js.map +0 -1
- package/dist/synthesis/StreamlabsPollyTTS.d.ts +0 -12
- package/dist/synthesis/StreamlabsPollyTTS.d.ts.map +0 -1
- package/dist/synthesis/StreamlabsPollyTTS.js +0 -88
- package/dist/synthesis/StreamlabsPollyTTS.js.map +0 -1
- package/dist/utilities/BinaryUtilities.d.ts +0 -14
- package/dist/utilities/BinaryUtilities.d.ts.map +0 -1
- package/dist/utilities/BinaryUtilities.js +0 -113
- package/dist/utilities/BinaryUtilities.js.map +0 -1
- package/src/audio/AudioRecorder.ts +0 -91
- package/src/audio/SoxPath.ts +0 -31
- package/src/recognition/SileroSTT.ts +0 -222
- package/src/recognition/VoskSTT.ts +0 -112
- package/src/synthesis/StreamlabsPollyTTS.ts +0 -114
- package/src/utilities/BinaryUtilities.ts +0 -138
- /package/{LICENSE.md → LICENSE.GPLv3.md} +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
1
|
+
import { Logger } from '../utilities/Logger.js'
|
|
2
|
+
import { Fragment, splitToFragments } from '../nlp/Segmentation.js'
|
|
3
|
+
import { TextTranslationCallbacks, TranslationPair } from '../api/TextTranslation.js'
|
|
4
|
+
import { getChromeOnAndroidHeaders } from '../utilities/BrowserRequestHeaders.js'
|
|
5
|
+
import { logToStderr } from '../utilities/Utilities.js'
|
|
6
|
+
import { getShortLanguageCode } from '../utilities/Locale.js'
|
|
7
|
+
import { PlainTextOptions } from '../api/Common.js'
|
|
8
|
+
import { extendDeep } from '../utilities/ObjectUtilities.js'
|
|
9
|
+
import { splitAndPreserveSeparators } from '../utilities/StringUtilities.js'
|
|
10
|
+
import { requestHttp } from 'easier-http-request'
|
|
11
11
|
|
|
12
12
|
const log = logToStderr
|
|
13
13
|
|
|
@@ -16,9 +16,10 @@ export async function translateText(
|
|
|
16
16
|
sourceLanguage: string,
|
|
17
17
|
targetLanguage: string,
|
|
18
18
|
plainTextOptions: PlainTextOptions,
|
|
19
|
-
options: GoogleTranslateTextTranslationOptions
|
|
19
|
+
options: GoogleTranslateTextTranslationOptions,
|
|
20
|
+
callbacks: TextTranslationCallbacks) {
|
|
20
21
|
|
|
21
|
-
const logger = new Logger()
|
|
22
|
+
const logger = new Logger(callbacks.logLevel)
|
|
22
23
|
|
|
23
24
|
if (!supportsLanguage(sourceLanguage)) {
|
|
24
25
|
throw new Error(`Language code ${sourceLanguage} is not supported by the Google Translate engine. Supported language codes are ${supportedLanguageCodes.join(', ')}`)
|
|
@@ -78,6 +79,8 @@ export async function translateText(
|
|
|
78
79
|
const translatedFragmentsForParagraphs = paragraphs.map(_ => [] as string[])
|
|
79
80
|
|
|
80
81
|
for (let partIndex = 0; partIndex < parts.length; partIndex++) {
|
|
82
|
+
callbacks?.abortSignal?.throwIfAborted()
|
|
83
|
+
|
|
81
84
|
const part = parts[partIndex]
|
|
82
85
|
|
|
83
86
|
const joinedFragmentsInPart = part.map(x => x.text.replaceAll('|', ' ')).join(`\n|\n`)
|
|
@@ -85,12 +88,16 @@ export async function translateText(
|
|
|
85
88
|
logger.logTitledMessage(`\nTranslate part ${partIndex + 1} of ${parts.length}`, joinedFragmentsInPart.replaceAll('\n|\n', ''))
|
|
86
89
|
|
|
87
90
|
logger.start(`Request translation from Google Translate`)
|
|
88
|
-
const fragmentTranslationPair = await translateText_MobileWeb(joinedFragmentsInPart, sourceLanguage, targetLanguage, options)
|
|
89
|
-
logger.end()
|
|
90
91
|
|
|
91
|
-
const
|
|
92
|
+
const fragmentTranslationPair = await translateText_MobileWeb(
|
|
93
|
+
joinedFragmentsInPart,
|
|
94
|
+
sourceLanguage,
|
|
95
|
+
targetLanguage,
|
|
96
|
+
options,
|
|
97
|
+
{ ...callbacks, logLevel: 'warning' }
|
|
98
|
+
)
|
|
92
99
|
|
|
93
|
-
|
|
100
|
+
const translatedTextForPart = fragmentTranslationPair[0].translatedText
|
|
94
101
|
|
|
95
102
|
const splitTranslation = translatedTextForPart.split(`|`)
|
|
96
103
|
|
|
@@ -102,6 +109,10 @@ export async function translateText(
|
|
|
102
109
|
|
|
103
110
|
translatedFragmentsForParagraphs[paragraphIndex].push(translatedFragment)
|
|
104
111
|
}
|
|
112
|
+
|
|
113
|
+
logger.end()
|
|
114
|
+
|
|
115
|
+
logger.logTitledMessage(`Translated part`, `"${translatedTextForPart.replaceAll(' | ', '\n')}"`)
|
|
105
116
|
}
|
|
106
117
|
|
|
107
118
|
const translationPairs: TranslationPair[] = []
|
|
@@ -143,15 +154,16 @@ export async function translateText_MobileWeb(
|
|
|
143
154
|
text: string,
|
|
144
155
|
sourceLanguage: string,
|
|
145
156
|
targetLanguage: string,
|
|
146
|
-
options: GoogleTranslateTextTranslationOptions
|
|
157
|
+
options: GoogleTranslateTextTranslationOptions,
|
|
158
|
+
callbacks: TextTranslationCallbacks) {
|
|
147
159
|
|
|
148
160
|
const tld = options.tld
|
|
149
161
|
|
|
150
|
-
const logger = new Logger()
|
|
162
|
+
const logger = new Logger(callbacks.logLevel)
|
|
151
163
|
|
|
152
164
|
logger.start(`Request translation from Google Translate`)
|
|
153
165
|
|
|
154
|
-
const response = await
|
|
166
|
+
const response = await requestHttp({
|
|
155
167
|
method: 'GET',
|
|
156
168
|
|
|
157
169
|
url: `https://translate.google.${tld}/m`,
|
|
@@ -171,12 +183,14 @@ export async function translateText_MobileWeb(
|
|
|
171
183
|
}),
|
|
172
184
|
},
|
|
173
185
|
|
|
174
|
-
|
|
186
|
+
abortSignal: callbacks?.abortSignal
|
|
175
187
|
})
|
|
176
188
|
|
|
189
|
+
const responseText = await response.text()
|
|
190
|
+
|
|
177
191
|
logger.start('Parse response')
|
|
178
192
|
|
|
179
|
-
const html =
|
|
193
|
+
const html = responseText
|
|
180
194
|
|
|
181
195
|
let translatedText: string
|
|
182
196
|
|
|
@@ -1,21 +1,17 @@
|
|
|
1
1
|
import chalk from 'chalk'
|
|
2
|
-
import { TranslationPair } from '../api/TextTranslation.js'
|
|
2
|
+
import { TextTranslationCallbacks, TranslationPair } from '../api/TextTranslation.js'
|
|
3
3
|
import { parseText } from '../nlp/Segmentation.js'
|
|
4
4
|
import { Logger } from '../utilities/Logger.js'
|
|
5
5
|
import { loadPackage } from '../utilities/PackageManager.js'
|
|
6
6
|
|
|
7
|
-
export async function translateText(sourceText: string, sourceLanguage: string, targetLanguage: string): Promise<TranslationPair[]> {
|
|
8
|
-
const logger = new Logger()
|
|
9
|
-
|
|
10
|
-
//const languageNames = Object.keys(languageNameToNLLBCode)
|
|
11
|
-
|
|
12
|
-
//logger.log(languageNames)
|
|
7
|
+
export async function translateText(sourceText: string, sourceLanguage: string, targetLanguage: string, callbacks: TextTranslationCallbacks): Promise<TranslationPair[]> {
|
|
8
|
+
const logger = new Logger(callbacks.logLevel)
|
|
13
9
|
|
|
14
10
|
logger.start(`Load transformers.js module`)
|
|
15
11
|
const { AutoTokenizer, M2M100ForConditionalGeneration } = await import('@echogarden/transformers-nodejs-lite')
|
|
16
12
|
|
|
17
13
|
logger.start(`Load NLLB package`)
|
|
18
|
-
const modelPath = await loadPackage(`xenova-nllb-200-distilled-600M-q8
|
|
14
|
+
const modelPath = await loadPackage(`xenova-nllb-200-distilled-600M-q8`, callbacks)
|
|
19
15
|
|
|
20
16
|
logger.start(`Load NLLB tokenizer`)
|
|
21
17
|
const tokenizer = await AutoTokenizer.from_pretrained(modelPath)
|
|
@@ -41,7 +37,7 @@ export async function translateText(sourceText: string, sourceLanguage: string,
|
|
|
41
37
|
for (let i = 0; i < sentences.length; i++) {
|
|
42
38
|
const sentenceText = sentences[i].text
|
|
43
39
|
|
|
44
|
-
logger.logTitledMessage(`Translate sentence ${i + 1}/${sentences.length}`, `"${sentenceText.trim()}"`, chalk.magentaBright)
|
|
40
|
+
logger.logTitledMessage(`Translate sentence ${i + 1}/${sentences.length}`, `"${sentenceText.trim()}"`, 'info', chalk.magentaBright)
|
|
45
41
|
|
|
46
42
|
logger.start(`Tokenize sentence`)
|
|
47
43
|
const inputs = (tokenizer as any)._build_translation_inputs(sentenceText, {
|
package/src/typings/Fillers.d.ts
CHANGED
|
@@ -37,63 +37,3 @@ declare module '@echogarden/pffft-wasm'
|
|
|
37
37
|
declare module '@echogarden/pffft-wasm/simd'
|
|
38
38
|
declare module '@echogarden/speex-resampler-wasm'
|
|
39
39
|
declare module '@echogarden/speex-resampler-wasm/simd'
|
|
40
|
-
declare module '@echogarden/vosk'
|
|
41
|
-
|
|
42
|
-
/*
|
|
43
|
-
// Not needed anymore in `onnxruntime-node` 1.21.0:
|
|
44
|
-
|
|
45
|
-
declare module 'onnxruntime-node' {
|
|
46
|
-
// From index.d.ts
|
|
47
|
-
export * from 'onnxruntime-common'
|
|
48
|
-
|
|
49
|
-
// From backend.d.ts
|
|
50
|
-
import { Backend, InferenceSession, SessionHandler, OnnxValue } from 'onnxruntime-common'
|
|
51
|
-
|
|
52
|
-
class OnnxruntimeBackend implements Backend {
|
|
53
|
-
init(): Promise<void>
|
|
54
|
-
createSessionHandler(pathOrBuffer: string | Uint8Array, options?: InferenceSession.SessionOptions): Promise<SessionHandler>
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export const onnxruntimeBackend: OnnxruntimeBackend
|
|
58
|
-
|
|
59
|
-
// From binding.d.ts
|
|
60
|
-
type SessionOptions = InferenceSession.SessionOptions
|
|
61
|
-
|
|
62
|
-
type FeedsType = {
|
|
63
|
-
[name: string]: OnnxValue
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
type FetchesType = {
|
|
67
|
-
[name: string]: OnnxValue | null
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
type ReturnType = {
|
|
71
|
-
[name: string]: OnnxValue
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
type RunOptions = InferenceSession.RunOptions
|
|
75
|
-
|
|
76
|
-
// Binding exports a simple synchronized inference session object wrap.
|
|
77
|
-
export namespace Binding {
|
|
78
|
-
interface InferenceSession {
|
|
79
|
-
loadModel(modelPath: string, options: SessionOptions): void
|
|
80
|
-
loadModel(buffer: ArrayBuffer, byteOffset: number, byteLength: number, options: SessionOptions): void
|
|
81
|
-
|
|
82
|
-
readonly inputNames: string[]
|
|
83
|
-
readonly outputNames: string[]
|
|
84
|
-
|
|
85
|
-
run(feeds: FeedsType, fetches: FetchesType, options: RunOptions): ReturnType
|
|
86
|
-
}
|
|
87
|
-
interface InferenceSessionConstructor {
|
|
88
|
-
new(): InferenceSession
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export const binding: {
|
|
93
|
-
InferenceSession: Binding.InferenceSessionConstructor
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// From version.d.ts
|
|
97
|
-
export const version = '1.20.0'
|
|
98
|
-
}
|
|
99
|
-
*/
|
|
@@ -1,4 +1,15 @@
|
|
|
1
|
-
export type TypedArray =
|
|
1
|
+
export type TypedArray =
|
|
2
|
+
Int8Array |
|
|
3
|
+
Uint8Array |
|
|
4
|
+
Uint8ClampedArray |
|
|
5
|
+
Int16Array |
|
|
6
|
+
Uint16Array |
|
|
7
|
+
Int32Array |
|
|
8
|
+
Uint32Array |
|
|
9
|
+
Float32Array |
|
|
10
|
+
Float64Array/* |
|
|
11
|
+
BigInt64Array |
|
|
12
|
+
BigUint64Array*/
|
|
2
13
|
|
|
3
14
|
export interface TypedArrayConstructor<T extends TypedArray> {
|
|
4
15
|
new(length: number): T
|
|
@@ -2,21 +2,22 @@ import { Logger } from './Logger.js'
|
|
|
2
2
|
import { readdir, stat } from './FileSystem.js'
|
|
3
3
|
import { encodeUtf8 } from '../encodings/Utf8.js'
|
|
4
4
|
import { getBaseName, getDirName } from './PathUtilities.js'
|
|
5
|
+
import { OperationCallbacks } from '../api/Common.js'
|
|
5
6
|
|
|
6
|
-
export async function createTarball(filePath: string, outputFile: string, prefixPath = '') {
|
|
7
|
+
export async function createTarball(filePath: string, outputFile: string, prefixPath = '', callbacks: OperationCallbacks) {
|
|
7
8
|
const pathStat = await stat(filePath)
|
|
8
9
|
|
|
9
10
|
if (pathStat.isDirectory()) {
|
|
10
|
-
await createTarballForDir(filePath, outputFile, prefixPath)
|
|
11
|
+
await createTarballForDir(filePath, outputFile, prefixPath, callbacks)
|
|
11
12
|
} else {
|
|
12
|
-
await createTarballForFile(filePath, outputFile, prefixPath)
|
|
13
|
+
await createTarballForFile(filePath, outputFile, prefixPath, callbacks)
|
|
13
14
|
}
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
export async function createTarballForFile(filePath: string, outputFile: string, prefixPath = '') {
|
|
17
|
-
const logger = new Logger()
|
|
17
|
+
export async function createTarballForFile(filePath: string, outputFile: string, prefixPath = '', callbacks: OperationCallbacks) {
|
|
18
|
+
const logger = new Logger(callbacks.logLevel)
|
|
18
19
|
|
|
19
|
-
logger.start(`
|
|
20
|
+
logger.start(`Create ${prefixPath || getBaseName(outputFile)}`)
|
|
20
21
|
|
|
21
22
|
const { create } = await import('tar')
|
|
22
23
|
|
|
@@ -49,10 +50,10 @@ export async function createTarballForFile(filePath: string, outputFile: string,
|
|
|
49
50
|
logger.end()
|
|
50
51
|
}
|
|
51
52
|
|
|
52
|
-
export async function createTarballForDir(inputDir: string, outputFile: string, prefixPath = '') {
|
|
53
|
-
const logger = new Logger()
|
|
53
|
+
export async function createTarballForDir(inputDir: string, outputFile: string, prefixPath = '', callbacks: OperationCallbacks) {
|
|
54
|
+
const logger = new Logger(callbacks.logLevel)
|
|
54
55
|
|
|
55
|
-
logger.start(`
|
|
56
|
+
logger.start(`Create ${prefixPath || getBaseName(outputFile)}`)
|
|
56
57
|
|
|
57
58
|
const { create } = await import('tar')
|
|
58
59
|
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import { GaxiosOptions, request } from 'gaxios'
|
|
2
|
-
import { Readable } from 'stream'
|
|
3
1
|
import { getRandomHexString, writeToStderr } from './Utilities.js'
|
|
4
2
|
|
|
5
3
|
import { Timer } from './Timer.js'
|
|
6
|
-
import { Logger } from './Logger.js'
|
|
4
|
+
import { Logger, LogLevel, logLevelGreaterOrEqualTo } from './Logger.js'
|
|
7
5
|
import { extractTarball } from './Compression.js'
|
|
8
6
|
import { move, remove, readdir, ensureDir } from './FileSystem.js'
|
|
9
7
|
import chalk from 'chalk'
|
|
10
|
-
import { logLevelGreaterOrEqualTo } from '../api/GlobalOptions.js'
|
|
11
8
|
import { FileWriter } from './FileWriter.js'
|
|
12
9
|
import { joinPath } from './PathUtilities.js'
|
|
10
|
+
import { EasierHttpRequestError, EasierHttpRequestConfig, requestHttp } from 'easier-http-request'
|
|
11
|
+
import { OperationCallbacks } from '../api/Common.js'
|
|
13
12
|
|
|
14
|
-
export async function downloadAndExtractTarball(options:
|
|
15
|
-
const logger = new Logger()
|
|
13
|
+
export async function downloadAndExtractTarball(options: EasierHttpRequestConfig, targetDir: string, baseTempPath: string, displayName = 'archive', callbacks: FileDownloaderCallbacks) {
|
|
14
|
+
const logger = new Logger(callbacks.logLevel)
|
|
16
15
|
|
|
17
16
|
const randomID = getRandomHexString(16).toLowerCase()
|
|
18
17
|
const tempTarballPath = joinPath(baseTempPath, `/${randomID}.tarball`)
|
|
@@ -21,7 +20,12 @@ export async function downloadAndExtractTarball(options: GaxiosOptions, targetDi
|
|
|
21
20
|
|
|
22
21
|
logger.end()
|
|
23
22
|
|
|
24
|
-
await downloadFile(
|
|
23
|
+
await downloadFile(
|
|
24
|
+
options,
|
|
25
|
+
tempTarballPath,
|
|
26
|
+
`${chalk.cyanBright('Downloading')} ${chalk.greenBright(displayName)}`,
|
|
27
|
+
callbacks
|
|
28
|
+
)
|
|
25
29
|
|
|
26
30
|
logger.end()
|
|
27
31
|
|
|
@@ -43,14 +47,12 @@ export async function downloadAndExtractTarball(options: GaxiosOptions, targetDi
|
|
|
43
47
|
logger.end()
|
|
44
48
|
}
|
|
45
49
|
|
|
46
|
-
export async function downloadFile(
|
|
47
|
-
const write = logLevelGreaterOrEqualTo('info') ? writeToStderr : () => {}
|
|
50
|
+
export async function downloadFile(requestConfig: EasierHttpRequestConfig, targetFilePath: string, prompt = 'Downloading', callbacks: FileDownloaderCallbacks) {
|
|
51
|
+
const write = logLevelGreaterOrEqualTo(callbacks.logLevel ?? 'warning', 'info') ? writeToStderr : () => { }
|
|
48
52
|
|
|
49
53
|
const timer = new Timer()
|
|
50
54
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const response = await request<Readable>(options)
|
|
55
|
+
const response = await requestHttp(requestConfig)
|
|
54
56
|
|
|
55
57
|
const ttyOutput = process.stderr.isTTY === true
|
|
56
58
|
|
|
@@ -59,8 +61,8 @@ export async function downloadFile(options: GaxiosOptions, targetFilePath: strin
|
|
|
59
61
|
const rateAveragingWindowSeconds = 5.0
|
|
60
62
|
|
|
61
63
|
let downloadStarted = false
|
|
62
|
-
let
|
|
63
|
-
let
|
|
64
|
+
let downloadedByteCount = 0
|
|
65
|
+
let totalByteCount: number | undefined = undefined
|
|
64
66
|
|
|
65
67
|
const statusUpdateInterval = 250
|
|
66
68
|
|
|
@@ -73,8 +75,8 @@ export async function downloadFile(options: GaxiosOptions, targetFilePath: strin
|
|
|
73
75
|
return
|
|
74
76
|
}
|
|
75
77
|
|
|
76
|
-
const totalMBytes = (
|
|
77
|
-
const downloadedMBytes =
|
|
78
|
+
const totalMBytes = (totalByteCount ?? 0) / 1000 / 1000
|
|
79
|
+
const downloadedMBytes = downloadedByteCount / 1000 / 1000
|
|
78
80
|
|
|
79
81
|
const elapsedTime = timer.elapsedTimeSeconds
|
|
80
82
|
const cumulativeDownloadRate = downloadedMBytes / elapsedTime
|
|
@@ -101,7 +103,7 @@ export async function downloadFile(options: GaxiosOptions, targetFilePath: strin
|
|
|
101
103
|
if (ttyOutput) {
|
|
102
104
|
let newString: string
|
|
103
105
|
|
|
104
|
-
if (
|
|
106
|
+
if (totalByteCount != undefined) {
|
|
105
107
|
const percentage = (downloadedMBytes / totalMBytes) * 100
|
|
106
108
|
|
|
107
109
|
newString = `${prompt}.. ${downloadedMbytesStr}MB/${totalMbytesStr}MB (${chalk.blueBright(percentage.toFixed(1) + '%')}, ${timer.elapsedTimeSeconds.toFixed(1)}s, ${downloadRateStr}MB/s)`
|
|
@@ -116,11 +118,11 @@ export async function downloadFile(options: GaxiosOptions, targetFilePath: strin
|
|
|
116
118
|
|
|
117
119
|
lastString = newString
|
|
118
120
|
} else {
|
|
119
|
-
if (
|
|
121
|
+
if (totalByteCount == undefined) {
|
|
120
122
|
return
|
|
121
123
|
}
|
|
122
124
|
|
|
123
|
-
const percent =
|
|
125
|
+
const percent = downloadedByteCount / totalByteCount
|
|
124
126
|
const percentDisplay = `${(Math.floor(percent * 10) * 10).toString()}%`
|
|
125
127
|
|
|
126
128
|
if (lastString == prompt) {
|
|
@@ -141,8 +143,8 @@ export async function downloadFile(options: GaxiosOptions, targetFilePath: strin
|
|
|
141
143
|
}
|
|
142
144
|
}
|
|
143
145
|
|
|
144
|
-
const contentLengthString = response.headers
|
|
145
|
-
|
|
146
|
+
const contentLengthString = response.headers.get('content-length')
|
|
147
|
+
totalByteCount = contentLengthString != undefined ? parseInt(contentLengthString) : undefined
|
|
146
148
|
|
|
147
149
|
const partialFilePath = `${targetFilePath}.${getRandomHexString(16)}.partial`
|
|
148
150
|
const fileWriter = new FileWriter(partialFilePath)
|
|
@@ -152,12 +154,22 @@ export async function downloadFile(options: GaxiosOptions, targetFilePath: strin
|
|
|
152
154
|
}, statusUpdateInterval)
|
|
153
155
|
|
|
154
156
|
try {
|
|
155
|
-
|
|
157
|
+
const responseBodyReader = response.body!.getReader()
|
|
158
|
+
|
|
159
|
+
while (true) {
|
|
160
|
+
const readableStreamResult = await responseBodyReader.read()
|
|
161
|
+
|
|
156
162
|
if (downloadStarted === false) {
|
|
157
163
|
downloadStarted = true
|
|
158
164
|
}
|
|
159
165
|
|
|
160
|
-
|
|
166
|
+
if (readableStreamResult.done) {
|
|
167
|
+
break
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const chunk = readableStreamResult.value
|
|
171
|
+
|
|
172
|
+
downloadedByteCount += chunk.length
|
|
161
173
|
|
|
162
174
|
await fileWriter.write(chunk)
|
|
163
175
|
}
|
|
@@ -178,3 +190,6 @@ export async function downloadFile(options: GaxiosOptions, targetFilePath: strin
|
|
|
178
190
|
|
|
179
191
|
await move(partialFilePath, targetFilePath)
|
|
180
192
|
}
|
|
193
|
+
|
|
194
|
+
export interface FileDownloaderCallbacks extends OperationCallbacks {
|
|
195
|
+
}
|
|
@@ -145,7 +145,7 @@ export async function writeUtf8File(filePath: string, content: string) {
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
export async function writeJsonFile(filePath: string, content: any, useJson5 = false) {
|
|
148
|
-
const textContent =
|
|
148
|
+
const textContent = stringifyAndFormatJson(content, useJson5)
|
|
149
149
|
|
|
150
150
|
await writeUtf8File(filePath, textContent)
|
|
151
151
|
}
|
package/src/utilities/Logger.ts
CHANGED
|
@@ -1,97 +1,114 @@
|
|
|
1
|
-
import chalk from 'chalk'
|
|
1
|
+
import chalk, { ChalkInstance } from 'chalk'
|
|
2
2
|
import { Timer } from './Timer.js'
|
|
3
3
|
import { logToStderr, writeToStderr, yieldToEventLoop } from './Utilities.js'
|
|
4
|
-
import { LogLevel, logLevelGreaterOrEqualTo, logLevelSmallerThan } from '../api/GlobalOptions.js'
|
|
5
|
-
|
|
6
|
-
let currentActiveLogger: Logger | null = null
|
|
7
4
|
|
|
8
5
|
export class Logger {
|
|
9
6
|
private timer = new Timer()
|
|
10
|
-
|
|
7
|
+
private started = false
|
|
8
|
+
|
|
9
|
+
constructor(
|
|
10
|
+
public readonly logLevel: LogLevel = 'warning',
|
|
11
|
+
public readonly timingMinimumLogLevel: LogLevel = 'info') {
|
|
12
|
+
}
|
|
11
13
|
|
|
12
14
|
start(title: string, titleColor = chalk.cyanBright) {
|
|
13
15
|
this.startAsync(title, false, titleColor)
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
async startAsync(title: string, yieldBeforeStart = true, titleColor = chalk.cyanBright) {
|
|
17
|
-
if (currentActiveLogger != null && currentActiveLogger != this) {
|
|
18
|
-
return
|
|
19
|
-
}
|
|
20
|
-
|
|
21
19
|
this.end()
|
|
22
20
|
|
|
23
21
|
if (yieldBeforeStart) {
|
|
24
22
|
await yieldToEventLoop()
|
|
25
23
|
}
|
|
26
24
|
|
|
27
|
-
if (logLevelGreaterOrEqualTo(
|
|
25
|
+
if (this.logLevelGreaterOrEqualTo(this.timingMinimumLogLevel)) {
|
|
28
26
|
writeToStderr(`${titleColor(title)}.. `)
|
|
29
27
|
}
|
|
30
28
|
|
|
31
|
-
this.
|
|
32
|
-
|
|
29
|
+
this.started = true
|
|
33
30
|
this.timer.restart()
|
|
34
31
|
}
|
|
35
32
|
|
|
36
|
-
|
|
37
|
-
this.
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
end() {
|
|
34
|
+
if (!this.started) {
|
|
35
|
+
return
|
|
36
|
+
}
|
|
40
37
|
|
|
41
|
-
|
|
42
|
-
this.active = false
|
|
43
|
-
currentActiveLogger = null
|
|
44
|
-
}
|
|
38
|
+
this.started = false
|
|
45
39
|
|
|
46
|
-
|
|
47
|
-
if (this.active && currentActiveLogger == this) {
|
|
40
|
+
if (this.logLevelGreaterOrEqualTo(this.timingMinimumLogLevel)) {
|
|
48
41
|
const elapsedTime = this.timer.elapsedTime
|
|
49
42
|
|
|
50
|
-
|
|
51
|
-
writeToStderr(`${elapsedTime.toFixed(1)}ms\n`)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
currentActiveLogger = null
|
|
43
|
+
writeToStderr(`${elapsedTime.toFixed(1)}ms\n`)
|
|
55
44
|
}
|
|
56
|
-
|
|
57
|
-
this.active = false
|
|
58
45
|
}
|
|
59
46
|
|
|
60
|
-
logDuration(message: any, startTime: number,
|
|
47
|
+
logDuration(message: any, startTime: number, logLevel: LogLevel = 'info', titleColor?: ChalkInstance) {
|
|
61
48
|
const duration = Timer.currentTime - startTime
|
|
62
49
|
|
|
63
|
-
|
|
50
|
+
titleColor = titleColor ?? Logger.getDefaultTitleColorForLogLevel(logLevel)
|
|
51
|
+
|
|
52
|
+
this.log(`${titleColor(message)}: ${duration.toFixed(1)}ms`)
|
|
64
53
|
}
|
|
65
54
|
|
|
66
|
-
logTitledMessage(title: string, content: any,
|
|
55
|
+
logTitledMessage(title: string, content: any, logLevel: LogLevel = 'info', titleColor?: ChalkInstance) {
|
|
56
|
+
titleColor = titleColor ?? Logger.getDefaultTitleColorForLogLevel(logLevel)
|
|
57
|
+
|
|
67
58
|
this.log(`${titleColor(title)}: ${content}`, logLevel)
|
|
68
59
|
}
|
|
69
60
|
|
|
70
61
|
log(message: any, logLevel: LogLevel = 'info') {
|
|
71
|
-
if (logLevelSmallerThan(logLevel)) {
|
|
62
|
+
if (this.logLevelSmallerThan(logLevel)) {
|
|
72
63
|
return
|
|
73
64
|
}
|
|
74
65
|
|
|
75
|
-
|
|
76
|
-
logToStderr(message)
|
|
77
|
-
}
|
|
66
|
+
logToStderr(message)
|
|
78
67
|
}
|
|
79
68
|
|
|
80
69
|
write(message: any, logLevel: LogLevel = 'info') {
|
|
81
|
-
if (logLevelSmallerThan(logLevel)) {
|
|
70
|
+
if (this.logLevelSmallerThan(logLevel)) {
|
|
82
71
|
return
|
|
83
72
|
}
|
|
84
73
|
|
|
85
|
-
|
|
86
|
-
writeToStderr(message)
|
|
87
|
-
}
|
|
74
|
+
writeToStderr(message)
|
|
88
75
|
}
|
|
89
76
|
|
|
90
77
|
getTimestamp() {
|
|
91
78
|
return Timer.currentTime
|
|
92
79
|
}
|
|
80
|
+
|
|
81
|
+
logLevelGreaterOrEqualTo(comparedLogLevel: LogLevel) {
|
|
82
|
+
return logLevelGreaterOrEqualTo(this.logLevel, comparedLogLevel)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
logLevelSmallerThan(comparedLogLevel: LogLevel) {
|
|
86
|
+
return logLevelSmallerThan(this.logLevel, comparedLogLevel)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
static getDefaultTitleColorForLogLevel(logLevel: LogLevel): ChalkInstance {
|
|
90
|
+
if (logLevel === 'error') {
|
|
91
|
+
return chalk.redBright
|
|
92
|
+
} else if (logLevel === 'warning') {
|
|
93
|
+
return chalk.yellow
|
|
94
|
+
} else {
|
|
95
|
+
return chalk.cyanBright
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function logLevelGreaterOrEqualTo(logLevel: LogLevel, comparedLogLevel: LogLevel) {
|
|
101
|
+
return !logLevelSmallerThan(logLevel, comparedLogLevel)
|
|
93
102
|
}
|
|
94
103
|
|
|
95
|
-
export function
|
|
96
|
-
|
|
104
|
+
export function logLevelSmallerThan(logLevel: LogLevel, comparedLogLevel: LogLevel) {
|
|
105
|
+
return logLevelToNumber(logLevel) < logLevelToNumber(comparedLogLevel)
|
|
97
106
|
}
|
|
107
|
+
|
|
108
|
+
export function logLevelToNumber(logLevel: LogLevel) {
|
|
109
|
+
return logLevels.indexOf(logLevel)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export const logLevels = ['silent', 'output', 'error', 'warning', 'info', 'trace'] as const
|
|
113
|
+
|
|
114
|
+
export type LogLevel = typeof logLevels[number]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { requestHttp } from 'easier-http-request'
|
|
2
2
|
|
|
3
3
|
export async function getPackageLatestVersion(packageName: string, timeout = 10000) {
|
|
4
|
-
const response = await
|
|
4
|
+
const response = await requestHttp({
|
|
5
5
|
method: 'GET',
|
|
6
6
|
|
|
7
7
|
url: `https://registry.npmjs.org/${packageName}/latest`,
|
|
@@ -12,12 +12,10 @@ export async function getPackageLatestVersion(packageName: string, timeout = 100
|
|
|
12
12
|
headers: {
|
|
13
13
|
},
|
|
14
14
|
|
|
15
|
-
responseType: 'json',
|
|
16
|
-
|
|
17
15
|
timeout,
|
|
18
16
|
})
|
|
19
17
|
|
|
20
|
-
const
|
|
18
|
+
const responseObject = await response.json()
|
|
21
19
|
|
|
22
|
-
return
|
|
20
|
+
return responseObject.version
|
|
23
21
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export class OpenPromise<T = void>
|
|
2
|
-
{
|
|
1
|
+
export class OpenPromise<T = void> {
|
|
3
2
|
promise: Promise<T>
|
|
4
3
|
resolve: (value: T) => void = () => { throw new Error('Open promise resolved before initialization') }
|
|
5
4
|
reject: (reason?: any) => void = () => { throw new Error('Open promise rejected before initialization') }
|