How does JavaScript modify the sampling rate (sampleRate) of audio?

because using JavaScript to call iFLYTEK speech recognition Web API, iFLYTEK (and others) only supports audio with a 16K sampling rate of (sampleRate). However, HTML5"s Web Audio has not found a way to convert the sampling rate.

searched several other people"s methods on the Internet, and all of them had problems such as unable to play after audio conversion.

is there any convenient way for JavaScript to convert the sampling rate?


OfflineAudioContext learn about

https://developer.mozilla.org.

seems interesting, so I wrote a demo:
https://jsfiddle.net/liqi0816.

.

record first, prompt to finish, then convert, and then play back. If the headphones are good enough, the noise caused by non-integer conversion of the sampling rate can be clearly recognized.

the above code is tested under Chrome67.

Menu