cocktailpeanut commited on
Commit
e383d75
1 Parent(s): 96fddc0
Files changed (2) hide show
  1. app.py +14 -8
  2. melo/text/japanese.py +8 -3
app.py CHANGED
@@ -1,5 +1,6 @@
1
  import gradio as gr
2
  import os, torch, io
 
3
  #os.system('python -m unidic download')
4
  from melo.api import TTS
5
  speed = 1.0
@@ -15,6 +16,8 @@ else:
15
  languages = ["EN", "ES", "FR", "ZH", "JP", "KR"]
16
  en = ["EN-Default", "EN-US", "EN-BR", "EN_INDIA", "EN-AU"]
17
 
 
 
18
  #model = TTS(language='EN', device=device)
19
  def synthesize(language, speaker, text, speed=1.0, progress=gr.Progress()):
20
  model = TTS(language=language, device=device)
@@ -23,19 +26,22 @@ def synthesize(language, speaker, text, speed=1.0, progress=gr.Progress()):
23
  model.tts_to_file(text, speaker_ids[speaker], bio, speed=speed, pbar=progress.tqdm, format='wav')
24
  return bio.getvalue()
25
 
26
- def lang(language):
27
- if language == "EN":
28
- return gr.update(choices=en, value="EN-Default")
29
- else:
30
- return gr.update(choices=[language], value=language)
31
  with gr.Blocks() as demo:
32
  gr.Markdown('# MeloTTS\n\nAn unofficial demo of [MeloTTS](https://github.com/myshell-ai/MeloTTS) from MyShell AI. MeloTTS is a permissively licensed (MIT) SOTA multi-speaker TTS model.\n\nI am not affiliated with MyShell AI in any way.\n\nThis demo currently only supports English, but the model itself supports other languages.')
33
  with gr.Group():
34
- language = gr.Dropdown(languages, interactive=True, value='EN', label='Language')
35
- speaker = gr.Dropdown(en, interactive=True, value='EN-Default', label='Speaker')
 
 
 
36
  speed = gr.Slider(label='Speed', minimum=0.1, maximum=10.0, value=1.0, interactive=True, step=0.1)
37
  text = gr.Textbox(label="Text to speak", value='The field of text to speech has seen rapid development recently')
38
- language.change(fn=lang, inputs=[language], outputs=[speaker])
39
  btn = gr.Button('Synthesize', variant='primary')
40
  aud = gr.Audio(interactive=False)
41
  btn.click(synthesize, inputs=[language, speaker, text, speed], outputs=[aud])
 
1
  import gradio as gr
2
  import os, torch, io
3
+ import sys
4
  #os.system('python -m unidic download')
5
  from melo.api import TTS
6
  speed = 1.0
 
16
  languages = ["EN", "ES", "FR", "ZH", "JP", "KR"]
17
  en = ["EN-Default", "EN-US", "EN-BR", "EN_INDIA", "EN-AU"]
18
 
19
+ LANG = sys.argv[1]
20
+
21
  #model = TTS(language='EN', device=device)
22
  def synthesize(language, speaker, text, speed=1.0, progress=gr.Progress()):
23
  model = TTS(language=language, device=device)
 
26
  model.tts_to_file(text, speaker_ids[speaker], bio, speed=speed, pbar=progress.tqdm, format='wav')
27
  return bio.getvalue()
28
 
29
+ #def lang(language):
30
+ # if language == "EN":
31
+ # return gr.update(choices=en, value="EN-Default")
32
+ # else:
33
+ # return gr.update(choices=[language], value=language)
34
  with gr.Blocks() as demo:
35
  gr.Markdown('# MeloTTS\n\nAn unofficial demo of [MeloTTS](https://github.com/myshell-ai/MeloTTS) from MyShell AI. MeloTTS is a permissively licensed (MIT) SOTA multi-speaker TTS model.\n\nI am not affiliated with MyShell AI in any way.\n\nThis demo currently only supports English, but the model itself supports other languages.')
36
  with gr.Group():
37
+ # language = gr.Dropdown(languages, interactive=True, value='EN', label='Language')
38
+ if LANG == "EN":
39
+ speaker = gr.Dropdown(en, interactive=True, value='EN-Default', label='Speaker')
40
+ else:
41
+ speaker = gr.Dropdown([LANG], interactive=True, value='EN-Default', label='Speaker')
42
  speed = gr.Slider(label='Speed', minimum=0.1, maximum=10.0, value=1.0, interactive=True, step=0.1)
43
  text = gr.Textbox(label="Text to speak", value='The field of text to speech has seen rapid development recently')
44
+ # language.change(fn=lang, inputs=[language], outputs=[speaker])
45
  btn = gr.Button('Synthesize', variant='primary')
46
  aud = gr.Audio(interactive=False)
47
  btn.click(synthesize, inputs=[language, speaker, text, speed], outputs=[aud])
melo/text/japanese.py CHANGED
@@ -11,7 +11,8 @@ punctuation = ["!", "?", "…", ",", ".", "'", "-"]
11
  try:
12
  import MeCab
13
  except ImportError as e:
14
- raise ImportError("Japanese requires mecab-python3 and unidic-lite.") from e
 
15
  from num2words import num2words
16
 
17
  _CONVRULES = [
@@ -364,7 +365,11 @@ def hira2kata(text: str) -> str:
364
 
365
  _SYMBOL_TOKENS = set(list("・、。?!"))
366
  _NO_YOMI_TOKENS = set(list("「」『』―()[][]"))
367
- _TAGGER = MeCab.Tagger()
 
 
 
 
368
 
369
 
370
  def text2kata(text: str) -> str:
@@ -644,4 +649,4 @@ if __name__ == "__main__":
644
  # conv = kakasi.getConverter()
645
  # katakana_text = conv.do('ええ、僕はおきなと申します。こちらの小さいわらべは杏子。ご挨拶が遅れてしまいすみません。あなたの名は?') # Replace with your Chinese text
646
 
647
- # print(katakana_text) # Output: ニーハオセカイ
 
11
  try:
12
  import MeCab
13
  except ImportError as e:
14
+ print("")
15
+ # raise ImportError("Japanese requires mecab-python3 and unidic-lite.") from e
16
  from num2words import num2words
17
 
18
  _CONVRULES = [
 
365
 
366
  _SYMBOL_TOKENS = set(list("・、。?!"))
367
  _NO_YOMI_TOKENS = set(list("「」『』―()[][]"))
368
+
369
+ try:
370
+ _TAGGER = MeCab.Tagger()
371
+ except:
372
+ print("")
373
 
374
 
375
  def text2kata(text: str) -> str:
 
649
  # conv = kakasi.getConverter()
650
  # katakana_text = conv.do('ええ、僕はおきなと申します。こちらの小さいわらべは杏子。ご挨拶が遅れてしまいすみません。あなたの名は?') # Replace with your Chinese text
651
 
652
+ # print(katakana_text) # Output: ニーハオセカイ