Skip to content

Commit

Permalink
Fix UT
Browse files Browse the repository at this point in the history
  • Loading branch information
jordimas committed Jan 6, 2025
1 parent ced123f commit 040162b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions open_dubbing/text_to_speech.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(self):
def get_available_voices(self, language_code: str) -> List[Voice]:
pass

def _get_voices_with_region_preference_only(
def get_voices_for_region_only(
self, *, voices: List[Voice], target_language_region: str
) -> List[Voice]:
if len(target_language_region) == 0:
Expand All @@ -65,7 +65,7 @@ def assign_voices(
) -> Mapping[str, str | None]:

voices = self.get_available_voices(target_language)
region_voices = self._get_voices_with_region_preference_only(
region_voices = self.get_voices_for_region_only(
voices=voices, target_language_region=target_language_region
)

Expand Down
10 changes: 5 additions & 5 deletions tests/text_to_speech_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,32 +353,32 @@ def test_get_start_time_of_next_speech_utterance(
)
assert result == expected_result

def _test_get_voices_with_region_preference_only(self):
def test_get_voices_for_region_only(self):
voices = [
Voice(name="Voice1", gender="Male", region="US"),
Voice(name="Voice2", gender="Female", region="UK"),
Voice(name="Voice3", gender="Male", region="IN"),
Voice(name="Voice4", gender="Female", region="IN"),
]

result = TextToSpeechUT().get_voices_with_region_preference(
result = TextToSpeechUT().get_voices_for_region_only(
voices=voices, target_language_region="UK"
)
assert 1 == len(result)
assert "UK" == result[0].region

result = TextToSpeechUT().get_voices_with_region_preference(
result = TextToSpeechUT().get_voices_for_region_only(
voices=voices, target_language_region="IN"
)

assert 2 == len(result)
assert "IN" == result[0].region
assert "IN" == result[1].region

result = TextToSpeechUT().get_voices_with_region_preference(
result = TextToSpeechUT().get_voices_for_region_only(
voices=voices, target_language_region=""
)
assert 1 == len(result)
assert 4 == len(result)
assert "US" == result[0].region

@pytest.mark.parametrize(
Expand Down

0 comments on commit 040162b

Please sign in to comment.