lagmoellertim / unsilence

Console Interface and Library to remove silent parts of a media file 🔈
https://unsilence.readthedocs.io/
MIT License
556 stars 45 forks source link

Define level of silence #85

Open jamesoliver1981 opened 3 years ago

jamesoliver1981 commented 3 years ago

Is your feature request related to a problem? Please describe. This works really well however I have some background noise that is carried through and that I would like to be removed too Therefore it would be great if I could ignore silence below a certain threshold.

Describe the solution you'd like A parameter of say decibels below which sound is treated as silence. Default can be zero.

Describe alternatives you've considered

Additional context

lagmoellertim commented 3 years ago

I think the feature you mean is already implemented, you could try the -sl MINIMUM_SILENCE_LEVEL flag in terminal (defaults to -35db) and adjust it to your liking. To see all available flags and options, you can use unsilence --help

jamesoliver1981 commented 3 years ago

Thank you. I am working in jupyter rather than in the terminal. Looking at the code on git hub, I cannot see where I would adjust this. I have tried this u.detect_silence(MINIMUM_SILENCE_LEVEL = 70)

but sadly it didn't change the results at all though did not throw an error. Could you advise how I could use this feature?

I am using your suggested code to process the file:

from unsilence import Unsilence
u = Unsilence(path2+"first3_nopoints.wav")

u.detect_silence(MINIMUM_SILENCE_LEVEL = 70)

estimated_time = u.estimate_time(audible_speed=5, silent_speed=2)  # Estimate time savings
print(estimated_time)

u.render_media(path2+"first3_nopoints_silenceout_50.wav", audio_only=True)