def list_wav_files(datapath,maxdepth=1):
return list_files(datapath, filter="f -name '*.wav' -maxdepth %d"%maxdepth)
+def list_snd_files(datapath,maxdepth=1):
+ return list_files(datapath, filter="f -name '*.wav' -o -name '*.aif' -maxdepth %d"%maxdepth)
+
def list_dirs(datapath):
return list_files(datapath, filter="d")
xorig += 1./todraw
g.gnuplot('unset multiplot;')
+def downsample_audio(time,data,maxpoints=10000):
+ """ create gnuplot plot from an audio file """
+ import numarray
+ length = len(time)
+ downsample = length/maxpoints
+ if downsample == 0: downsample = 1
+ x = numarray.array(time).resize(length)[0:-1:downsample]
+ y = numarray.array(data).resize(length)[0:-1:downsample]
+ return x,y
+
def make_audio_plot(time,data,maxpoints=10000):
""" create gnuplot plot from an audio file """
import numarray
# check if datafile exists truth
datafile = filename.replace('.wav','.txt')
+ if datafile == filename: datafile = ""
if not os.path.isfile(datafile):
title = "truth file not found"
t = Gnuplot.Data(0,0,with='impulses')
# check if ground truth exists
datafile = filename.replace('.wav','.txt')
+ if datafile == filename: datafile = ""
if not os.path.isfile(datafile):
title = "truth file not found"
t = Gnuplot.Data(0,0,with='impulses')