%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
# Define and run the pipe in one line !
(file_decoder | irit4hz | iritEntropy | specgram_).run()
# Display avalaible results
irit4hz.results.keys()
['irit_speech_4hz.energy_confidence', 'irit_speech_4hz.segments', 'irit_speech_4hz.segments_median']
# Pick segmentation results
irit_4hz_seg = irit4hz.results['irit_speech_4hz.segments']
# Display avalaible results
iritEntropy.results.keys()
['irit_speech_entropy.confidence', 'irit_speech_entropy.segments']
# Pick segmentation results
irit_entropy_seg = iritEntropy.results['irit_speech_entropy.segments']
# Display the result through timeside
irit_4hz_seg.render();
# 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()
# Display the result through timeside
irit_entropy_seg.render();
# 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()
spec_res.parameters
{'fft_size': 2048}