Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -129,7 +129,7 @@ def detect_onnx_models(path):
|
|
| 129 |
def get_initial_values():
|
| 130 |
# You can set default values or load them from a configuration file here
|
| 131 |
selected_model = onnx_models[0] if onnx_models else "default_model"
|
| 132 |
-
selected_speaker_id =
|
| 133 |
|
| 134 |
# Check if there are onnx models and load the speaker_id_map from the first model's config
|
| 135 |
if onnx_models:
|
|
@@ -138,6 +138,8 @@ def get_initial_values():
|
|
| 138 |
speaker_id_map = first_model_config.get("speaker_id_map")
|
| 139 |
if speaker_id_map:
|
| 140 |
selected_speaker_id = next(iter(speaker_id_map)) # Get the first speaker_id
|
|
|
|
|
|
|
| 141 |
|
| 142 |
return selected_model, selected_speaker_id
|
| 143 |
@app.get("/get_speaker_id_map")
|
|
@@ -147,7 +149,11 @@ async def get_speaker_id_map(selected_model: str):
|
|
| 147 |
print("selectef config ",config)
|
| 148 |
if config:
|
| 149 |
speaker_id_map = config.get("speaker_id_map", {})
|
| 150 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
|
| 152 |
# Handle the case where the config is not available for the selected model
|
| 153 |
return {"speaker_id_map": {}}
|
|
@@ -235,6 +241,7 @@ async def main(
|
|
| 235 |
]
|
| 236 |
sess_options = onnxruntime.SessionOptions()
|
| 237 |
model, config = load_onnx(selected_model, sess_options, providers)
|
|
|
|
| 238 |
speaker_id_map = config.get("speaker_id_map", {})
|
| 239 |
|
| 240 |
auto_play = play
|
|
|
|
| 129 |
def get_initial_values():
|
| 130 |
# You can set default values or load them from a configuration file here
|
| 131 |
selected_model = onnx_models[0] if onnx_models else "default_model"
|
| 132 |
+
selected_speaker_id = 0 # Default value
|
| 133 |
|
| 134 |
# Check if there are onnx models and load the speaker_id_map from the first model's config
|
| 135 |
if onnx_models:
|
|
|
|
| 138 |
speaker_id_map = first_model_config.get("speaker_id_map")
|
| 139 |
if speaker_id_map:
|
| 140 |
selected_speaker_id = next(iter(speaker_id_map)) # Get the first speaker_id
|
| 141 |
+
else:
|
| 142 |
+
selected_speaker_id = 0
|
| 143 |
|
| 144 |
return selected_model, selected_speaker_id
|
| 145 |
@app.get("/get_speaker_id_map")
|
|
|
|
| 149 |
print("selectef config ",config)
|
| 150 |
if config:
|
| 151 |
speaker_id_map = config.get("speaker_id_map", {})
|
| 152 |
+
if speaker_id_map:
|
| 153 |
+
return {"speaker_id_map": speaker_id_map}
|
| 154 |
+
else:
|
| 155 |
+
speaker_id_map = {"speaker1": "0",
|
| 156 |
+
}
|
| 157 |
|
| 158 |
# Handle the case where the config is not available for the selected model
|
| 159 |
return {"speaker_id_map": {}}
|
|
|
|
| 241 |
]
|
| 242 |
sess_options = onnxruntime.SessionOptions()
|
| 243 |
model, config = load_onnx(selected_model, sess_options, providers)
|
| 244 |
+
config["espeak"]["voice"] = speaker
|
| 245 |
speaker_id_map = config.get("speaker_id_map", {})
|
| 246 |
|
| 247 |
auto_play = play
|