Yurii Paniv commited on
Commit
c01049d
1 Parent(s): 70980d2

Add code coverage build

Browse files
.github/workflows/hf-sync.yml CHANGED
@@ -7,6 +7,33 @@ on:
7
  workflow_dispatch:
8
 
9
  jobs:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  sync-to-hub:
11
  runs-on: ubuntu-latest
12
  steps:
7
  workflow_dispatch:
8
 
9
  jobs:
10
+ build:
11
+ name: Run pytest and checks
12
+ runs-on: ubuntu-latest
13
+ #strategy:
14
+ # matrix:
15
+ # python-version: ["3.7", "3.8", "3.9", "3.10"]
16
+
17
+ steps:
18
+ - uses: actions/checkout@v3
19
+ - name: Set up Python 3.9 #${{ matrix.python-version }}
20
+ uses: actions/setup-python@v4
21
+ with:
22
+ python-version: 3.9 #${{ matrix.python-version }}
23
+ - name: Install dependencies
24
+ run: |
25
+ python -m pip install --upgrade pip
26
+ pip install pytest
27
+ pip install -r requirements-test.txt
28
+ #- name: Lint with flake8
29
+ # run: |
30
+ # # stop the build if there are Python syntax errors or undefined names
31
+ # flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
32
+ # # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
33
+ # flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
34
+ - name: Test with pytest
35
+ run: |
36
+ pytest
37
  sync-to-hub:
38
  runs-on: ubuntu-latest
39
  steps:
pytest.ini CHANGED
@@ -1,2 +1,2 @@
1
  [pytest]
2
- addopts = --ignore=training
1
  [pytest]
2
+ addopts = --ignore=training --cov=ukrainian_tts
requirements-test.txt CHANGED
@@ -1,3 +1,4 @@
1
  -r requirements.txt
2
 
3
- pytest==7.2.0
 
1
  -r requirements.txt
2
 
3
+ pytest==7.2.0
4
+ pytest-cov==4.0.0
{ukrainian_tts → tests}/__init__.py RENAMED
File without changes
tests/test_stress.py CHANGED
@@ -3,7 +3,8 @@ from ukrainian_tts.stress import sentence_to_stress, stress_with_model
3
 
4
  def test_stress_table():
5
  examples = [
6
- #("Бабин біб розцвів у дощ — Буде бабі біб у борщ.\n\nБоронила", "Б+абин б+іб розцв+ів +у д+ощ — Б+уде б+абі б+іб +у б+орщ.\n\nБоронила"),
 
7
  ("Бобер на березі з бобренятами бублики пік.","Боб+ер н+а березі з бобрен+ятами б+ублики п+ік."),
8
  (
9
  "Кам'янець-Подільський - місто в Хмельницькій області України, центр Кам'янець-Подільської міської об'єднаної територіальної громади і Кам'янець-Подільського району.",
3
 
4
  def test_stress_table():
5
  examples = [
6
+ ("Бабин біб розцвів у дощ — Буде бабі біб у борщ.\n\nБоронила", "Б+абин б+іб розцв+ів +у д+ощ — Б+уде б+абі б+іб +у б+орщ. Борон+ила"),
7
+ ("Бабин біб розцвів у дощ — Буде бабі біб у борщ.,,Боронила", "Б+абин б+іб розцв+ів +у д+ощ — Б+уде б+абі б+іб +у б+орщ.,,Борон+ила"),
8
  ("Бобер на березі з бобренятами бублики пік.","Боб+ер н+а березі з бобрен+ятами б+ублики п+ік."),
9
  (
10
  "Кам'янець-Подільський - місто в Хмельницькій області України, центр Кам'янець-Подільської міської об'єднаної територіальної громади і Кам'янець-Подільського району.",
ukrainian_tts/stress.py CHANGED
@@ -46,6 +46,7 @@ def stress_dict(sentence: str):
46
  def sentence_to_stress(sentence: str, stress_function=stress_dict) -> str:
47
  # save custom stress positions
48
  all_stresses = []
 
49
  orig_words = sentence.split(" ")
50
  for i in range(0, len(orig_words)):
51
  if "+" in orig_words[i]:
@@ -74,4 +75,4 @@ def sentence_to_stress(sentence: str, stress_function=stress_dict) -> str:
74
  for stressed in all_stresses:
75
  words[stressed] = orig_words[stressed]
76
  return " ".join(words)
77
- return new_stressed
46
  def sentence_to_stress(sentence: str, stress_function=stress_dict) -> str:
47
  # save custom stress positions
48
  all_stresses = []
49
+ sentence = sentence.replace("\n", " ")
50
  orig_words = sentence.split(" ")
51
  for i in range(0, len(orig_words)):
52
  if "+" in orig_words[i]:
75
  for stressed in all_stresses:
76
  words[stressed] = orig_words[stressed]
77
  return " ".join(words)
78
+ return new_stressed