How to use the phonemizer.backend.SegmentsBackend function in phonemizer

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_segments.py View on Github external
def test_separator_5():
    backend = SegmentsBackend('cree')
    text = 'achi acho'

    sep = separator.Separator(phone=' ', word='_')
    assert backend.phonemize(text, separator=sep) == u'ʌ tʃ ɪ _ʌ tʃ ʊ _'
    assert backend.phonemize(text, separator=sep, strip=True) \
        == u'ʌ tʃ ɪ_ʌ tʃ ʊ'
github bootphon / phonemizer / test / test_segments.py View on Github external
def test_bad_morpheme():
    backend = SegmentsBackend('cree')
    with pytest.raises(ValueError):
        backend.phonemize('A')
github bootphon / phonemizer / test / test_segments.py View on Github external
def test_separator_3():
    backend = SegmentsBackend('cree')
    text = 'achi acho'

    sep = separator.Separator(word=' ', syllable=None, phone='_')
    assert backend.phonemize(text, separator=sep) == u'ʌ_tʃ_ɪ_ ʌ_tʃ_ʊ_ '
    assert backend.phonemize(text, separator=sep, strip=True) \
        == u'ʌ_tʃ_ɪ ʌ_tʃ_ʊ'
github bootphon / phonemizer / test / test_segments.py View on Github external
def test_separator_2():
    backend = SegmentsBackend('cree')
    text = 'achi acho'

    sep = separator.Separator(word='_', phone=' ')
    assert backend.phonemize(text, separator=sep) == u'ʌ tʃ ɪ _ʌ tʃ ʊ _'
    assert backend.phonemize(text, separator=sep, strip=True) \
        == u'ʌ tʃ ɪ_ʌ tʃ ʊ'
github bootphon / phonemizer / test / test_segments.py View on Github external
def test_separator_4():
    backend = SegmentsBackend('cree')
    text = 'achi acho'

    # TODO bug when sep.phone == ' ' with no sep.word
    sep = separator.Separator(phone=' ', word='')
    assert backend.phonemize(text, separator=sep) == u'ʌ tʃ ɪ ʌ tʃ ʊ '
    assert backend.phonemize(text, separator=sep, strip=True) \
        == u'ʌ tʃ ɪʌ tʃ ʊ'
github bootphon / phonemizer / test / test_segments.py View on Github external
def test_multiline():
    backend = SegmentsBackend('cree')
    assert backend.phonemize('a') == u'ʌ '
    assert backend.phonemize('aa') == u'ʌʌ '
    assert backend.phonemize('a\n') == u'ʌ '
    assert backend.phonemize('a\na') == u'ʌ \nʌ '
    assert backend.phonemize('a\na\n') == u'ʌ \nʌ '
github bootphon / phonemizer / test / test_segments.py View on Github external
def test_separator():
    backend = SegmentsBackend('cree')
    text = 'achi acho'

    sep = separator.default_separator
    assert backend.phonemize(text, separator=sep) == u'ʌtʃɪ ʌtʃʊ '
    assert backend.phonemize(text, separator=sep, strip=True) == u'ʌtʃɪ ʌtʃʊ'
github bootphon / phonemizer / phonemizer / version.py View on Github external
unavailable = []

    if EspeakBackend.is_available():
        available.append(
            'espeak-' + ('ng-' if EspeakBackend.is_espeak_ng() else '')
            + EspeakBackend.version())
    else:  # pragma: nocover
        unavailable.append('espeak')

    if FestivalBackend.is_available():
        available.append('festival-' + FestivalBackend.version())
    else:  # pragma: nocover
        unavailable.append('festival')

    if SegmentsBackend.is_available():
        available.append('segments-' + SegmentsBackend.version())
    else:  # pragma: nocover
        unavailable.append('segments')

    # resumes the backends status in the final version string
    if available:
        version += '\navailable backends: ' + ', '.join(available)
    if unavailable:  # pragma: nocover
        version += '\nuninstalled backends: ' + ', '.join(unavailable)

    return version
github bootphon / phonemizer / phonemizer / version.py View on Github external
available = []
    unavailable = []

    if EspeakBackend.is_available():
        available.append(
            'espeak-' + ('ng-' if EspeakBackend.is_espeak_ng() else '')
            + EspeakBackend.version())
    else:  # pragma: nocover
        unavailable.append('espeak')

    if FestivalBackend.is_available():
        available.append('festival-' + FestivalBackend.version())
    else:  # pragma: nocover
        unavailable.append('festival')

    if SegmentsBackend.is_available():
        available.append('segments-' + SegmentsBackend.version())
    else:  # pragma: nocover
        unavailable.append('segments')

    # resumes the backends status in the final version string
    if available:
        version += '\navailable backends: ' + ', '.join(available)
    if unavailable:  # pragma: nocover
        version += '\nuninstalled backends: ' + ', '.join(unavailable)

    return version