How to detect the silence part in audio when using wavesurfer.js #2678
-
Beta Was this translation helpful? Give feedback.
Replies: 6 comments
-
I don't believe wavesurfer.js provides any methods for directly manipulating/analyzing audio. However, you can use the JavaScript Web Audio API for such features. |
Beta Was this translation helpful? Give feedback.
-
@truong24hdev have a look at this section of the code, you can essentially add in there a part where it would check the peak and manipulate the progress and bar colours before it renders if it's 0.
wavesurfer.js/src/drawer.multicanvas.js Line 566 in a92da7f |
Beta Was this translation helpful? Give feedback.
-
You can ask WaveSurfer to give you an array of peaks in the waveform and then look for 0 values or sequences of 0 values within the array. This is the line of code that I used to generate such an array. I hope this is what you are looking for. I don't remember why I said that accuracy is irrelevant.
|
Beta Was this translation helpful? Give feedback.
-
Do you still need help with this? I think I can help you. |
Beta Was this translation helpful? Give feedback.
-
I just wrote this. hope it helps! |
Beta Was this translation helpful? Give feedback.
-
I've added an example of silence detection in the new version of wavesurfer: https://wavesurfer-ts.pages.dev/tutorial/#/examples/silence.js |
Beta Was this translation helpful? Give feedback.
I've added an example of silence detection in the new version of wavesurfer: https://wavesurfer-ts.pages.dev/tutorial/#/examples/silence.js