txya900619 commited on
Commit
873fbd2
·
1 Parent(s): 10e10ea

fix: if input is text can't handle uppercase problem

Browse files
Files changed (2) hide show
  1. app.py +7 -0
  2. ipa/ipa.py +2 -8
app.py CHANGED
@@ -1,3 +1,5 @@
 
 
1
  import gradio as gr
2
  import numpy as np
3
  import spaces
@@ -41,7 +43,12 @@ def text_to_speech(
41
  if language not in g2p:
42
  tag = f"{language}_{dialect}"
43
 
 
 
 
 
44
  ignore_comma = "gt3" not in model_id
 
45
  if language == "阿美_秀姑巒":
46
  ipa = text
47
  else:
 
1
+ import re
2
+
3
  import gradio as gr
4
  import numpy as np
5
  import spaces
 
43
  if language not in g2p:
44
  tag = f"{language}_{dialect}"
45
 
46
+ text = text.lower()
47
+ text = re.sub(r"[.?!]", "", text)
48
+ text = text.replace("'", "’")
49
+
50
  ignore_comma = "gt3" not in model_id
51
+
52
  if language == "阿美_秀姑巒":
53
  ipa = text
54
  else:
ipa/ipa.py CHANGED
@@ -1,6 +1,3 @@
1
- import re
2
-
3
-
4
  def can_form_string(x, symbol_dict):
5
  def helper(x, symbol_dict, matched_parts):
6
  if not x:
@@ -21,12 +18,9 @@ def can_form_string(x, symbol_dict):
21
 
22
  def text_to_ipa(text, lang_tag, g2p, ignore_comma=True):
23
  ipa = []
24
- text = text.lower()
25
- text = re.sub(r"[.?!]", "", text)
26
- text = text.replace("'", "’")
27
  words = text.split() # change in future
28
 
29
- print(words)
30
 
31
  for word in words:
32
  ipa_parts = ""
@@ -34,7 +28,7 @@ def text_to_ipa(text, lang_tag, g2p, ignore_comma=True):
34
  result, matched_parts = can_form_string(word, extended_g2p)
35
 
36
  if result is False:
37
- print(word)
38
  return ""
39
 
40
  for matched_part in matched_parts:
 
 
 
 
1
  def can_form_string(x, symbol_dict):
2
  def helper(x, symbol_dict, matched_parts):
3
  if not x:
 
18
 
19
  def text_to_ipa(text, lang_tag, g2p, ignore_comma=True):
20
  ipa = []
 
 
 
21
  words = text.split() # change in future
22
 
23
+ print(f"ipa: {words}")
24
 
25
  for word in words:
26
  ipa_parts = ""
 
28
  result, matched_parts = can_form_string(word, extended_g2p)
29
 
30
  if result is False:
31
+ print(f"no match g2p : {word}")
32
  return ""
33
 
34
  for matched_part in matched_parts: