Add JavaScript API (wasm) for speech enhancement GTCRN models (#2007)
This commit is contained in:
@@ -24,6 +24,16 @@ In the following, we describe how to use [sherpa-onnx](https://github.com/k2-fsa
|
||||
for text-to-speech and speech-to-text.
|
||||
|
||||
|
||||
# Speech enhancement
|
||||
|
||||
In the following, we demonstrate how to run speech enhancement.
|
||||
|
||||
```bash
|
||||
curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/speech-enhancement-models/gtcrn_simple.onnx
|
||||
curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/speech-enhancement-models/inp_16k.wav
|
||||
node ./test-offline-speech-enhancement-gtcrn.js
|
||||
```
|
||||
|
||||
# Speaker diarization
|
||||
|
||||
In the following, we demonstrate how to run speaker diarization.
|
||||
|
||||
30
nodejs-examples/test-offline-speech-enhancement-gtcrn.js
Normal file
30
nodejs-examples/test-offline-speech-enhancement-gtcrn.js
Normal file
@@ -0,0 +1,30 @@
|
||||
// Copyright (c) 2025 Xiaomi Corporation (authors: Fangjun Kuang)
|
||||
//
|
||||
// Please download ./gtcrn_simple.onnx and ./inp_16k.wav used in this file
|
||||
// from
|
||||
// https://github.com/k2-fsa/sherpa-onnx/releases/tag/speech-enhancement-models
|
||||
//
|
||||
// This script shows how to use speech enhancement API from sherpa-onnx.
|
||||
const sherpa_onnx = require('sherpa-onnx');
|
||||
|
||||
function createOfflineSpeechDenoiser() {
|
||||
let config = {
|
||||
model: {
|
||||
gtcrn: {model: './gtcrn_simple.onnx'},
|
||||
debug: 1,
|
||||
},
|
||||
};
|
||||
|
||||
return sherpa_onnx.createOfflineSpeechDenoiser(config);
|
||||
}
|
||||
|
||||
speech_denoiser = createOfflineSpeechDenoiser();
|
||||
|
||||
const waveFilename = './inp_16k.wav';
|
||||
const wave = sherpa_onnx.readWave(waveFilename);
|
||||
|
||||
const denoised = speech_denoiser.run(wave.samples, wave.sampleRate);
|
||||
sherpa_onnx.writeWave('./enhanced-16k.wav', denoised);
|
||||
console.log('Saved to ./enhanced-16k.wav');
|
||||
|
||||
speech_denoiser.free();
|
||||
Reference in New Issue
Block a user