Subject: Re: [AUDITORY] Cut silence in beginning and end of speech recordings automatically? From: gvoysey <gvoysey@xxxxxxxx> Date: Fri, 5 Mar 2021 09:53:34 -0500--0000000000003b85a005bccb4023 Content-Type: text/plain; charset="UTF-8" I've used https://github.com/wiseman/py-webrtcvad before, with mixed results. I think it's mono PCM-16 only, but it is entirely offline. The parameter tuning is a little twitchy. On Fri, Mar 5, 2021 at 6:10 AM Ale Osses <ale.a.osses@xxxxxxxx> wrote: > Dear Tamar, > > In MATLAB I recommend the following (this assumes a monaural sound (one > column vector), so you have to adjust it for stereo sounds): > > [insig,fs] = audioread(file2load); > > Ma_amplitude = max(abs(insig)); % maximum absolute amplitude > dB_below = 100; % dB below the maximum amplitude to look for... > Mi_amplitude = Ma_amplitude*10^(-dB_below/20); > idx_i = find(abs(insig1)>=Mi_amplitude,1,'first'); % first sample with > absolute value above Mi_amplitude > idx_f = find(abs(insig1)<=Mi_amplitude,1,'last'); % last sample with > absolute value above Mi_amplitude > insig_cut = insig(idx_i:idx_f); > > I hope it is intuitive. If you are conservative you can set the "dB_below" > to cut amplitudes 100 dB the maximum value but it could be good enough to > use 60 dB of 40 dB, just make sure you don't get clips when reproducing the > resulting files... > > Cheers, > Alejandro > > Op vr 5 mrt. 2021 om 06:25 schreef Tamar Regev <tamaregev@xxxxxxxx>: > >> Hi all, >> >> Does anyone know of a good way to automatically trim silent parts (which >> may contain some minor background noise) at the beginning and end of speech >> recordings? >> >> Preferentially using Matlab but any other automatic way would work (we >> want to run this on *many* sound files). >> >> Thanks a lot! >> Tamar >> >> -- Graham Voysey Boston University College of Engineering HRC Research Engineer Auditory Biophysics and Simulation Laboratory ERB 413 --0000000000003b85a005bccb4023 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">I've used <a href=3D"https://github.com/wiseman/py-web= rtcvad">https://github.com/wiseman/py-webrtcvad</a>=C2=A0 before, with mixe= d results.=C2=A0 I think it's mono PCM-16 only, but it is entirely offl= ine. The parameter tuning is a little twitchy.<br></div><br><div class=3D"g= mail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Fri, Mar 5, 2021 at 6:= 10 AM Ale Osses <<a href=3D"mailto:ale.a.osses@xxxxxxxx">ale.a.osses@xxxxxxxx= ail.com</a>> wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"= margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-lef= t:1ex"><div dir=3D"ltr">Dear Tamar,<div><br></div><div>In MATLAB I recommen= d the following (this assumes a monaural sound (one column vector), so you = have to adjust=C2=A0it for stereo sounds):</div><div><br></div><div>[insig,= fs] =3D audioread(file2load); <br><br>Ma_amplitude =3D max(abs(insig)); % m= aximum absolute amplitude<br>dB_below =3D 100; % dB below the maximum ampli= tude to look for...<br>Mi_amplitude =3D Ma_amplitude*10^(-dB_below/20);<br>= idx_i =3D find(abs(insig1)>=3DMi_amplitude,1,'first'); % first s= ample with absolute value above Mi_amplitude<br>idx_f =3D find(abs(insig1)&= lt;=3DMi_amplitude,1,'last'); % last sample with absolute value abo= ve Mi_amplitude<br>insig_cut =3D insig(idx_i:idx_f);<br></div><div><br></di= v><div>I hope it is intuitive. If you are conservative you can set the &quo= t;dB_below" to cut amplitudes 100 dB the maximum value but it could be= good enough to use 60 dB of 40 dB, just make sure you don't get clips = when reproducing the resulting files...</div><div><br></div><div>Cheers,</d= iv><div>Alejandro</div></div><br><div class=3D"gmail_quote"><div dir=3D"ltr= " class=3D"gmail_attr">Op vr 5 mrt. 2021 om 06:25 schreef Tamar Regev <<= a href=3D"mailto:tamaregev@xxxxxxxx" target=3D"_blank">tamaregev@xxxxxxxx= </a>>:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0p= x 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div d= ir=3D"ltr">Hi all,<div><br></div><div>Does anyone know of a good way to aut= omatically trim silent parts (which may contain some=C2=A0minor background = noise) at the beginning and end of speech recordings?</div><div><br></div><= div>Preferentially using Matlab but any other automatic way would work (we = want to run this on <u>many</u> sound files).</div><div><br></div><div>Than= ks a lot!</div><div>Tamar</div><div><br></div></div> </blockquote></div> </blockquote></div><br clear=3D"all"><br>-- <br><div dir=3D"ltr" class=3D"g= mail_signature"><div dir=3D"ltr">Graham Voysey<br>Boston University College= of Engineering<br>HRC Research Engineer<br>Auditory Biophysics and Simulat= ion Laboratory<br>ERB 413</div></div> --0000000000003b85a005bccb4023--