Yurii Paniv commited on
Commit
30f2cde
1 Parent(s): 305bf1a

Improve English handling

Browse files
tests/test_formatter.py CHANGED
@@ -3,7 +3,7 @@ from ukrainian_tts.formatter import preprocess_text
3
 
4
  def test_formatter():
5
  examples = [
6
- ("Quality of life update", "квюаліті оф ліфе юпдате"),
7
  ("Він украв 20000000 $", "він украв двадцять мільйонів долар"),
8
  (
9
  "111 000 000 000 доларів державного боргу.",
3
 
4
  def test_formatter():
5
  examples = [
6
+ ("Quality of life update", "кваліті оф ліфе юпдате"),
7
  ("Він украв 20000000 $", "він украв двадцять мільйонів долар"),
8
  (
9
  "111 000 000 000 доларів державного боргу.",
ukrainian_tts/formatter.py CHANGED
@@ -2,7 +2,8 @@ import num2words
2
  import re
3
 
4
 
5
- def preprocess_text(text, use_autostress_model=False):
 
6
  # currencies
7
  text = text.replace("$", "долар")
8
  text = text.replace("₴", "гривня")
@@ -59,6 +60,9 @@ def preprocess_text(text, use_autostress_model=False):
59
  text = text.replace("0", "нуль ")
60
  # speak english alphabet using brute force transliteration
61
  english = {
 
 
 
62
  "a": "а",
63
  "b": "б",
64
  "c": "ц",
@@ -91,5 +95,4 @@ def preprocess_text(text, use_autostress_model=False):
91
  text = text.replace(english_char.upper(), english[english_char].upper())
92
  text = text.replace(english_char, english[english_char])
93
 
94
- text = text.lower()
95
  return text
2
  import re
3
 
4
 
5
+ def preprocess_text(text):
6
+ text = text.lower()
7
  # currencies
8
  text = text.replace("$", "долар")
9
  text = text.replace("₴", "гривня")
60
  text = text.replace("0", "нуль ")
61
  # speak english alphabet using brute force transliteration
62
  english = {
63
+ "qu": "кв",
64
+ "ch": "ч",
65
+ "ph": "ф",
66
  "a": "а",
67
  "b": "б",
68
  "c": "ц",
95
  text = text.replace(english_char.upper(), english[english_char].upper())
96
  text = text.replace(english_char, english[english_char])
97
 
 
98
  return text