Yurii Paniv commited on
Commit
12ee3cc
1 Parent(s): de21232

Apply black formatter

Browse files
Files changed (5) hide show
  1. .gitignore +3 -0
  2. .vscode/settings.json +3 -0
  3. app.py +4 -3
  4. formatter.py +3 -1
  5. stress_with_model.py +1 -4
.gitignore CHANGED
@@ -128,6 +128,9 @@ dmypy.json
128
  # Pyre type checker
129
  .pyre/
130
 
 
 
 
131
  # model files
132
  *.pth.tar
133
  *.pth
128
  # Pyre type checker
129
  .pyre/
130
 
131
+ # mac
132
+ .DS_Store
133
+
134
  # model files
135
  *.pth.tar
136
  *.pth
.vscode/settings.json ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ {
2
+ "python.formatting.provider": "black"
3
+ }
app.py CHANGED
@@ -67,7 +67,9 @@ def tts(text: str, voice: str, stress: str):
67
  print("Voice", voice)
68
  print("Stress:", stress)
69
  print("Time:", datetime.utcnow())
70
- autostress_with_model = True if stress == StressOption.AutomaticStressWithModel.value else False
 
 
71
  speaker_name = "male1" if voice == VoiceOption.MaleVoice.value else "female3"
72
  text = preprocess_text(text, autostress_with_model)
73
  text_limit = 7200
@@ -93,7 +95,7 @@ iface = gr.Interface(
93
  gr.inputs.Radio(
94
  label="Голос",
95
  choices=[option.value for option in VoiceOption],
96
- default=VoiceOption.FemaleVoice.value
97
  ),
98
  gr.inputs.Radio(
99
  label="Наголоси",
@@ -105,7 +107,6 @@ iface = gr.Interface(
105
  gr.outputs.Textbox(label="Наголошений текст"),
106
  ],
107
  title="🐸💬🇺🇦 - Coqui TTS",
108
- #theme="huggingface",
109
  description="Україномовний🇺🇦 TTS за допомогою Coqui TTS (щоб вручну поставити наголос, використовуйте + перед голосною)",
110
  article="Якщо вам подобається, підтримайте за посиланням: [SUPPORT LINK](https://send.monobank.ua/jar/48iHq4xAXm), "
111
  + "Github: [https://github.com/robinhad/ukrainian-tts](https://github.com/robinhad/ukrainian-tts) \n"
67
  print("Voice", voice)
68
  print("Stress:", stress)
69
  print("Time:", datetime.utcnow())
70
+ autostress_with_model = (
71
+ True if stress == StressOption.AutomaticStressWithModel.value else False
72
+ )
73
  speaker_name = "male1" if voice == VoiceOption.MaleVoice.value else "female3"
74
  text = preprocess_text(text, autostress_with_model)
75
  text_limit = 7200
95
  gr.inputs.Radio(
96
  label="Голос",
97
  choices=[option.value for option in VoiceOption],
98
+ default=VoiceOption.FemaleVoice.value,
99
  ),
100
  gr.inputs.Radio(
101
  label="Наголоси",
107
  gr.outputs.Textbox(label="Наголошений текст"),
108
  ],
109
  title="🐸💬🇺🇦 - Coqui TTS",
 
110
  description="Україномовний🇺🇦 TTS за допомогою Coqui TTS (щоб вручну поставити наголос, використовуйте + перед голосною)",
111
  article="Якщо вам подобається, підтримайте за посиланням: [SUPPORT LINK](https://send.monobank.ua/jar/48iHq4xAXm), "
112
  + "Github: [https://github.com/robinhad/ukrainian-tts](https://github.com/robinhad/ukrainian-tts) \n"
formatter.py CHANGED
@@ -78,7 +78,9 @@ def preprocess_text(text, use_autostress_model=False):
78
  text = text.replace(english_char.upper(), english[english_char].upper())
79
  text = text.replace(english_char, english[english_char])
80
 
81
- text = sentence_to_stress(text, stress_with_model if use_autostress_model else stress_dict)
 
 
82
 
83
  return text
84
 
78
  text = text.replace(english_char.upper(), english[english_char].upper())
79
  text = text.replace(english_char, english[english_char])
80
 
81
+ text = sentence_to_stress(
82
+ text, stress_with_model if use_autostress_model else stress_dict
83
+ )
84
 
85
  return text
86
 
stress_with_model.py CHANGED
@@ -3,10 +3,7 @@ import ukrainian_accentor as accentor
3
  # run
4
  def stress_with_model(text: str):
5
  text = text.lower()
6
- try:
7
- result = accentor.process(text, mode='plus')
8
- except ValueError: # TODO: apply fix for cases when there are no vowels
9
- return text
10
  return result
11
 
12
 
3
  # run
4
  def stress_with_model(text: str):
5
  text = text.lower()
6
+ result = accentor.process(text, mode="plus")
 
 
 
7
  return result
8
 
9