Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -56,11 +56,7 @@ import uuid
|
|
56 |
import soundfile as sf
|
57 |
#from IPython.display import display, Audio, Markdown, clear_output
|
58 |
from piper_phonemize import phonemize_codepoints, phonemize_espeak, tashkeel_run
|
59 |
-
|
60 |
-
with open("multi265ende175.onnx.json", "r") as config_file:
|
61 |
-
config_data = json.load(config_file)
|
62 |
-
speaker_id_map = config_data.get("speaker_id_map", {})
|
63 |
-
voices = [{"id": speaker_id, "name": speaker_name} for speaker_id, speaker_name in speaker_id_map.items()]
|
64 |
#@app.get("/", response_class=HTMLResponse)
|
65 |
#async def read_root(request: Request):
|
66 |
# return templates.TemplateResponse("interface.html", {"request": request, "data": data})
|
@@ -133,8 +129,8 @@ async def load_model_data():
|
|
133 |
sess_options = onnxruntime.SessionOptions()
|
134 |
|
135 |
# Collect data for all models in the directory and populate model_configurations
|
136 |
-
|
137 |
-
for model_name in
|
138 |
# Load the configuration data for each model (including speaker_id_map)
|
139 |
config = load_model_configuration(model_name)
|
140 |
model_configurations[model_name] = config
|
@@ -174,11 +170,13 @@ async def main(
|
|
174 |
# description=f'{lan.translate(lang, "Select speaker")}:',
|
175 |
# layout={'visibility': 'hidden'}
|
176 |
# )
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
|
|
|
|
182 |
# Show loading message and disable the form
|
183 |
response_html = """
|
184 |
<div id="loading-message">Generating your audio, please wait...</div>
|
|
|
56 |
import soundfile as sf
|
57 |
#from IPython.display import display, Audio, Markdown, clear_output
|
58 |
from piper_phonemize import phonemize_codepoints, phonemize_espeak, tashkeel_run
|
59 |
+
|
|
|
|
|
|
|
|
|
60 |
#@app.get("/", response_class=HTMLResponse)
|
61 |
#async def read_root(request: Request):
|
62 |
# return templates.TemplateResponse("interface.html", {"request": request, "data": data})
|
|
|
129 |
sess_options = onnxruntime.SessionOptions()
|
130 |
|
131 |
# Collect data for all models in the directory and populate model_configurations
|
132 |
+
onnx_models = detect_onnx_models(models_path)
|
133 |
+
for model_name in onnx_models:
|
134 |
# Load the configuration data for each model (including speaker_id_map)
|
135 |
config = load_model_configuration(model_name)
|
136 |
model_configurations[model_name] = config
|
|
|
170 |
# description=f'{lan.translate(lang, "Select speaker")}:',
|
171 |
# layout={'visibility': 'hidden'}
|
172 |
# )
|
173 |
+
# Handle loading the selected model and speaker ID here
|
174 |
+
if selected_model in model_configurations:
|
175 |
+
config = model_configurations[selected_model]
|
176 |
+
onnx_model = config["onnx_model"] # Replace with the actual key for your ONNX model file
|
177 |
+
model, config = load_onnx(onnx_model, sess_options, providers)
|
178 |
+
speaker_id_map = config.get("speaker_id_map", {})
|
179 |
+
if isinstance(onnx_models, str):
|
180 |
# Show loading message and disable the form
|
181 |
response_html = """
|
182 |
<div id="loading-message">Generating your audio, please wait...</div>
|