Skip to content

Commit

Permalink
Add test_espeak_voices
Browse files Browse the repository at this point in the history
  • Loading branch information
cclauss committed Nov 5, 2024
1 parent 8ca1b54 commit 21bf4ad
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tests/test_engines.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,16 @@ def test_espeak_voices(driver_name):
print(engine)
assert str(engine) == "espeak", "Expected engine name to be espeak"
voice = engine.getProperty("voice")
if voice: # eSpeak-NG Windows (or perhaps v1.52-dev) returns None
if voice: # eSpeak-NG Windows v1.52-dev returns None
assert (
voice == "English (Great Britain)"
), f"Expected {engine} default voice to be 'English (Great Britain)'"
voices = engine.getProperty("voices")
print(f"{engine} has {len(voices) = } voices.")
# Linux eSpeak-NG (v1.50) has 109 voices, macOS eSpeak-NG (v1.51) has 131 voices.
assert len(voices) in {109, 131}, f"Expected 109 or 131 voices in {engine}"
# Linux eSpeak-NG v1.50 has 109 voices,
# macOS eSpeak-NG v1.51 has 131 voices,
# Windows eSpeak-NG v1.52-dev has 221 voices.
assert len(voices) in {109, 131, 221}, f"Expected 109, 131, 221 voices in {engine}"
# print("\n".join(voice.id for voice in voices))
english_voices = [voice for voice in voices if voice.id.startswith("English")]
# Linux eSpeak-NG (v1.50) has 7 English voices, macOS eSpeak-NG (v1.51) has 8.
Expand All @@ -63,10 +65,12 @@ def test_espeak_voices(driver_name):
engine.say(f"{name} says hello")
engine.runAndWait() # TODO: Remove this line when multiple utterances work!
name_str = "|".join(names)
assert name_str == (
expected = (
"Caribbean|Great Britain|Scotland|Lancaster|West Midlands"
"|Received Pronunciation|America|America, New York City"
)
no_nyc = expected.rpartition("|")[0]
assert name_str in {expected, no_nyc}, f"Expected {expected} or {no_nyc}"
print(f"({name_str.replace('|', ' ; ')})", end=" ", flush=True)
engine.runAndWait()
engine.setProperty("voice", voice) # Reset voice to original value
Expand Down

0 comments on commit 21bf4ad

Please sign in to comment.