Skip to content

Commit

Permalink
Add test case for #117
Browse files Browse the repository at this point in the history
Update test dependencies to pin compatible dependency
  • Loading branch information
NeonDaniel committed Mar 15, 2024
1 parent c55a2dd commit a998f7c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ jobs:
python-version: [ 3.7, 3.8, 3.9, "3.10", "3.11" ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
sudo apt-get install espeak-ng
python -m pip install --upgrade pip wheel
pip install -r requirements/requirements.txt -r requirements/test_requirements.txt
pip install . -r requirements/test_requirements.txt
- name: Test TTS
run: |
pytest tests/test_tts.py --junitxml=tests/tts-test-results.xml
Expand Down
2 changes: 1 addition & 1 deletion requirements/test_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
speechbrain
speechbrain~=0.5
resampy
pytest
pytest-timeout
20 changes: 16 additions & 4 deletions tests/test_tts.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
import os
import sys
import unittest
from os.path import isfile
from pprint import pprint
from tempfile import mkstemp

import resampy
import torch
Expand Down Expand Up @@ -97,23 +99,33 @@ def deleteFiles(self) -> None:
except FileNotFoundError:
pass

def test_error_cases(self):
_, out_file = mkstemp()
file, _ = self.tts.get_tts("failed to connect to wifi, verify credentials and try again", out_file)
self.assertEqual(file, out_file)
print(file)
# self.assertEqual(self.detect_language(wav_data=))

def test_speak_no_params(self):
out_file = os.path.join(os.path.dirname(__file__), "test.wav")
file, _ = self.tts.get_tts("Hello.", out_file)
self.assertEqual(file, out_file)
self.assertTrue(isfile(file))

def test_speak_lang(self):
for lang in CoquiTTS.langs:
sentence = CoquiTTS.langs[lang]["sentence"]
with self.subTest(lang=lang):
speaker = {
"language" : lang
"language": lang
}
wav_data, synthesizer = self.tts.get_audio(sentence, speaker = speaker)
wav_data, synthesizer = self.tts.get_audio(sentence,
speaker=speaker)
detected_language = self.detect_language(wav_data, synthesizer)
if (lang in self.lang_exeptions):
if lang in self.lang_exeptions:
lang_exeption = self.lang_exeptions[lang]
print(f"Language {lang} is an exeption and detected as {lang_exeption}")
print(f"Language {lang} is an exception and detected as "
f"{lang_exeption}")
lang = lang_exeption
self.assertIn(detected_language, lang)

Expand Down

0 comments on commit a998f7c

Please sign in to comment.