Audio Tagging¶
The goal of audio tagging is to assign tags (one or many) to audio signal. Tags can be considered as sound events without timing information (onset or offset).
Metrics¶
Main functions:
sed_eval.audio_tag.AudioTaggingMetrics.evaluate
: Calculate intermediate values for evaluation and accumulate them.sed_eval.audio_tag.AudioTaggingMetrics.results
: Calculate and return all metrics.sed_eval.audio_tag.AudioTaggingMetrics.results_overall_metrics
: Calculate and return overall metrics (micro-averaged).sed_eval.audio_tag.AudioTaggingMetrics.results_class_wise_metrics
: Calculate and return class-wise metrics.sed_eval.audio_tag.AudioTaggingMetrics.results_class_wise_average_metrics
: Calculate and return class-wise average metrics (macro-averaged).
Function sed_eval.audio_tag.AudioTaggingMetrics.evaluate
takes as a parameter tag lists,
(use dcase_util.containers.MetaDataContainer
to read them from a file), and probability lists (use dcase_util.containers.ProbabilityContainer
to read them from a file).
Usage example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | import sed_eval
import dcase_util
reference_tag_list = dcase_util.containers.MetaDataContainer([
{
'filename': 'test1.wav',
'tags': 'cat,dog'
},
{
'filename': 'test2.wav',
'tags': 'dog'
},
{
'filename': 'test3.wav',
'tags': 'bird,cat'
},
{
'filename': 'test4.wav',
'tags': 'cat'
},
{
'filename': 'test5.wav',
'tags': 'bird,speech'
},
{
'filename': 'test6.wav',
'tags': 'dog,speech'
},
{
'filename': 'test7.wav',
'tags': 'speech'
},
])
estimated_tag_probabilities = dcase_util.containers.ProbabilityContainer([
{
'filename': 'test1.wav',
'label': 'bird',
'probability': 0.2
},
{
'filename': 'test1.wav',
'label': 'cat',
'probability': 0.99
},
{
'filename': 'test1.wav',
'label': 'dog',
'probability': 0.88
},
{
'filename': 'test1.wav',
'label': 'speech',
'probability': 0.01
},
{
'filename': 'test2.wav',
'label': 'bird',
'probability': 0.1
},
{
'filename': 'test2.wav',
'label': 'cat',
'probability': 0.3
},
{
'filename': 'test2.wav',
'label': 'dog',
'probability': 0.8
},
{
'filename': 'test2.wav',
'label': 'speech',
'probability': 0.1
},
{
'filename': 'test3.wav',
'label': 'bird',
'probability': 0.7
},
{
'filename': 'test3.wav',
'label': 'cat',
'probability': 0.6
},
{
'filename': 'test3.wav',
'label': 'dog',
'probability': 0.4
},
{
'filename': 'test3.wav',
'label': 'speech',
'probability': 0.3
},
{
'filename': 'test4.wav',
'label': 'bird',
'probability': 0.323
},
{
'filename': 'test4.wav',
'label': 'cat',
'probability': 0.6
},
{
'filename': 'test4.wav',
'label': 'dog',
'probability': 0.56
},
{
'filename': 'test4.wav',
'label': 'speech',
'probability': 0.4
},
{
'filename': 'test5.wav',
'label': 'bird',
'probability': 0.8
},
{
'filename': 'test5.wav',
'label': 'cat',
'probability': 0.7
},
{
'filename': 'test5.wav',
'label': 'dog',
'probability': 0.45
},
{
'filename': 'test5.wav',
'label': 'speech',
'probability': 0.43
},
{
'filename': 'test6.wav',
'label': 'bird',
'probability': 0.9
},
{
'filename': 'test6.wav',
'label': 'cat',
'probability': 0.53
},
{
'filename': 'test6.wav',
'label': 'dog',
'probability': 0.83
},
{
'filename': 'test6.wav',
'label': 'speech',
'probability': 0.95
},
{
'filename': 'test7.wav',
'label': 'bird',
'probability': 0.2
},
{
'filename': 'test7.wav',
'label': 'cat',
'probability': 0.2
},
{
'filename': 'test7.wav',
'label': 'dog',
'probability': 0.89
},
{
'filename': 'test7.wav',
'label': 'speech',
'probability': 0.45
},
])
estimated_tag_list = dcase_util.containers.MetaDataContainer()
for file in estimated_tag_probabilities.unique_files:
k = estimated_tag_probabilities.filter(filename=file)
tags = []
for item in k:
if item.probability > 0.5:
tags.append(item.label)
estimated_tag_list.append(
{
'filename': file,
'tags': tags
}
)
tag_evaluator = sed_eval.audio_tag.AudioTaggingMetrics(
tags=reference_tag_list.unique_tags
)
tag_evaluator.evaluate(
reference_tag_list=reference_tag_list,
estimated_tag_list=estimated_tag_list,
estimated_tag_probabilities=estimated_tag_probabilities
)
print(tag_evaluator)
|
AudioTaggingMetrics ([tags]) |
|
AudioTaggingMetrics.evaluate (reference_tag_list) |
Evaluate estimated against reference |
AudioTaggingMetrics.results () |
All metrics |
AudioTaggingMetrics.results_overall_metrics () |
Overall metrics |
AudioTaggingMetrics.results_class_wise_metrics () |
Class-wise metrics |
AudioTaggingMetrics.results_class_wise_average_metrics () |
Class-wise averaged metrics |
AudioTaggingMetrics.result_report_parameters () |
Report metric parameters |
AudioTaggingMetrics.result_report_class_wise () |
Report class-wise results |
AudioTaggingMetrics.result_report_class_wise_average () |
Report class-wise averages |
AudioTaggingMetrics.reset () |
Reset internal state |