def test_tedlium(self):
        transitions = durmodel_utils.read_transitions(os.path.dirname(__file__) + "/test_data/tedlium/transitions.txt")
        nonsilence_phonemes = set()
        for l in open(os.path.dirname(__file__) + "/test_data/tedlium/nonsilence.txt"):
            nonsilence_phonemes.add(l.partition("_")[0])

        word_list = []
        for l in codecs.open(os.path.dirname(__file__) + "/test_data/tedlium/words.txt", encoding="UTF-8"):
            word_list.append(l.split()[0])

        stress_dict = durmodel_utils.load_stress_dict(os.path.dirname(__file__) + "/data/en/cmudict.0.7a.lc")

        # about
        word_id = 437
        frames = [int(s) for s in "1794_2062_2061_2061_2300_5602_5601_5650_5662_5661_5661_4808_4807_4807_4807_4807_4832_4831_4831_4831_4860_4859_4859_22924_22923_22923_23018_23118".split("_")]

        features_and_dur_seq = durmodel_utils.make_local(0, word_id, frames, transitions, word_list, nonsilence_phonemes, language="ENGLISH", stress_dict=stress_dict)
        print features_and_dur_seq
        self.assert_(('syllable', 1) in features_and_dur_seq[0][0])
        self.assert_(('AH', 1) in features_and_dur_seq[0][0])
        self.assert_(('vowel', 1) in features_and_dur_seq[0][0])
        self.assert_(5, features_and_dur_seq[0][1])

        self.assert_(('stress1', 1) in features_and_dur_seq[2][0])

        self.assert_(('syllable', 2) in features_and_dur_seq[1][0])

        self.assert_(('stop', 1) in features_and_dur_seq[-1][0])
        self.assert_(5, features_and_dur_seq[0][-1])
Exemplo n.º 2
0
    def test_tedlium(self):
        transitions = durmodel_utils.read_transitions(
            os.path.dirname(__file__) + "/test_data/tedlium/transitions.txt")
        nonsilence_phonemes = set()
        for l in open(
                os.path.dirname(__file__) +
                "/test_data/tedlium/nonsilence.txt"):
            nonsilence_phonemes.add(l.partition("_")[0])

        word_list = []
        for l in codecs.open(os.path.dirname(__file__) +
                             "/test_data/tedlium/words.txt",
                             encoding="UTF-8"):
            word_list.append(l.split()[0])

        stress_dict = durmodel_utils.load_stress_dict(
            os.path.dirname(__file__) + "/data/en/cmudict.0.7a.lc")

        # about
        word_id = 437
        frames = [
            int(s) for s in
            "1794_2062_2061_2061_2300_5602_5601_5650_5662_5661_5661_4808_4807_4807_4807_4807_4832_4831_4831_4831_4860_4859_4859_22924_22923_22923_23018_23118"
            .split("_")
        ]

        features_and_dur_seq = durmodel_utils.make_local(
            0,
            word_id,
            frames,
            transitions,
            word_list,
            nonsilence_phonemes,
            language="ENGLISH",
            stress_dict=stress_dict)
        print features_and_dur_seq
        self.assert_(('syllable', 1) in features_and_dur_seq[0][0])
        self.assert_(('AH', 1) in features_and_dur_seq[0][0])
        self.assert_(('vowel', 1) in features_and_dur_seq[0][0])
        self.assert_(5, features_and_dur_seq[0][1])

        self.assert_(('stress1', 1) in features_and_dur_seq[2][0])

        self.assert_(('syllable', 2) in features_and_dur_seq[1][0])

        self.assert_(('stop', 1) in features_and_dur_seq[-1][0])
        self.assert_(5, features_and_dur_seq[0][-1])
Exemplo n.º 3
0
    parser.add_argument('--language', action='store', dest='language', help="Language of the data", default="ESTONIAN")
    parser.add_argument('--stress', action='store', dest='stress_dict_filename', help="Stress dictionary")
    parser.add_argument('--left-context', action='store', dest='left_context', help="Left context length", default=2, type=int)
    parser.add_argument('--right-context', action='store', dest='right_context', help="Left context length", default=2, type=int)
    parser.add_argument('--no-duration-feature', action='store_true', dest='no_use_duration', help="Don't Use duration features")

    parser.add_argument('transitions', metavar='transitions.txt', help='Transition model, produced with show-transitions')
    parser.add_argument('nonsilence', metavar='nonsilence.txt', help='Nonsilence phonemes')
    parser.add_argument('words', metavar='words.txt', help='words.txt file')
    parser.add_argument('train_lattice', metavar='ali-lat.txt', help='Aligned phone lattice')

    args = parser.parse_args()
    durmodel_utils.LEFT_CONTEXT = args.left_context
    durmodel_utils.RIGHT_CONTEXT = args.right_context

    transitions = read_transitions(args.transitions)

    print >> sys.stderr, "DEBUG: transitions[%d] = %s" % (len(transitions) -2,  transitions[-2])
    print >> sys.stderr, "DEBUG: transitions[%d] = %s" % (len(transitions) -1,  transitions[-1])

    print >> sys.stderr, "Reading non-silence phonemes"
    nonsilence_phonemes = set()
    for l in open(args.nonsilence):
        nonsilence_phonemes.add(l.partition("_")[0])

    print >> sys.stderr, "Reading words.txt"
    word_list = []
    for l in codecs.open(args.words, encoding="UTF-8"):
        word_list.append(l.split()[0])

    stress_dict = None
Exemplo n.º 4
0
    parser.add_argument(
        'transitions',
        metavar='transitions.txt',
        help='Transition model, produced with show-transitions')
    parser.add_argument('nonsilence',
                        metavar='nonsilence.txt',
                        help='Nonsilence phonemes')
    parser.add_argument('words', metavar='words.txt', help='words.txt file')
    parser.add_argument('model', metavar='durmodel.pkl', help='duration model')

    args = parser.parse_args()
    durmodel_utils.LEFT_CONTEXT = args.left_context
    durmodel_utils.RIGHT_CONTEXT = args.right_context

    transitions = durmodel_utils.read_transitions(args.transitions)

    print >> sys.stderr, "Reading non-silence phonemes"
    nonsilence_phonemes = set()
    for l in open(args.nonsilence):
        nonsilence_phonemes.add(l.partition("_")[0])

    print >> sys.stderr, "Reading words.txt"
    word_list = []
    for l in codecs.open(args.words, encoding="UTF-8"):
        word_list.append(l.split()[0])

    filler_words = ["<eps>"] + args.fillers.split(",")
    print >> sys.stderr, "Fillers: ", filler_words

    stress_dict = None
    parser.add_argument('--left-context', action='store', dest='left_context', help="Left context length", default=2, type=int)
    parser.add_argument('--right-context', action='store', dest='right_context', help="Left context length", default=2, type=int)
    parser.add_argument('--skip-fillers', action='store_true', dest='skip_fillers', help="Don't calculate posterior probabilities for fillers", default=True)
    parser.add_argument('--utt2spk', action='store', dest='utt2spk', help="Use the mapping in the given file to add speaker ID to each sample")
    parser.add_argument('--speakers', action='store', dest='speakers', help="List of speakers in training data, in sorted order")

    parser.add_argument('transitions', metavar='transitions.txt', help='Transition model, produced with show-transitions')
    parser.add_argument('nonsilence', metavar='nonsilence.txt', help='Nonsilence phonemes')
    parser.add_argument('words', metavar='words.txt', help='words.txt file')
    parser.add_argument('model', metavar='durmodel.pkl', help='duration model')

    args = parser.parse_args()
    durmodel_utils.LEFT_CONTEXT = args.left_context
    durmodel_utils.RIGHT_CONTEXT = args.right_context

    transitions = durmodel_utils.read_transitions(args.transitions)

    print >> sys.stderr, "Reading non-silence phonemes"
    nonsilence_phonemes = set()
    for l in open(args.nonsilence):
        nonsilence_phonemes.add(l.partition("_")[0])

    print >> sys.stderr, "Reading words.txt"
    word_list = []
    for l in codecs.open(args.words, encoding="UTF-8"):
        word_list.append(l.split()[0])

    filler_words = ["<eps>"] + args.fillers.split(",")
    print >> sys.stderr, "Fillers: ", filler_words

    stress_dict = None
Exemplo n.º 6
0
        'transitions',
        metavar='transitions.txt',
        help='Transition model, produced with show-transitions')
    parser.add_argument('nonsilence',
                        metavar='nonsilence.txt',
                        help='Nonsilence phonemes')
    parser.add_argument('words', metavar='words.txt', help='words.txt file')
    parser.add_argument('train_lattice',
                        metavar='ali-lat.txt',
                        help='Aligned phone lattice')

    args = parser.parse_args()
    durmodel_utils.LEFT_CONTEXT = args.left_context
    durmodel_utils.RIGHT_CONTEXT = args.right_context

    transitions = read_transitions(args.transitions)

    print >> sys.stderr, "DEBUG: transitions[%d] = %s" % (len(transitions) - 2,
                                                          transitions[-2])
    print >> sys.stderr, "DEBUG: transitions[%d] = %s" % (len(transitions) - 1,
                                                          transitions[-1])

    print >> sys.stderr, "Reading non-silence phonemes"
    nonsilence_phonemes = set()
    for l in open(args.nonsilence):
        nonsilence_phonemes.add(l.partition("_")[0])

    print >> sys.stderr, "Reading words.txt"
    word_list = []
    for l in codecs.open(args.words, encoding="UTF-8"):
        word_list.append(l.split()[0])