Yurii Paniv commited on
Commit
c7de0f6
1 Parent(s): 890295c

Add text_preformatter

Browse files
Files changed (3) hide show
  1. app.py +2 -0
  2. formatter.py +16 -0
  3. requirements.txt +2 -1
app.py CHANGED
@@ -6,6 +6,7 @@ from TTS.utils.manage import ModelManager
6
  from TTS.utils.synthesizer import Synthesizer
7
  import requests
8
  from os.path import exists
 
9
 
10
  MODEL_NAMES = [
11
  "uk/mai/vits-tts"
@@ -45,6 +46,7 @@ for MODEL_NAME in MODEL_NAMES:
45
 
46
  def tts(text: str, model_name: str):
47
  text = text if len(text) < 500 else text[0:500] # mitigate crashes on hf space
 
48
  print(text, model_name)
49
  synthesizer = MODELS.get(model_name, None)
50
  if synthesizer is None:
 
6
  from TTS.utils.synthesizer import Synthesizer
7
  import requests
8
  from os.path import exists
9
+ from formatter import preprocess_text
10
 
11
  MODEL_NAMES = [
12
  "uk/mai/vits-tts"
 
46
 
47
  def tts(text: str, model_name: str):
48
  text = text if len(text) < 500 else text[0:500] # mitigate crashes on hf space
49
+ text = preprocess_text(text)
50
  print(text, model_name)
51
  synthesizer = MODELS.get(model_name, None)
52
  if synthesizer is None:
formatter.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ def preprocess_text(text):
2
+ # replace apostrophe
3
+ text = text.replace("`", "'")
4
+ text = text.replace("ʼ", "'")
5
+ # numbers
6
+ text = text.replace("1", "один ")
7
+ text = text.replace("2", "два ")
8
+ text = text.replace("3", "три ")
9
+ text = text.replace("4", "чотири ")
10
+ text = text.replace("5", "п'ять ")
11
+ text = text.replace("6", "шість ")
12
+ text = text.replace("7", "сім ")
13
+ text = text.replace("8", "вісім ")
14
+ text = text.replace("9", "дев'ять ")
15
+ text = text.replace("0", "нуль ")
16
+ return text
requirements.txt CHANGED
@@ -1 +1,2 @@
1
- TTS==0.4.1
 
 
1
+ TTS==0.4.1
2
+ gradio