Beispiel #1
0
 def assertAccent(self, word_utf8, expected_accent_utf8):
     syllables = separate_syllaba(word_utf8.decode('utf-8'))
     acc_idx = locate_accent(syllables)
     if acc_idx is not None:
         syllables[acc_idx] = u'[' + syllables[acc_idx] + u']'
     actual_accent_utf8 = (u'-'.join(syllables)).encode('utf-8')
     self.assertEqual(actual_accent_utf8, expected_accent_utf8)
Beispiel #2
0
def analyze_latin_word_phonemes(word_uc, debug_mode=False):
    syllables = separate_syllaba(word_uc)
    acc_idx = locate_accent(syllables)

    if debug_mode:
#    if True:
        syllables_ = [u'[' + syl + u']' if i == acc_idx else syl for i, syl in enumerate(syllables)]
        print '\n>', u'-'.join(syllables_).encode('utf-8')

    phonemes = []

    for i, syl in enumerate(syllables):
        if i == acc_idx:
            pitch = latin_freq_high
        else:
            pitch = latin_freq_low

        # qu [kw]
        syl.replace(u'QU', u'kv')
        syl.replace(u'qu', u'kv')
        # gu [gw]
        syl.replace(u'GU', u'gv')
        syl.replace(u'gu', u'gv')

        # bs [ps], bt [pt]
        if syl[-1] in (u'B', u'b') and i < len(syllables)-1:
            if syllables[i+1][0] in (u's', u'S', u't', u'T'):
                syl[-1] = u'p'

        for c in syl:
            # print acc_idx, i, syl, c, pitch
            phoneme = latin_phoneme_dic.get(c, '~')

            if c in (u'ā', u'ē', u'ī', u'ō', u'ū',
                     u'Ā', u'Ē', u'Ī', u'Ō', u'Ū',
                     u'ȳ', u'Ȳ',
                     u'æ', u'Æ',
                     u'œ', u'Œ',
                     u'x', u'X' ):
                # longer
                duration = latin_time_unit * 2
            # elif c in (u't', u'T'):
            #    duration = latin_time_unit * 1.25
            else:
                # shorter
                duration = latin_time_unit

            phonemes.append("%s {D %d; P %g:0}" % (phoneme, duration, pitch))

    return phonemes