pyAudioAnalysis icon indicating copy to clipboard operation
pyAudioAnalysis copied to clipboard

bug when running demo code for diarization - "TypeError: only size-1 arrays can be converted to Python scalars"

Open erjan opened this issue 6 years ago • 0 comments

I m trying to run this code, using the same file as in the official repo.

from pyAudioAnalysis import audioSegmentation as aS
[flagsInd, classesAll, acc, CM] = aS.mtFileClassification("diarizationExample.wav", "svmSM", "svm", True, 'dar.segments.txt')

I have eyed3, pydub, hmmlearn and other libs installed. The code above gives me the error:

speech [100.] [41.]
music [0.] [0.]
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-24-0297348e7ff8> in <module>()
      1 import ffmpeg
      2 from pyAudioAnalysis import audioSegmentation as aS
----> 3 [flagsInd, classesAll, acc, CM] = aS.mtFileClassification("diarizationExample.wav", "svmSM", "svm", True, 'dar.segments.txt')

~/anaconda3/envs/python3/lib/python3.6/site-packages/pyAudioAnalysis/audioSegmentation.py in mtFileClassification(input_file, model_name, model_type, plot_results, gt_file)
    572         flags_ind_gt = numpy.array([])
    573     acc = plotSegmentationResults(flags_ind, flags_ind_gt,
--> 574                                   class_names, mt_step, not plot_results)
    575     if acc >= 0:
    576         print("Overall Accuracy: {0:.3f}".format(acc)  )

~/anaconda3/envs/python3/lib/python3.6/site-packages/pyAudioAnalysis/audioSegmentation.py in plotSegmentationResults(flags_ind, flags_ind_gt, class_names, mt_step, ONLY_EVALUATE)
    228         ax2.set_xticks(numpy.array(range(len(class_names) + 1)))
    229         ax2.set_xticklabels([" "] + class_names)
--> 230         ax2.bar(numpy.array(range(len(class_names))) + 0.5, percentages)
    231 
    232         ax3 = fig.add_subplot(224)

~/anaconda3/envs/python3/lib/python3.6/site-packages/matplotlib/__init__.py in inner(ax, data, *args, **kwargs)
   1808                         "the Matplotlib list!)" % (label_namer, func.__name__),
   1809                         RuntimeWarning, stacklevel=2)
-> 1810             return func(ax, *args, **kwargs)
   1811 
   1812         inner.__doc__ = _add_data_doc(inner.__doc__,

~/anaconda3/envs/python3/lib/python3.6/site-packages/matplotlib/axes/_axes.py in bar(self, x, height, width, bottom, align, **kwargs)
   2294                 edgecolor=e,
   2295                 linewidth=lw,
-> 2296                 label='_nolegend_',
   2297                 )
   2298             r.update(kwargs)

~/anaconda3/envs/python3/lib/python3.6/site-packages/matplotlib/patches.py in __init__(self, xy, width, height, angle, **kwargs)
    656         """
    657 
--> 658         Patch.__init__(self, **kwargs)
    659 
    660         self._x0 = xy[0]

~/anaconda3/envs/python3/lib/python3.6/site-packages/matplotlib/patches.py in __init__(self, edgecolor, facecolor, color, linewidth, linestyle, antialiased, hatch, fill, capstyle, joinstyle, **kwargs)
     85         self.set_fill(fill)
     86         self.set_linestyle(linestyle)
---> 87         self.set_linewidth(linewidth)
     88         self.set_antialiased(antialiased)
     89         self.set_hatch(hatch)

~/anaconda3/envs/python3/lib/python3.6/site-packages/matplotlib/patches.py in set_linewidth(self, w)
    346                 w = mpl.rcParams['axes.linewidth']
    347 
--> 348         self._linewidth = float(w)
    349         # scale the dash pattern by the linewidth
    350         offset, ls = self._us_dashes

TypeError: only size-1 arrays can be converted to Python scalars

How to make it run and diarize the audio file?

erjan avatar Jan 18 '20 22:01 erjan