mirror of
https://github.com/ggerganov/whisper.cpp.git
synced 2023-11-04 02:52:44 +03:00
command.wasm : add voice assistant example for the Web (#171)
Same as the command-line tool "command", but runs in the browser Also, added helper script "extra/deploy-wasm.sh" and fixed some timing constants for the WASM examples.
This commit is contained in:
@@ -225,12 +225,6 @@
|
||||
}
|
||||
};
|
||||
|
||||
const kMaxAudio_s = 120;
|
||||
const kSampleRate = 16000;
|
||||
|
||||
window.AudioContext = window.AudioContext || window.webkitAudioContext;
|
||||
window.OfflineAudioContext = window.OfflineAudioContext || window.webkitOfflineAudioContext;
|
||||
|
||||
// web audio context
|
||||
var context = null;
|
||||
|
||||
@@ -348,9 +342,21 @@
|
||||
// audio file
|
||||
//
|
||||
|
||||
const kMaxAudio_s = 120;
|
||||
const kSampleRate = 16000;
|
||||
|
||||
window.AudioContext = window.AudioContext || window.webkitAudioContext;
|
||||
window.OfflineAudioContext = window.OfflineAudioContext || window.webkitOfflineAudioContext;
|
||||
|
||||
function loadAudio(event) {
|
||||
if (!context) {
|
||||
context = new AudioContext({sampleRate: 16000});
|
||||
context = new AudioContext({
|
||||
sampleRate: kSampleRate,
|
||||
channelCount: 1,
|
||||
echoCancellation: false,
|
||||
autoGainControl: true,
|
||||
noiseSuppression: true,
|
||||
});
|
||||
}
|
||||
|
||||
var file = event.target.files[0] || null;
|
||||
@@ -410,7 +416,13 @@
|
||||
// update progress information
|
||||
function startRecording() {
|
||||
if (!context) {
|
||||
context = new AudioContext({sampleRate: 16000});
|
||||
context = new AudioContext({
|
||||
sampleRate: kSampleRate,
|
||||
channelCount: 1,
|
||||
echoCancellation: false,
|
||||
autoGainControl: true,
|
||||
noiseSuppression: true,
|
||||
});
|
||||
}
|
||||
|
||||
document.getElementById('start').disabled = true;
|
||||
|
||||
Reference in New Issue
Block a user