Spaces:
Running
Running
Yurii Paniv
commited on
Commit
•
a4249a1
1
Parent(s):
858a295
Automatic stress by default, override manually with +
Browse files
app.py
CHANGED
@@ -12,13 +12,12 @@ import torch
|
|
12 |
|
13 |
|
14 |
class StressOption(Enum):
|
15 |
-
|
16 |
-
AutomaticStress = "Автоматичні наголоси (Beta)"
|
17 |
|
18 |
|
19 |
class VoiceOption(Enum):
|
20 |
-
MaleVoice = "Микита (чоловічий)"
|
21 |
FemaleVoice = "Олена (жіночий)"
|
|
|
22 |
|
23 |
|
24 |
def download(url, file_name):
|
@@ -105,7 +104,7 @@ iface = gr.Interface(
|
|
105 |
],
|
106 |
title="🐸💬🇺🇦 - Coqui TTS",
|
107 |
theme="huggingface",
|
108 |
-
description="Україномовний🇺🇦 TTS за допомогою Coqui TTS (
|
109 |
article="Якщо вам подобається, підтримайте за посиланням: [SUPPORT LINK](https://send.monobank.ua/jar/48iHq4xAXm), "
|
110 |
+ "Github: [https://github.com/robinhad/ukrainian-tts](https://github.com/robinhad/ukrainian-tts) \n"
|
111 |
+ "Model training - [Yurii Paniv @robinhad](https://github.com/robinhad) \n"
|
@@ -114,19 +113,19 @@ iface = gr.Interface(
|
|
114 |
+ f'<center><img src="{badge}" alt="visitors badge"/></center>',
|
115 |
examples=[
|
116 |
[
|
117 |
-
"
|
118 |
VoiceOption.FemaleVoice.value,
|
119 |
-
StressOption.
|
120 |
],
|
121 |
[
|
122 |
-
"
|
123 |
VoiceOption.MaleVoice.value,
|
124 |
-
StressOption.
|
125 |
],
|
126 |
[
|
127 |
-
"
|
128 |
VoiceOption.MaleVoice.value,
|
129 |
-
StressOption.
|
130 |
],
|
131 |
[
|
132 |
"Привіт, як тебе звати?",
|
|
|
12 |
|
13 |
|
14 |
class StressOption(Enum):
|
15 |
+
AutomaticStress = "Автоматичні наголоси"
|
|
|
16 |
|
17 |
|
18 |
class VoiceOption(Enum):
|
|
|
19 |
FemaleVoice = "Олена (жіночий)"
|
20 |
+
MaleVoice = "Микита (чоловічий)"
|
21 |
|
22 |
|
23 |
def download(url, file_name):
|
|
|
104 |
],
|
105 |
title="🐸💬🇺🇦 - Coqui TTS",
|
106 |
theme="huggingface",
|
107 |
+
description="Україномовний🇺🇦 TTS за допомогою Coqui TTS (щоб вручну поставити наголос, використовуйте + перед голосною)",
|
108 |
article="Якщо вам подобається, підтримайте за посиланням: [SUPPORT LINK](https://send.monobank.ua/jar/48iHq4xAXm), "
|
109 |
+ "Github: [https://github.com/robinhad/ukrainian-tts](https://github.com/robinhad/ukrainian-tts) \n"
|
110 |
+ "Model training - [Yurii Paniv @robinhad](https://github.com/robinhad) \n"
|
|
|
113 |
+ f'<center><img src="{badge}" alt="visitors badge"/></center>',
|
114 |
examples=[
|
115 |
[
|
116 |
+
"Введіть, будь ласка, своє речення.",
|
117 |
VoiceOption.FemaleVoice.value,
|
118 |
+
StressOption.AutomaticStress.value,
|
119 |
],
|
120 |
[
|
121 |
+
"Введіть, будь ласка, своє речення.",
|
122 |
VoiceOption.MaleVoice.value,
|
123 |
+
StressOption.AutomaticStress.value,
|
124 |
],
|
125 |
[
|
126 |
+
"Вв+едіть, будь ласка, св+оє реч+ення.",
|
127 |
VoiceOption.MaleVoice.value,
|
128 |
+
StressOption.AutomaticStress.value,
|
129 |
],
|
130 |
[
|
131 |
"Привіт, як тебе звати?",
|
stress.py
CHANGED
@@ -1,13 +1,23 @@
|
|
|
|
1 |
from ukrainian_word_stress import Stressifier, StressSymbol
|
2 |
|
3 |
stressify = Stressifier(stress_symbol=StressSymbol.CombiningAcuteAccent)
|
4 |
|
5 |
|
6 |
-
def sentence_to_stress(sentence):
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
new_stressed = ""
|
9 |
start = 0
|
10 |
last = 0
|
|
|
11 |
while True:
|
12 |
plus_position = stressed.find("+", start)
|
13 |
if plus_position != -1:
|
@@ -19,6 +29,13 @@ def sentence_to_stress(sentence):
|
|
19 |
else:
|
20 |
new_stressed += stressed[last:]
|
21 |
break
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
return new_stressed
|
23 |
|
24 |
|
@@ -31,6 +48,10 @@ if __name__ == "__main__":
|
|
31 |
print(sentence_to_stress(sentence))
|
32 |
sentence = "Не тільки в Україні таке може бути."
|
33 |
print(sentence_to_stress(sentence))
|
|
|
|
|
|
|
|
|
34 |
sentence = "Н тльк в крн тк мж бт."
|
35 |
print(sentence_to_stress(sentence))
|
36 |
sentence = "Н тльк в крн тк мж бт."
|
|
|
1 |
+
import numpy as np
|
2 |
from ukrainian_word_stress import Stressifier, StressSymbol
|
3 |
|
4 |
stressify = Stressifier(stress_symbol=StressSymbol.CombiningAcuteAccent)
|
5 |
|
6 |
|
7 |
+
def sentence_to_stress(sentence: str) -> str:
|
8 |
+
# save custom stress positions
|
9 |
+
all_stresses = []
|
10 |
+
orig_words = sentence.split(" ")
|
11 |
+
for i in range(0, len(orig_words)):
|
12 |
+
if "+" in orig_words[i]:
|
13 |
+
all_stresses.append(i)
|
14 |
+
|
15 |
+
# add stress before vowel
|
16 |
+
stressed = stressify(sentence.replace("+", "")).replace(StressSymbol.CombiningAcuteAccent, "+")
|
17 |
new_stressed = ""
|
18 |
start = 0
|
19 |
last = 0
|
20 |
+
|
21 |
while True:
|
22 |
plus_position = stressed.find("+", start)
|
23 |
if plus_position != -1:
|
|
|
29 |
else:
|
30 |
new_stressed += stressed[last:]
|
31 |
break
|
32 |
+
|
33 |
+
# replace already stressed words
|
34 |
+
if len(all_stresses) > 0:
|
35 |
+
words = new_stressed.split(" ")
|
36 |
+
for stressed in all_stresses:
|
37 |
+
words[stressed] = orig_words[stressed]
|
38 |
+
return " ".join(words)
|
39 |
return new_stressed
|
40 |
|
41 |
|
|
|
48 |
print(sentence_to_stress(sentence))
|
49 |
sentence = "Не тільки в Україні таке може бути."
|
50 |
print(sentence_to_stress(sentence))
|
51 |
+
sentence = "Не тільки в +Укра+їні т+аке може бути."
|
52 |
+
print(sentence_to_stress(sentence))
|
53 |
+
sentence = "два + два"
|
54 |
+
print(sentence_to_stress(sentence))
|
55 |
sentence = "Н тльк в крн тк мж бт."
|
56 |
print(sentence_to_stress(sentence))
|
57 |
sentence = "Н тльк в крн тк мж бт."
|