How to use phonemizer - 10 common examples

To help you get started, we’ve selected a few phonemizer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bootphon / phonemizer / test / test_festival.py View on Github external
def test_im():
    sep = separator.Separator(word=' ', syllable='', phone='')
    assert _test("I'm looking for an image", sep) \
        == ['aym luhkaxng faor axn ihmaxjh']
    assert _test("Im looking for an image", sep) \
        == ['ihm luhkaxng faor axn ihmaxjh']
github bootphon / phonemizer / test / test_espeak.py View on Github external
def test_arabic():
    backend = EspeakBackend('ar')
    text = u'السلام عليكم'
    sep = separator.Separator()

    # Arabic seems to have changed starting at espeak-ng-1.49.3
    if tuple(EspeakBackend.version().split('.')) >= ('1', '49', '3'):
        expected = [u'ʔassalaːm ʕliːkm ']
    else:
        expected = [u'ʔassalaam ʕaliijkum ']
    out = backend._phonemize_aux(text, sep, False)
    assert out == expected
github bootphon / phonemizer / test / test_main.py View on Github external
def test_readme():
    _test(u'hello world', u'həloʊ wɜːld ')
    _test(u'hello world', u'həloʊ wɜːld ', '--verbose')
    _test(u'hello world', u'həloʊ wɜːld ', '--quiet')

    if backend.EspeakBackend.is_espeak_ng():
        _test(u'hello world', u'h@loU w3:ld ', '--sampa')
    else:  # sampa only supported by espeak-ng
        with pytest.raises(SystemExit):
            _test(u'hello world', u'h@loU w3:ld ', '--sampa')

    _test(u'hello world', u'hhaxlow werld', '-b festival --strip')
    _test(u'hello world', u'həloʊ wɜːld ', '-l en-us')
    _test(u'bonjour le monde', u'bɔ̃ʒuʁ lə- mɔ̃d ', '-l fr-fr')
    _test(u'bonjour le monde', u'b ɔ̃ ʒ u ʁ ;eword l ə- ;eword m ɔ̃ d ;eword ',
          '-l fr-fr -p " " -w ";eword "')
github bootphon / phonemizer / test / test_espeak.py View on Github external
    not EspeakBackend.is_espeak_ng(),
    reason='Arabic is only supported by espeak-ng')
def test_arabic():
    backend = EspeakBackend('ar')
    text = u'السلام عليكم'
    sep = separator.Separator()

    # Arabic seems to have changed starting at espeak-ng-1.49.3
    if tuple(EspeakBackend.version().split('.')) >= ('1', '49', '3'):
        expected = [u'ʔassalaːm ʕliːkm ']
    else:
        expected = [u'ʔassalaam ʕaliijkum ']
    out = backend._phonemize_aux(text, sep, False)
    assert out == expected
github bootphon / phonemizer / test / test_festival.py View on Github external
    '2.1' in FestivalBackend.version(),
    reason='festival-2.1 gives different results than further versions '
    'for syllable boundaries')
def test_hello():
    assert _test('hello world') == ['hh-ax|l-ow w-er-l-d']
    assert _test('hello\nworld') == ['hh-ax|l-ow', 'w-er-l-d']
    assert _test('hello\nworld\n') == ['hh-ax|l-ow', 'w-er-l-d']
github bootphon / phonemizer / test / test_main.py View on Github external
    '2.1' in backend.FestivalBackend.version(),
    reason='festival-2.1 gives different results than further versions '
    'for syllable boundaries')
def test_readme_festival_syll():
    _test(u'hello world',
          u'hh ax ;esyll l ow ;esyll ;eword w er l d ;esyll ;eword ',
          u"-p ' ' -s ';esyll ' -w ';eword ' -b festival -l en-us")
github bootphon / phonemizer / test / test_festival.py View on Github external
def _test(text, separator=separator.Separator(
        word=' ', syllable='|', phone='-')):
    backend = FestivalBackend('en-us')
    return backend._phonemize_aux(text, separator, True)
github bootphon / phonemizer / test / test_espeak.py View on Github external
def test_arabic():
    backend = EspeakBackend('ar')
    text = u'السلام عليكم'
    sep = separator.Separator()

    # Arabic seems to have changed starting at espeak-ng-1.49.3
    if tuple(EspeakBackend.version().split('.')) >= ('1', '49', '3'):
        expected = [u'ʔassalaːm ʕliːkm ']
    else:
        expected = [u'ʔassalaam ʕaliijkum ']
    out = backend._phonemize_aux(text, sep, False)
    assert out == expected
github bootphon / phonemizer / test / test_main.py View on Github external
def _test(input, expected_output, args=''):
    with tempfile.NamedTemporaryFile('w') as finput:
        # python2 needs additional utf8 encoding
        if sys.version_info[0] == 2:
            input = input.encode('utf8')
        finput.write(input)
        finput.seek(0)

        with tempfile.NamedTemporaryFile('w+') as foutput:
            opts = '{} -o {} {}'.format(finput.name, foutput.name, args)
            sys.argv = ['foo'] + shlex.split(opts)
            main.main()

            output = foutput.read()
            # python2 needs additional utf8 decoding
            if sys.version_info[0] == 2:
                output = output.decode('utf8')
            if expected_output == '':
                assert output == ''
            else:
                assert output == expected_output + '\n'
github bootphon / phonemizer / test / test_espeak.py View on Github external
def test_french():
    backend = EspeakBackend('fr-fr')
    text = u'bonjour le monde'
    sep = separator.Separator(word=';eword ', syllable=None, phone=' ')
    expected = [u'b ɔ̃ ʒ u ʁ ;eword l ə- ;eword m ɔ̃ d ;eword ']
    out = backend._phonemize_aux(text, sep, False)
    assert out == expected