Skip to content

Commit d160905

Browse files
authored
explaining downsampling / low-pass filter
fixes #30
1 parent 013e60e commit d160905

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

speech-to-text/webaudio-l16-stream.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,13 @@ WebAudioL16Stream.prototype.downsample = function downsample(bufferNewSamples) {
7878
buffer = bufferNewSamples;
7979
}
8080

81-
// downsampling variables
81+
// Downsampling and low-pass filter:
82+
// Input audio is typically 48kHz, this downsamples it to 16kHz.
83+
// It uses a FIR (finite impulse response) Filter to remove (or, at least attinuate)
84+
// audio frequencies > ~8kHz because sampled audio cannot accurately represent
85+
// frequiencies greater than half of the sample rate.
86+
// (Human voice tops out at < 4kHz, so nothing important is lost for transcription.)
87+
// See http://dsp.stackexchange.com/a/37475/26392 for a good explination of this code.
8288
var filter = [
8389
-0.037935,
8490
-0.00089024,

0 commit comments

Comments
 (0)