hexgrad commited on
Commit
343970c
·
verified ·
1 Parent(s): dd3b355

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -78,9 +78,12 @@ def normalize(text):
78
  text = re.sub(r'\d*\.\d+|\b\d{4}s?\b', split_num, text)
79
  text = re.sub(r'(?<=\d),(?=\d)', '', text)
80
  text = re.sub(r'(?<=\d)-(?=\d)', ' to ', text) # TODO: could be minus
 
81
  text = re.sub(r'(?<=\d):(?=\d)', ' ', text)
82
  text = re.sub(r'(?<=\d)S', ' S', text)
83
  text = re.sub(r"(?<=[A-Z])'?s", lambda m: m.group().upper(), text)
 
 
84
  return parens_to_angles(text).strip()
85
 
86
  phonemizers = dict(
@@ -101,8 +104,8 @@ def phonemize(text, voice, norm=True):
101
  if lang in 'ab':
102
  ps = ps.replace('kəkˈoːɹoʊ', 'kˈoʊkəɹoʊ').replace('kəkˈɔːɹəʊ', 'kˈəʊkəɹəʊ')
103
  ps = ps.replace('ʲ', 'j').replace('r', 'ɹ').replace('x', 'k').replace('ɬ', 'l')
104
- ps = ps.replace(' z', 'z')
105
  ps = re.sub(r'(?<=[a-zɹː])(?=hˈʌndɹɪd)', ' ', ps)
 
106
  if lang == 'a':
107
  ps = re.sub(r'(?<=nˈaɪn)ti(?!ː)', 'di', ps)
108
  ps = ''.join(filter(lambda p: p in VOCAB, ps))
@@ -502,7 +505,7 @@ audio_path, out_ps = client.predict(
502
 
503
  # 4. Display the audio and print the output phonemes
504
  from IPython.display import display, Audio
505
- display(Audio(audio_path))
506
  print(out_ps)
507
  ```
508
  Note that this Space and the underlying Kokoro model are both under development and subject to change. Reliability is not guaranteed. Hugging Face and/or Gradio might enforce their own rate limits.
 
78
  text = re.sub(r'\d*\.\d+|\b\d{4}s?\b', split_num, text)
79
  text = re.sub(r'(?<=\d),(?=\d)', '', text)
80
  text = re.sub(r'(?<=\d)-(?=\d)', ' to ', text) # TODO: could be minus
81
+ text = re.sub(r'(?<=\d):00\b', " o'clock", text)
82
  text = re.sub(r'(?<=\d):(?=\d)', ' ', text)
83
  text = re.sub(r'(?<=\d)S', ' S', text)
84
  text = re.sub(r"(?<=[A-Z])'?s", lambda m: m.group().upper(), text)
85
+ text = re.sub(r'(?:[A-Za-z]\.){2,} [a-z]', lambda m: m.group().replace('.', '-'), text)
86
+ text = re.sub(r'(?i)(?<=[A-Z])\.(?=[A-Z])', '-', text)
87
  return parens_to_angles(text).strip()
88
 
89
  phonemizers = dict(
 
104
  if lang in 'ab':
105
  ps = ps.replace('kəkˈoːɹoʊ', 'kˈoʊkəɹoʊ').replace('kəkˈɔːɹəʊ', 'kˈəʊkəɹəʊ')
106
  ps = ps.replace('ʲ', 'j').replace('r', 'ɹ').replace('x', 'k').replace('ɬ', 'l')
 
107
  ps = re.sub(r'(?<=[a-zɹː])(?=hˈʌndɹɪd)', ' ', ps)
108
+ ps = re.sub(r' z(?=[;:,.!?¡¿—…"«»“” ]|$)', 'z', ps)
109
  if lang == 'a':
110
  ps = re.sub(r'(?<=nˈaɪn)ti(?!ː)', 'di', ps)
111
  ps = ''.join(filter(lambda p: p in VOCAB, ps))
 
505
 
506
  # 4. Display the audio and print the output phonemes
507
  from IPython.display import display, Audio
508
+ display(Audio(audio_path, autoplay=True))
509
  print(out_ps)
510
  ```
511
  Note that this Space and the underlying Kokoro model are both under development and subject to change. Reliability is not guaranteed. Hugging Face and/or Gradio might enforce their own rate limits.