In [19]:
%pylab inline
from __future__ import division

import timeside.core
from timeside.core import get_processor

wavFile = '/home/thomas/code/timeside/exempleCMMR/CNRSMH_I_2013_202_001_06.mp3'

file_decoder = get_processor('file_decoder')(wavFile, start=0, duration = 60)
file_decoder.output_blocksize=2048

irit4hz = get_processor('irit_speech_4hz')()

specgram_ = get_processor('spectrogram_analyzer')()

iritEntropy = get_processor('irit_speech_entropy')()
Populating the interactive namespace from numpy and matplotlib
In [20]:
# Define and run the pipe in one line !
(file_decoder | irit4hz | iritEntropy | specgram_).run()
In [21]:
# Display avalaible results
irit4hz.results.keys()
Out[21]:
['irit_speech_4hz.energy_confidence',
 'irit_speech_4hz.segments',
 'irit_speech_4hz.segments_median']
In [22]:
# Pick segmentation results
irit_4hz_seg = irit4hz.results['irit_speech_4hz.segments']
In [23]:
# Display avalaible results
iritEntropy.results.keys()
Out[23]:
['irit_speech_entropy.confidence', 'irit_speech_entropy.segments']
In [24]:
# Pick segmentation results
irit_entropy_seg = iritEntropy.results['irit_speech_entropy.segments']
In [25]:
# Display the result through timeside 
irit_4hz_seg.render();
In [26]:
# Display Spectrogram + IRIT SPEECH 
plt.figure(1)

spec_res = specgram_.results['spectrogram_analyzer']
N = spec_res.parameters['fft_size']
plt.imshow(20 * np.log10(spec_res.data.T+1e-2),
           origin='lower',
           extent=[spec_res.time[0], spec_res.time[-1], 0,
                   (N // 2 + 1) / N * spec_res.data_object.frame_metadata.samplerate],
           aspect='auto', cmap = 'binary')

for (time, dur, label) in zip(irit_4hz_seg.time, irit_4hz_seg.duration, irit_4hz_seg.data):
    if label == 0:
        pass
        #plt.axvspan(time, time+dur , color='g', alpha=0.4)
    elif label == 1:
        plt.axvspan(time, time+dur , color='b', alpha=0.3)

plt.title('Spectrogram + 4Hz Seg')
plt.axis('tight')
plt.ylim( (0, 8000) )
plt.grid()
In [27]:
# Display the result through timeside 
irit_entropy_seg.render();
In [28]:
# Entropy --------------------------
plt.figure(2)

spec_res = specgram_.results['spectrogram_analyzer']
N = spec_res.parameters['fft_size']
plt.imshow(20 * np.log10(spec_res.data.T+1e-2),
           origin='lower',
           extent=[spec_res.time[0], spec_res.time[-1], 0,
                   (N // 2 + 1) / N * spec_res.data_object.frame_metadata.samplerate],
           aspect='auto', cmap = 'binary')


for (time, dur, label) in zip(irit_entropy_seg.time, irit_entropy_seg.duration, irit_4hz_seg.data):
    if label == 0:
        pass
        #plt.axvspan(time, time+dur , color='g', alpha=0.4)
    elif label == 1:
        plt.axvspan(time, time+dur , color='b', alpha=0.3)

plt.title('Spectrogram + entropy Seg')
plt.axis('tight')
plt.grid()
#
plt.show()
In [29]:
spec_res.parameters
Out[29]:
{'fft_size': 2048}
In [29]: