Question

I am writing an application using Python with PyQT4 bindings, which should be multiplatform. The version of Python I'm using is 3.3. I fail to build pysox (SoX bindings for Python) under MS WindowsXP, although, step by step, I have managed to: - compile Sox 14.4.1 from sources, using VC++ 10.0 Express. - compile Cython to compile pysox. Right now it fails to build, saying that strings.h is not found (if I plase SoX sources alonside with libsox.lib into the corresponding directory for pysox), then - something else not found, etc. To be short, it fails to compile because it continues asking for Linux-specific headers, which I don't need right now, because I am under Windows.

The question is, is it possible to compile pysox under Windows AT ALL? Or I should rather compile it under Linux and then import the compiled libraries to Windows, because Python is multiplatform?

Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top