Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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ʃ ʊ'
def test_bad_morpheme():
backend = SegmentsBackend('cree')
with pytest.raises(ValueError):
backend.phonemize('A')
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ʃ_ʊ'
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ʃ ʊ'
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ʃ ʊ'
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ʌ '
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ʃʊ'
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
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