Transcribe phonetics.
183793
def to_phonetics(self):
        """"""
        tr = Transcriber()
        self.transcribed_phonetics = [tr.transcribe(line) for line in self.text]
115853
def to_phonetics(self):
        
        if len(self.long_lines) == 0:
            logger.error("No text was imported")
            self.syllabified_text = []
        else:
            transcriber = Transcriber(DIPHTHONGS_IPA, DIPHTHONGS_IPA_class, IPA_class, old_norse_rules)
            transcribed_text = []
            phonological_features_text = []
            for i, long_line in enumerate(self.long_lines):
                transcribed_text.append([])
                phonological_features_text.append([])
                for short_line in long_line:
                    assert isinstance(short_line, ShortLine) or isinstance(short_line, LongLine)
                    short_line.to_phonetics(transcriber)
                    transcribed_text[i].append(short_line.transcribed)
                    phonological_features_text[i].append(short_line.phonological_features_text)

            self.transcribed_text = transcribed_text
            self.phonological_features_text = phonological_features_text
720954
def apply_T1(word):
    ''''''
    T1 = ' T1'
    WORD = _split_consonants_and_vowels(word)
    CONTINUE_VV = 0
    CONTINUE_VVV = 0

    for i, v in enumerate(WORD):

        if i == 0 and is_consonant(v[0][0]):
            continue

        elif is_consonant(v[0]) and i + 1 != len(WORD):
            WORD[i] = v[:-1] + '.' + v[-1]

        elif is_vowel(v[0]):

            if len(v) > 2:
                CONTINUE_VVV += 1

            elif len(v) > 1:
                CONTINUE_VV += 1

    word = ''.join(WORD)

    return word, CONTINUE_VV, CONTINUE_VVV, T1
1016282
function consonantStringBackwards(tokens, i, orig_i) {
	var out = [];
	var t = '';
	while (i >= orig_i && tokens[i] != null) {
		t = tokens[i--];
		if (t == '+' || t == '^') continue;
		if (consonant(t) == null) break;
		out.unshift(t);
	}
	return out.join("+");
}
1326335
def orthographic_syllabify(self, word):
        """"""
        p_vectors = [self.get_phonetic_feature_vector(c, self.lang) for c in word]

        syllables = []

        for i in range(len(word)):
            v = p_vectors[i]

            syllables.append(word[i])

            if i + 1 < len(word) and (not self.is_valid(p_vectors[i + 1]) or self.is_misc(p_vectors[i + 1])):
                syllables.append(u' ')

            elif not self.is_valid(v) or self.is_misc(v):
                syllables.append(u' ')

            elif self.is_vowel(v):

                anu_nonplos = (i + 2 < len(word) and
                               self.is_anusvaar(p_vectors[i + 1]) and
                               not self.is_plosive(p_vectors[i + 2])
                               )

                anu_eow = (i + 2 == len(word) and
                           self.is_anusvaar(p_vectors[i + 1]))

                if not (anu_nonplos or anu_eow):
                    syllables.append(u' ')

            elif i + 1 < len(word) and (self.is_consonant(v) or self.is_nukta(v)):
                if self.is_consonant(p_vectors[i + 1]):
                    syllables.append(u' ')
                elif self.is_vowel(p_vectors[i + 1]) and not self.is_dependent_vowel(p_vectors[i + 1]):
                    syllables.append(u' ')
                elif self.is_anusvaar(p_vectors[i + 1]):
                    anu_nonplos = (i + 2 < len(word) and not self.is_plosive(p_vectors[i + 2]))

                    anu_eow = i + 2 == len(word)

                    if not (anu_nonplos or anu_eow):
                        syllables.append(u' ')

        return u''.join(syllables).strip().split(u' ')
1122406
def map_hmms(input_model, mapping):
    

    output_model = copy.copy(input_model)

    o_hmms = []
    for i_hmm in input_model['hmms']:
        i_hmm_name = i_hmm['name']
        o_hmm_names = mapping.get(i_hmm_name, [i_hmm_name])

        for o_hmm_name in o_hmm_names:
            o_hmm = copy.copy(i_hmm)
            o_hmm['name'] = o_hmm_name

            o_hmms.append(o_hmm)

    output_model['hmms'] = o_hmms

    return output_model
960827
def _transform(comps, trans):
    
    logging.debug("== In _transform(%s, %s) ==", comps, trans)
    components = list(comps)

    action, parameter = _get_action(trans)
    if action == _Action.ADD_MARK and \
            components[2] == "" and \
            mark.strip(components[1]).lower() in ['oe', 'oa'] and trans == "o^":
        action, parameter = _Action.ADD_CHAR, trans[0]

    if action == _Action.ADD_ACCENT:
        logging.debug("add_accent(%s, %s)", components, parameter)
        components = accent.add_accent(components, parameter)
    elif action == _Action.ADD_MARK and mark.is_valid_mark(components, trans):
        logging.debug("add_mark(%s, %s)", components, parameter)
        components = mark.add_mark(components, parameter)

        # Handle uơ in "huơ", "thuở", "quở"
        # If the current word has no last consonant and the first consonant
        # is one of "h", "th" and the vowel is "ươ" then change the vowel into
        # "uơ", keeping case and accent. If an alphabet character is then added
        # into the word then change back to "ươ".
        #
        # NOTE: In the dictionary, these are the only words having this strange
        # vowel so we don't need to worry about other cases.
        if accent.remove_accent_string(components[1]).lower() == "ươ" and \
                not components[2] and components[0].lower() in ["", "h", "th", "kh"]:
            # Backup accents
            ac = accent.get_accent_string(components[1])
            components[1] = ("u", "U")[components[1][0].isupper()] + components[1][1]
            components = accent.add_accent(components, ac)

    elif action == _Action.ADD_CHAR:
        if trans[0] == "<":
            if not components[2]:
                # Only allow ư, ơ or ươ sitting alone in the middle part
                # and ['g', 'i', '']. If we want to type giowf = 'giờ', separate()
                # will create ['g', 'i', '']. Therefore we have to allow
                # components[1] == 'i'.
                if (components[0].lower(), components[1].lower()) == ('g', 'i'):
                    components[0] += components[1]
                    components[1] = ''
                if not components[1] or \
                        (components[1].lower(), trans[1].lower()) == ('ư', 'ơ'):
                    components[1] += trans[1]
        else:
            components = utils.append_comps(components, parameter)
            if parameter.isalpha() and \
                    accent.remove_accent_string(components[1]).lower().startswith("uơ"):
                ac = accent.get_accent_string(components[1])
                components[1] = ('ư',  'Ư')[components[1][0].isupper()] + \
                    ('ơ', 'Ơ')[components[1][1].isupper()] + components[1][2:]
                components = accent.add_accent(components, ac)
    elif action == _Action.UNDO:
        components = _reverse(components, trans[1:])

    if action == _Action.ADD_MARK or (action == _Action.ADD_CHAR and parameter.isalpha()):
        # If there is any accent, remove and reapply it
        # because it is likely to be misplaced in previous transformations
        ac = accent.get_accent_string(components[1])

        if ac != accent.Accent.NONE:
            components = accent.add_accent(components, Accent.NONE)
            components = accent.add_accent(components, ac)

    logging.debug("After transform: %s", components)
    return components
585858
def _syllabify(word, T4=True):
    ''''''
    word = replace_umlauts(word)
    word, rules = apply_T1(word)

    if re.search(r'[^ieAyOauo]*([ieAyOauo]{2})[^ieAyOauo]*', word):
        word, T2 = apply_T2(word)
        word, T8 = apply_T8(word)
        word, T9 = apply_T9(word)
        word, T4 = apply_T4(word) if T4 else (word, '')
        rules += T2 + T8 + T9 + T4

    if re.search(r'[ieAyOauo]{3}', word):
        word, T6 = apply_T6(word)
        word, T5 = apply_T5(word)
        word, T7 = apply_T7(word)
        word, T2 = apply_T2(word)
        rules += T5 + T6 + T7 + T2

    word = replace_umlauts(word, put_back=True)
    rules = rules or ' T0'  # T0 means no rules have applied

    return word, rules
78354
def _convert_consonant(sign):
        
        for key in TITTLES:
            sign = sign.replace(key, TITTLES[key])
        return sign
1319463
def sounds_like(self, word1, word2):
        """"""
        return self.phonetics(word1) == self.phonetics(word2)
244847
def _syllabify(word):
    ''''''
    word = replace_umlauts(word)
    word, CONTINUE_VV, CONTINUE_VVV, applied_rules = apply_T1(word)

    if CONTINUE_VV:
        word, T2 = apply_T2(word)
        word, T4 = apply_T4(word)
        applied_rules += T2 + T4

    if CONTINUE_VVV:
        word, T5 = apply_T5(word)
        word, T6 = apply_T6(word)
        word, T7 = apply_T7(word)
        applied_rules += T5 + T6 + T7

    word = replace_umlauts(word, put_back=True)

    return word, applied_rules
1323759
def multicharacters(input)
      output = input.gsub(/\([Cc]\)/, "©")
      output = output.gsub(/\([Pp]\)/, "℗")
      output = output.gsub(/\([Rr]\)/, "®")
      output = output.gsub(/\((SM|sm|Sm)\)/, "℠")
      output = output.gsub(/\((TM|tm|Tm)\)/, "™")
      output = output.gsub(/\+-/, "±")
      output = output.gsub(/-\+/, "∓")
      output = output.gsub(/N[oO]\.?\s*(\d+)/, '№\1')
      output = output.gsub(/°C/, '℃')
      output = output.gsub(/°F/, '℉')
    end
1061382
def phonemes(self,set=None):
        """"""
        for layer in self.select(PhonologyLayer):
            for p in layer.select(Phoneme, set):
                yield p
910031
def transcribe(decoder, audio_file, libdir=None):
    
    decoder = get_decoder()

    decoder.start_utt()
    stream = open(audio_file, 'rb')
    while True:
        buf = stream.read(1024)
        if buf:
            decoder.process_raw(buf, False, False)
        else:
            break
    decoder.end_utt()
    return evaluate_results(decoder)
392506
def _numbered_vowel_to_accented(vowel, tone):
    """"""
    if isinstance(tone, int):
        tone = str(tone)
    return _PINYIN_TONES[vowel + tone]
947391
function sro2syllabics (sro, options) {
    options = options || {}
    let hyphens = options.hyphens || DEFAULT_SRO2SYLLABICS_OPTIONS.hyphens
    // Instead of using sro2syllabicsLookup directly, create a customizable
    // lookup here that fallsback to sro2syllabicsLookup.
    let lookup = Object.create(sro2syllabicsLookup)
    // The customization is what the hyphen should be converted to:
    lookup['-'] = hyphens

    let transliteration = nfc(sro).replace(wordPattern, transliterateWord)
    return transliteration.replace(fullStopPattern, function (_, syllabic) {
      // The pattern may yank the last syllabic before the full stop,
      // so add it back here:
      return (syllabic || '') + '\u166E' // ᙮ U+166E CANADIAN SYLLABICS FULL STOP
    })

    function transliterateWord (_match, preamble, word) {
      // The pattern matches zero or more non-word characters before the word
      // (preamble), so glue that before the word.
      return (preamble || '') + transcodeSROWordToSyllabics(word)
    }

    function transcodeSROWordToSyllabics (sroWord) {
      let toTranscribe = translateAltForms(sroWord.toLowerCase())

      let parts = []
      let match = toTranscribe.match(sroPattern)

      while (match) {
        let syllable = match[0]
        let onset = match[1]
        let vowel = match[2]
        let nextSyllablePos

        if (onset !== undefined) {
          // When the onset matched, apply sandhi for Cw?-V → Cw?V
          syllable = onset + vowel
          // Special case for sandhi hw?-V cases: Just transcribe
          // the 'h'/ᐦ part first, then run pretend that this
          // syllable is just the (optional w and) vowel.
          if (onset[0] === 'h') {
            parts.push('ᐦ');
            syllable = syllable.substr(1);
          }
        }
        nextSyllablePos = match[0].length

        let syllabic = lookup[syllable]
        parts.push(syllabic)
        toTranscribe = toTranscribe.slice(nextSyllablePos)

        match = toTranscribe.match(sroPattern)
      }

      if (endsWithHK(parts)) {
        // Replace last two charcters with 'hk' syllabic
        parts = parts.slice(0, parts.length - 2).concat('ᕽ')
      }

      return parts.join('')
    }
  }
615629
def compose_from_transcript(files, search, searchtype):
    """"""

    final_segments = []

    if searchtype in ['re', 'word', 'franken', 'fragment']:
        if searchtype == 're':
            searchtype = 'sentence'

        segments = audiogrep.search(search, files, mode=searchtype, regex=True)
        for seg in segments:
            seg['file'] = seg['file'].replace('.transcription.txt', '')
            seg['line'] = seg['words']
            final_segments.append(seg)

    elif searchtype in ['hyper', 'pos']:
        for s in audiogrep.convert_timestamps(files):
            for w in s['words']:
                if search_line(w[0], search, searchtype):
                    seg = {
                        'file': s['file'].replace('.transcription.txt',''),
                        'line': w[0],
                        'start': float(w[1]),
                        'end': float(w[2])
                    }
                    final_segments.append(seg)

    return final_segments