In [1]:
import os
from matplotlib import pyplot as plt
from tomato.joint.completeanalyzer import CompleteAnalyzer
In [2]:
data_folder = os.path.join('..', 'sample-data')
# score input
symbtr_name = 'ussak--sazsemaisi--aksaksemai----neyzen_aziz_dede'
txt_score_filename = os.path.join(data_folder, symbtr_name, symbtr_name + '.txt')
mu2_score_filename = os.path.join(data_folder, symbtr_name, symbtr_name + '.mu2')
# audio input
audio_mbid = 'f970f1e0-0be9-4914-8302-709a0eac088e'
audio_filename = os.path.join(data_folder, symbtr_name, audio_mbid, audio_mbid + '.mp3')
# instantiate
completeAnalyzer = CompleteAnalyzer()
In [3]:
# Apply the complete analysis. The output tuple will have (summarized_features,
# score_features, audio_features, score_informed_audio_features, joint_features) in order
complete_features = completeAnalyzer.analyze(
symbtr_txt_filename=txt_score_filename, symbtr_mu2_filename=mu2_score_filename,
symbtr_name=symbtr_name, audio_filename=audio_filename, audio_metadata=audio_mbid)
# plot the summarized features
plt.rcParams['figure.figsize'] = [20, 8]
fig, ax = completeAnalyzer.plot(complete_features[0])
ax[0].set_ylim([50, 500])
plt.show()
... or you can use the single line call "analyze" of each analyzer object. The procedure below does all the analysis for the given audio and score pair.
In [4]:
from tomato.audio.audioanalyzer import AudioAnalyzer
from tomato.symbolic.symbtranalyzer import SymbTrAnalyzer
from tomato.joint.jointanalyzer import JointAnalyzer
# instantiate analyzer objects
scoreAnalyzer = SymbTrAnalyzer(verbose=True)
audioAnalyzer = AudioAnalyzer(verbose=True)
jointAnalyzer = JointAnalyzer(verbose=True)
# score analysis
score_features = scoreAnalyzer.analyze(
txt_score_filename, mu2_score_filename, symbtr_name=symbtr_name)
# audio analysis
audio_features = audioAnalyzer.analyze(
audio_filename, makam=score_features['metadata']['makam']['symbtr_slug'])
# joint analysis
joint_features, score_informed_audio_features = jointAnalyzer.analyze(
txt_score_filename, score_features, audio_filename, audio_features['pitch'])
# redo some steps in audio analysis
score_informed_audio_features = audioAnalyzer.analyze(
metadata=False, pitch=False, **score_informed_audio_features)
# summarize all the features extracted from all sources
summarized_features = jointAnalyzer.summarize(
audio_features, score_features, joint_features, score_informed_audio_features)