Pipe1213 commited on
Commit
1f2b8fe
·
verified ·
1 Parent(s): 26f0a75

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -21
app.py CHANGED
@@ -13,19 +13,10 @@ import commons
13
  import utils
14
  from data_utils import TextAudioLoader, TextAudioCollate, TextAudioSpeakerLoader, TextAudioSpeakerCollate
15
  from models import SynthesizerTrn
16
- #from text.symbols import symbols
17
- #from text.symbols_gra import symbols
18
  from text import text_to_sequence
19
  from scipy.io.wavfile import write
20
 
21
- ########################################
22
- _pad = '_'
23
- _punctuation = ';:,.!?¡¿—-<>*()…"«»“”~ '
24
- _letters = 'ABCÇDEFGHIJKLMNOPQRSTUVWXYZÂÊÎÔÛâêîôûéÉèåÅÈàÀùÙÌìëöabcçdefghijklmnopqrstuvwxyz'
25
- _letters_ipa = "ɑɐɒæɓʙβɔɕçɗɖðʤəɘɚɛɜɝɞɟʄɡɠɢʛɦɧħɥʜɨɪʝɭɬɫɮʟɱɯɰŋɳɲɴøɵɸθœɶʘɹɺɾɻʀʁɽʂʃʈʧʉʊʋⱱʌɣɤʍχʎʏʑʐʒʔʡʕʢǀǁǂǃˈˌːˑʼʴʰʱʲʷˠˤ˞↓↑→↗↘'̩'ᵻ"
26
- symbols = [_pad] + list(_punctuation) + list(_letters) + list(_letters_ipa)
27
- SPACE_ID = symbols.index(" ")
28
-
29
  def get_text(text, hps):
30
  text_norm = text_to_sequence(text, hps.data.text_cleaners)
31
  if hps.data.add_blank:
@@ -45,18 +36,15 @@ def load_model(model_path, hps):
45
  return net_g
46
 
47
  #hps = utils.get_hparams_from_file("configs/vctk_base.json")
48
- hps = utils.get_hparams_from_file("wa_graphemes/config.json")
49
 
50
  # Define a dictionary to store the model paths for each tab
51
  model_paths = {
52
- "Phonemes_finetuned": "fr_wa_finetuned_pho/G_125000.pth",
53
- "Graphemes_finetuned": "fr_wa_finetuned/G_198000.pth",
54
- "Phonemes": "path_to_phonemes_model.pth",
55
- "Graphemes": "wa_graphemes/G_258000.pth"
56
  }
57
 
58
  # Load the initial model
59
- net_g = load_model(model_paths["Graphemes"], hps)
60
 
61
  def tts(text, speaker_id, tab_name):
62
  global net_g
@@ -74,7 +62,7 @@ def tts(text, speaker_id, tab_name):
74
  def create_tab(tab_name):
75
  with gr.TabItem(tab_name):
76
  gr.Markdown(f"### {tab_name} TTS Model")
77
- tts_input1 = gr.TextArea(label="Text in Walloon (Depending on the model the input should be on phonemes or characters)", value="")
78
  tts_input2 = gr.Dropdown(label="Speaker", choices=["Male", "Female"], type="index", value="Male")
79
  tts_submit = gr.Button("Generate", variant="primary")
80
  tts_output1 = gr.Textbox(label="Message")
@@ -88,16 +76,13 @@ with app:
88
  # First Text to Speech (TTS) for Walloon
89
  Based on VITS (https://github.com/jaywalnut310/vits).
90
 
91
- Select the desired model and write the text in phonemes or graphemes depending on the model.
92
 
93
  For faster inference speed it is recommended to use short sentences.
94
  """
95
  )
96
  with gr.Tabs():
97
  create_tab("Phonemes_finetuned")
98
- create_tab("Graphemes_finetuned")
99
- create_tab("Phonemes")
100
- create_tab("Graphemes")
101
 
102
  gr.Markdown(
103
  """
 
13
  import utils
14
  from data_utils import TextAudioLoader, TextAudioCollate, TextAudioSpeakerLoader, TextAudioSpeakerCollate
15
  from models import SynthesizerTrn
16
+ from text.symbols import symbols
 
17
  from text import text_to_sequence
18
  from scipy.io.wavfile import write
19
 
 
 
 
 
 
 
 
 
20
  def get_text(text, hps):
21
  text_norm = text_to_sequence(text, hps.data.text_cleaners)
22
  if hps.data.add_blank:
 
36
  return net_g
37
 
38
  #hps = utils.get_hparams_from_file("configs/vctk_base.json")
39
+ hps = utils.get_hparams_from_file("configs/vctk_base.json")
40
 
41
  # Define a dictionary to store the model paths for each tab
42
  model_paths = {
43
+ "Phonemes_finetuned": "fr_wa_finetuned_pho/G_125000.pth"
 
 
 
44
  }
45
 
46
  # Load the initial model
47
+ net_g = load_model(model_paths["Phonemes_finetuned"], hps)
48
 
49
  def tts(text, speaker_id, tab_name):
50
  global net_g
 
62
  def create_tab(tab_name):
63
  with gr.TabItem(tab_name):
64
  gr.Markdown(f"### {tab_name} TTS Model")
65
+ tts_input1 = gr.TextArea(label="Text in Walloon on IPA phonemes", value="")
66
  tts_input2 = gr.Dropdown(label="Speaker", choices=["Male", "Female"], type="index", value="Male")
67
  tts_submit = gr.Button("Generate", variant="primary")
68
  tts_output1 = gr.Textbox(label="Message")
 
76
  # First Text to Speech (TTS) for Walloon
77
  Based on VITS (https://github.com/jaywalnut310/vits).
78
 
79
+ Write the text in phonemes or graphemes depending on the model.
80
 
81
  For faster inference speed it is recommended to use short sentences.
82
  """
83
  )
84
  with gr.Tabs():
85
  create_tab("Phonemes_finetuned")
 
 
 
86
 
87
  gr.Markdown(
88
  """