Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -139,7 +139,7 @@ async def get_speaker_id_map(selected_model: str):
|
|
139 |
|
140 |
@app.on_event("startup")
|
141 |
async def load_model_data():
|
142 |
-
global onnx_models, model_configurations # Make onnx_models and
|
143 |
# Load data for all models in the directory upon startup
|
144 |
sys.path.append('./content/piper/src/python')
|
145 |
models_path = "./content/piper/src/python"
|
@@ -156,10 +156,10 @@ async def load_model_data():
|
|
156 |
onnx_models = model_names # Populate onnx_models here
|
157 |
for config_name in config_names:
|
158 |
# Load the configuration data for each model (including speaker_id_map)
|
159 |
-
config = load_model_configuration(config_name)
|
160 |
model_configurations[config_name] = config
|
161 |
|
162 |
-
def load_model_configuration(config_name):
|
163 |
# Assuming config_name is the path to the JSON configuration file, e.g., 'model.json'
|
164 |
config_file_path = os.path.join(models_path, config_name)
|
165 |
|
@@ -172,6 +172,7 @@ def load_model_configuration(config_name):
|
|
172 |
return None
|
173 |
|
174 |
|
|
|
175 |
|
176 |
@app.post("/", response_class=HTMLResponse)
|
177 |
async def main(
|
|
|
139 |
|
140 |
@app.on_event("startup")
|
141 |
async def load_model_data():
|
142 |
+
global onnx_models, model_configurations, models_path # Make onnx_models, model_configurations, and models_path available globally
|
143 |
# Load data for all models in the directory upon startup
|
144 |
sys.path.append('./content/piper/src/python')
|
145 |
models_path = "./content/piper/src/python"
|
|
|
156 |
onnx_models = model_names # Populate onnx_models here
|
157 |
for config_name in config_names:
|
158 |
# Load the configuration data for each model (including speaker_id_map)
|
159 |
+
config = load_model_configuration(models_path, config_name)
|
160 |
model_configurations[config_name] = config
|
161 |
|
162 |
+
def load_model_configuration(models_path, config_name):
|
163 |
# Assuming config_name is the path to the JSON configuration file, e.g., 'model.json'
|
164 |
config_file_path = os.path.join(models_path, config_name)
|
165 |
|
|
|
172 |
return None
|
173 |
|
174 |
|
175 |
+
|
176 |
|
177 |
@app.post("/", response_class=HTMLResponse)
|
178 |
async def main(
|