Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -55,15 +55,21 @@ festcat_speakers = [s for s in speakers_list if len(s) == 3] #
|
|
| 55 |
google_speakers = [s for s in speakers_list if 3 < len(s) < 20] #
|
| 56 |
commonvoice_speakers = [s for s in speakers_list if len(s) > 20] #
|
| 57 |
|
|
|
|
|
|
|
|
|
|
| 58 |
DEFAULT_SPEAKER_ID = os.environ.get("DEFAULT_SPEAKER_ID", default="pau")
|
| 59 |
-
DEFAULT_CHECKPOINT = os.environ.get("DEFAULT_CHECKPOINT", default=model_files[
|
|
|
|
|
|
|
|
|
|
| 60 |
# model_file = model_files[0] # change this!!
|
| 61 |
|
| 62 |
# model_path = os.path.join(os.getcwd(), model_file)
|
| 63 |
# config_path = os.path.join(os.getcwd(), "config.json")
|
| 64 |
|
| 65 |
-
vocoder_path = None
|
| 66 |
-
vocoder_config_path = None
|
| 67 |
|
| 68 |
# synthesizer = Synthesizer(
|
| 69 |
# model_path, config_path, speakers_path, None, vocoder_path, vocoder_config_path,
|
|
@@ -89,7 +95,12 @@ def tts_inference(text: str, speaker_idx: str = None, model_file: str=None):
|
|
| 89 |
|
| 90 |
model_path = os.path.join(os.getcwd(), model_file)
|
| 91 |
speakers_file_path = "speakers.pth"
|
| 92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
vocoder_path = None
|
| 94 |
vocoder_config_path = None
|
| 95 |
|
|
@@ -179,11 +190,30 @@ with gr.Blocks(**AinaGradioTheme().get_kwargs()) as app:
|
|
| 179 |
return gr.update(choices=current_speakers, value=current_speakers[0])
|
| 180 |
|
| 181 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
speaker_id = gr.Dropdown(label="Select a voice", choices=speakers_list, value=DEFAULT_SPEAKER_ID,
|
| 183 |
interactive=True)
|
| 184 |
dataset.change(fn=update_speaker_list, inputs=dataset, outputs=speaker_id)
|
| 185 |
|
| 186 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
|
| 188 |
# model = gr.Dropdown(label="Select a model", choices=model_files, value=DEFAULT_MODEL_FILE_NAME)
|
| 189 |
with gr.Row():
|
|
|
|
| 55 |
google_speakers = [s for s in speakers_list if 3 < len(s) < 20] #
|
| 56 |
commonvoice_speakers = [s for s in speakers_list if len(s) > 20] #
|
| 57 |
|
| 58 |
+
hop_128_checkpoints = [c for c in model_files if c.split('_')[1] == "M"]
|
| 59 |
+
hop_96_checkpoints = [c for c in model_files if c.split('_')[1] == "reduced"]
|
| 60 |
+
|
| 61 |
DEFAULT_SPEAKER_ID = os.environ.get("DEFAULT_SPEAKER_ID", default="pau")
|
| 62 |
+
DEFAULT_CHECKPOINT = os.environ.get("DEFAULT_CHECKPOINT", default=model_files[-1])
|
| 63 |
+
|
| 64 |
+
model_config = "config.json" # by default 128 hop
|
| 65 |
+
|
| 66 |
# model_file = model_files[0] # change this!!
|
| 67 |
|
| 68 |
# model_path = os.path.join(os.getcwd(), model_file)
|
| 69 |
# config_path = os.path.join(os.getcwd(), "config.json")
|
| 70 |
|
| 71 |
+
# vocoder_path = None
|
| 72 |
+
# vocoder_config_path = None
|
| 73 |
|
| 74 |
# synthesizer = Synthesizer(
|
| 75 |
# model_path, config_path, speakers_path, None, vocoder_path, vocoder_config_path,
|
|
|
|
| 95 |
|
| 96 |
model_path = os.path.join(os.getcwd(), model_file)
|
| 97 |
speakers_file_path = "speakers.pth"
|
| 98 |
+
if model_file.split('_')[1] == "M":
|
| 99 |
+
config_path = "config.json"
|
| 100 |
+
elif model_file.split('_')[1] == "reduced":
|
| 101 |
+
config_path = "config_hop_96.json"
|
| 102 |
+
else:
|
| 103 |
+
config_path = "config.json"
|
| 104 |
vocoder_path = None
|
| 105 |
vocoder_config_path = None
|
| 106 |
|
|
|
|
| 190 |
return gr.update(choices=current_speakers, value=current_speakers[0])
|
| 191 |
|
| 192 |
|
| 193 |
+
def update_checkpoint_list(model_hop):
|
| 194 |
+
print("Updating checkpoint list based on model config:", model_hop)
|
| 195 |
+
if model_hop == "hop_size_128":
|
| 196 |
+
current_checkpoints = hop_128_checkpoints
|
| 197 |
+
# model_config = "config.json"
|
| 198 |
+
elif model_hop == "hop_size_96":
|
| 199 |
+
current_checkpoints = hop_96_checkpoints
|
| 200 |
+
else:
|
| 201 |
+
current_checkpoints = model_files
|
| 202 |
+
|
| 203 |
+
return gr.update(choices=current_checkpoints, value=current_checkpoints[0])
|
| 204 |
+
|
| 205 |
+
|
| 206 |
+
|
| 207 |
speaker_id = gr.Dropdown(label="Select a voice", choices=speakers_list, value=DEFAULT_SPEAKER_ID,
|
| 208 |
interactive=True)
|
| 209 |
dataset.change(fn=update_speaker_list, inputs=dataset, outputs=speaker_id)
|
| 210 |
|
| 211 |
+
model_hop = gr.Radio(["hop_size_128", "hop_size_96"], label="Model Type", value="hop_size_128")
|
| 212 |
+
|
| 213 |
+
model_chkpt = gr.Dropdown(label="Select a checkpoint", choices=model_files, value=DEFAULT_CHECKPOINT,
|
| 214 |
+
interactive=True)
|
| 215 |
+
|
| 216 |
+
model_hop.change(fn=update_checkpoint_list, inputs=model_hop, outputs=model_chkpt)
|
| 217 |
|
| 218 |
# model = gr.Dropdown(label="Select a model", choices=model_files, value=DEFAULT_MODEL_FILE_NAME)
|
| 219 |
with gr.Row():
|