How can I make sure sox doesn't perform automatic dithering without knowing the version?
I'm using sox to resample audio before introducing it to our speech 开发者_运维百科detection system, but I've hit a snag with version 14.3 of sox adding automatic dithering by default to the resampling operation, which we don't want.
This wouldn't be a problem if we knew that we were always using sox ≥ 14.3, as we could just use the new -D
flag to disable it:
sox original.wav -Dr 8000 new.wav
However, we cannot guarantee that we will be using sox ≥ 14.3 so I need some way to specify the -D flag if needed, but leave it out otherwise (as it errors when it doesn't recognise it).
Any ideas?
My first thought is just something like:
# assume -D flag is available to disable automatic dithering
sox original.wav -Dr 8000 new.wav
# if -D flag isn't available (sox < 14.3), then dithering isn't automatic
if [$? -ne 0]; then
sox original.wav -r 8000 new.wav
fi
As checking the version numbers seemed like it would probably be a pain and not very future-proof.
The only main disadvantage is that if there is some other error, the operation is attempted twice.
精彩评论