I made a male and female 'talking-head' animation that runs while an audio file is playing. It works well but to make it better I would like the animation (mouth movement especially) to pause during any silence in the audio file. Is there a way with JavaScript to detect silence (or near silence) while an audio file is playing? Note: my application has a button to play and pause the audio.
Asked
Active
Viewed 554 times
2
-
Does this answer your question? https://stackoverflow.com/questions/24515978/html-audio-recording-until-silence – Maestro Jul 23 '20 at 05:06
-
And to connect your HTMLAudioElements to the AnalyserNode, either use [audio_context.createMediaElementSource](https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/createMediaElementSource) or audio_context.createMediaStreamSource( element.captureStream() ) (will require that your media are served with the proper CORS headers anyway). Oh and an other, naive but working way would be to store the positions of silence in a JSON file and check the audios current time. – Kaiido Jul 23 '20 at 06:23
-
The answers suggested are dealing with recording. In my application, I'm not recording. I just play an audio and want to stop the head (mouth) animation during any silence inside the audio played (when the voice pauses between paragraphs). I just wanted to know if JavaScript has a may to monior silences of the audio played. – mlsmet Jul 24 '20 at 12:30
-
Both accepted answers include exactly the feature you want: detect silence. That the original code in the first link was recording it makes no difference, and the second answer really only has the silence detection code. – Kaiido Jul 27 '20 at 02:37
-
Thanks Kaiido. Sorry, I didn't get it right the first time. It worked now! – mlsmet Jul 29 '20 at 03:52