def text2phone(text, language):
    '\n    Convert graphemes to phonemes.\n    '
    seperator = phonemizer.separator.Separator(' |', '', '|')
    punctuations = re.findall(PHONEME_PUNCTUATION_PATTERN, text)
    if (version.parse(phonemizer.__version__) < version.parse('2.1')):
        ph = phonemize(text, separator=seperator, strip=False, njobs=1, backend='espeak', language=language)
        ph = ph[:(- 1)].strip()
        if punctuations:
            if (text[(- 1)] == punctuations[(- 1)]):
                for punct in punctuations[:(- 1)]:
                    ph = ph.replace('| |\n', (('|' + punct) + '| |'), 1)
                    ph = (ph + punctuations[(- 1)])
            else:
                for punct in punctuations:
                    ph = ph.replace('| |\n', (('|' + punct) + '| |'), 1)
    elif (version.parse(phonemizer.__version__) >= version.parse('2.1')):
        ph = phonemize(text, separator=seperator, strip=False, njobs=1, backend='espeak', language=language, preserve_punctuation=True)
        if punctuations:
            for punctuation in punctuations:
                ph = ph.replace(f'| |{punctuation} ', f'|{punctuation}| |').replace(f'| |{punctuation}', f'|{punctuation}| |')
            ph = ph[:(- 3)]
    else:
        raise RuntimeError(" [!] Use 'phonemizer' version 2.1 or older.")
    return ph
Convert graphemes to phonemes.
def text2phone(text, language):
    '\n    \n    '
    seperator = phonemizer.separator.Separator(' |', , '|')
    punctuations = re.findall(PHONEME_PUNCTUATION_PATTERN, text)
    if (version.parse(phonemizer.__version__) < version.parse('2.1')):
        ph = phonemize(text, separator=seperator, strip=False, njobs=1, backend='espeak', language=language)
        ph = ph[:(- 1)].strip()
        if punctuations:
            if (text[(- 1)] == punctuations[(- 1)]):
                for punct in punctuations[:(- 1)]:
                    ph = ph.replace('| |\n', (('|' + punct) + '| |'), 1)
                    ph = (ph + punctuations[(- 1)])
            else:
                for punct in punctuations:
                    ph = ph.replace('| |\n', (('|' + punct) + '| |'), 1)
    elif (version.parse(phonemizer.__version__) >= version.parse('2.1')):
        ph = phonemize(text, separator=seperator, strip=False, njobs=1, backend='espeak', language=language, preserve_punctuation=True)
        if punctuations:
            for punctuation in punctuations:
                ph = ph.replace(f'| |{punctuation} ', f'|{punctuation}| |').replace(f'| |{punctuation}', f'|{punctuation}| |')
            ph = ph[:(- 3)]
    else:
        raise RuntimeError(" [!] Use 'phonemizer' version 2.1 or older.")
    return ph