Example #1
0
    def test_read_label_list_de(self):
        path = os.path.join(os.path.dirname(__file__), 'audacity_labels_de.txt')
        ll = audacity.read_label_list(path)

        assert ll == annotations.LabelList(labels=[
            annotations.Label('music', 43352.824046, 43525.837661),
            annotations.Label('speech_male', 43512.446969, 43531.343483),
        ])
Example #2
0
    def test_read_label_list_with_empty_value(self):
        path = os.path.join(os.path.dirname(__file__), 'audacity_labels_empty_value.txt')
        ll = audacity.read_label_list(path)

        assert ll == annotations.LabelList(labels=[
            annotations.Label('music', 1, 4),
            annotations.Label('', 4, 7),
            annotations.Label('speech_male', 7, 9),
        ])
Example #3
0
    def test_read_label_list_de(self):
        path = os.path.join(os.path.dirname(__file__),
                            'audacity_labels_de.txt')
        ll = read_label_list(path)

        assert len(ll) == 2

        assert ll[0].start == 43352.824046
        assert ll[0].end == 43525.837661
        assert ll[0].value == 'music'

        assert ll[1].start == 43512.446969
        assert ll[1].end == 43531.343483
        assert ll[1].value == 'speech_male'
Example #4
0
def classification_ref_corpus_and_hyp_labels():
    """
    Sample corpus and hypothesis label-lists from a classification task.
    """
    ref_path = os.path.join(os.path.dirname(resources.__file__), 'classification', 'ref_corpus')
    hyp_path = os.path.join(os.path.dirname(resources.__file__), 'classification', 'hyp')
    corpus = audiomate.Corpus.load(ref_path)
    hyps = {}

    for utt_id in corpus.utterances.keys():
        ll = audacity.read_label_list(os.path.join(hyp_path, '{}.txt'.format(utt_id)))
        hyps[utt_id] = ll

    return corpus, hyps
Example #5
0
    def read_labels(path, corpus):
        label_reference_file = os.path.join(path, LABEL_FILE)
        label_references = textfile.read_separated_lines(label_reference_file, separator=' ', max_columns=3)

        for record in label_references:
            utt_idx = record[0]
            label_path = os.path.join(path, record[1])
            label_idx = None

            if len(record) > 2:
                label_idx = record[2]

            ll = audacity.read_label_list(label_path)
            ll.idx = label_idx
            ll.apply(extract_meta_from_label_value)

            corpus.utterances[utt_idx].set_label_list(ll)
Example #6
0
    def test_read_label_list_with_empty_value(self):
        path = os.path.join(os.path.dirname(__file__),
                            'audacity_labels_empty_value.txt')
        ll = read_label_list(path)

        assert len(ll) == 3

        assert ll[0].start == 1
        assert ll[0].end == 4
        assert ll[0].value == 'music'

        assert ll[1].start == 4
        assert ll[1].end == 7
        assert ll[1].value == ''

        assert ll[2].start == 7
        assert ll[2].end == 9
        assert ll[2].value == 'speech_male'