I'm trying to use the sox
terminal package in Linux to create a spectrogram png and display it in a GUI using Python. As I will need to use a sequence of images, I'm ultimately planning to implement this in a multiprocessing.Manager|Queue
context.
The terminal command is:
:~$ sox sound.wav -n trim 42 6 rate 30k spectrogram -q 8 -r -l -m -o spectrogram.png
I can call this in a Python (3.4) script using
import subprocess
path= 'spectrogram.png'
process = 'sox sound.wav -n trim 42 6 rate 30k spectrogram -q 8 -r -l -m -o {}'.format(path)
subprocess.call(process, shell=True)
but (to speed things up a bit on a Raspberry Pi) I would rather not save to disk and then reload for the GUI.
My attempts using mkfifo
e.g.:
import subprocess
import os
path= '/tmp/spectrogram.png'
os.mkfifo(path)
process = 'sox sound.wav -n trim 42 6 rate 30k spectrogram -q 8 -r -l -m -o {}'.format(path)
subprocess.call(process, shell=True)
have all failed (blocking, presumably cos I'm only using a single process?).
Examples I've found all concentrate on separate server/receiver processes and/or processing the terminal output (using, say stdout) not a file created by a command line process.
Not being experienced in Python (and a novice with the command line), I sense I'm "barking up the wrong tree" but don't I know where to look next!