-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
splitting a file with silence #117
Comments
I should clarify my question more: I'm aware that the 'silence' effect is implemented. My questions was more related to how I could translate ": newfile : restart" idiom to pysox. |
i'm not sure if this is featured in pysox. it might be good to bring this up to @rabitt |
Thanks for your response @lostanlen . I will post a more clearly specified feature request then. |
I have a small bash script to use # splits input file into clip files based on a silence threshold
sox --show-progress $1 clip.wav silence 1 0.1 1% 1 0.1 1% : newfile : restart
# applies fade-in fade-out to each output file
for f in clip*
do
name=$(basename -s .wav $f)
newname="$name-f.wav"
sox $f $newname fade 0.1 0
done My question to @rabitt is whether it is possible to translate this script's functionality (in particular the ": newfile : restart" idiom) into a pure-python pysox solution. |
Trying to convert the splitting part of the above sox call into current pysox, I got as far as the following: import sox
t = sox.Transformer()
t.silence(1, 1.0, 0.1)
t.silence(-1, 1.0, 0.1)
t.build('input.wav', 'clip.wav', extra_args=[':', 'newfile', ':', 'restart'])
# pysox converts this into the following sox args:
args = ['sox', '-D', '-V2', '-c', '1', 's104.wav', 'clip.wav', 'silence', '1', '0.100000', '1.000000%', 'reverse', 'silence', '1', '0.100000', '1.000000%', 'reverse', ':', 'newfile', ':', 'restart'] The problem is that this doesn't split the input file. I presume the culprit is the default translation to 'reverse' which always output one file. Also the arg order for pysox |
Hey @shakfu
The short answer is, no pysox doesn't currently support the
Yes, this is the case for several of the transforms - the documentation should describe what each argument is doing, but it's true that it may not exactly match the command line tool's ordering. Note that for the silence command in particular, the "location" argument in pysox is there to support removing silence from the end of the file, hence the reverse. |
@rabitt I do love pysox it rocks guys & thankx I am going to steal @shakfu bash script but also would love to do this in pysox (creating model datasets for kws) Thnx @shakfu for the script as was just about to ask about silence splitting and saw your post PS if it could also do no action but output split points to txt would also be useful might be useful with a ASR aligner as still have to get one that extracts words satisfactory. |
@rabitt Thanks for your response. It would be great if the pysox API could be extended to accommodate this use-case. Naturally, it would be great to accomplish this in python (-: @StuartIanNaylor Thanks, glad that my little script can be of use. Incidentally, I was curious about the answer to your last question and found some possible solutions in this stack overflow exchange. |
I just suddenly clicked and didn't like writing out to harddrive all the time use tmp... |
One typical use case for me is to split a file using the
silence
effect as outlined in this excellent sox tutorial https://madskjeldgaard.dk/posts/sox-tutorial-split-by-silence/gives "clip001.wav", "clip002.wav" etc. with only the audio in clip and without the silence in between.
Is it possible to do this in pysox (and apply a fade-in and fade-out to each resulting clip)?
The text was updated successfully, but these errors were encountered: