Spaces:
Running
Running
Yurii Paniv
commited on
Commit
·
0e41b64
1
Parent(s):
d3459a5
Stress with model if not available in vocab
Browse files- app.py +2 -1
- ukrainian_tts/stress.py +7 -1
app.py
CHANGED
|
@@ -171,4 +171,5 @@ iface = gr.Interface(
|
|
| 171 |
],
|
| 172 |
],
|
| 173 |
)
|
| 174 |
-
iface.
|
|
|
|
|
|
| 171 |
],
|
| 172 |
],
|
| 173 |
)
|
| 174 |
+
iface.queue(concurrency_count=6)
|
| 175 |
+
iface.launch()
|
ukrainian_tts/stress.py
CHANGED
|
@@ -72,15 +72,21 @@ def sentence_to_stress(sentence: str, stress_function=stress_dict) -> str:
|
|
| 72 |
|
| 73 |
# add stress to single-vowel words
|
| 74 |
for word_index in range(0, len(new_list)):
|
| 75 |
-
element = new_list[word_index]
|
| 76 |
vowels_in_words = list(map(lambda letter: letter in vowels, element.lower()))
|
| 77 |
if "+" in element:
|
|
|
|
|
|
|
|
|
|
| 78 |
continue
|
| 79 |
if vowels_in_words.count(True) == 0:
|
| 80 |
continue
|
| 81 |
elif vowels_in_words.count(True) == 1:
|
| 82 |
vowel_index = vowels_in_words.index(True)
|
| 83 |
new_list[word_index] = element[0:vowel_index] + "+" + element[vowel_index::]
|
|
|
|
|
|
|
|
|
|
| 84 |
new_stressed = "".join(new_list)
|
| 85 |
|
| 86 |
# replace already stressed words
|
|
|
|
| 72 |
|
| 73 |
# add stress to single-vowel words
|
| 74 |
for word_index in range(0, len(new_list)):
|
| 75 |
+
element: str = new_list[word_index]
|
| 76 |
vowels_in_words = list(map(lambda letter: letter in vowels, element.lower()))
|
| 77 |
if "+" in element:
|
| 78 |
+
if element.count("+") > 1:
|
| 79 |
+
first = element.find("+")
|
| 80 |
+
new_list[word_index] = new_list[word_index][:first + 1] + new_list[word_index][first + 1:].replace("+", "")
|
| 81 |
continue
|
| 82 |
if vowels_in_words.count(True) == 0:
|
| 83 |
continue
|
| 84 |
elif vowels_in_words.count(True) == 1:
|
| 85 |
vowel_index = vowels_in_words.index(True)
|
| 86 |
new_list[word_index] = element[0:vowel_index] + "+" + element[vowel_index::]
|
| 87 |
+
elif vowels_in_words.count(True) > 1:
|
| 88 |
+
new_list[word_index] = stress_with_model(element)
|
| 89 |
+
|
| 90 |
new_stressed = "".join(new_list)
|
| 91 |
|
| 92 |
# replace already stressed words
|