To everyone reading this and banging their heads into the wall:
Don't bother.
I'm not saying it is not possible, but when it's not easy, just make an easier solution.
Sox is a command line tool. There is the latest Windows version already compiled for you, so you absolutely don't need pysox
.
Here is a Python 3 example how to use sox.exe
, provided it is distributed with your application and is in the same folder:
command = """sox.exe "{0}" """.format(FilePath)
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
sox = subprocess.Popen(command, startupinfo = startupinfo)
You won't see any popup, there will be little to no delay, you can implement callback functions if you really need to. Here is the full list of available commands: http://sox.sourceforge.net/sox.html
The only bad thing is that it is not possible to send Ctrl+C
command to sox.exe as a subprocess to stop recording, for instance. Thus, I've ended up using pyaudio
for recording and sox.exe
for converting .wav
to .ogg
with specific parameters.