Gregniuki commited on
Commit
5288ae8
·
1 Parent(s): ec04f88

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py CHANGED
@@ -118,6 +118,28 @@ def detect_onnx_models(path):
118
  return None
119
  renamed_audio_file = None
120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  #@app.post("/synthesize")
122
  #@app.post("/", response_class=FileResponse)
123
  @app.post("/", response_class=HTMLResponse)
 
118
  return None
119
  renamed_audio_file = None
120
 
121
+ model_configurations = {}
122
+
123
+ @app.on_event("startup")
124
+ async def load_model_data():
125
+ # Load data for all models in the directory upon startup
126
+ sys.path.append('./content/piper/src/python')
127
+ models_path = "./content/piper/src/python"
128
+ logging.basicConfig(level=logging.DEBUG)
129
+ providers = [
130
+ "CPUExecutionProvider"
131
+ if use_gpu is False
132
+ else ("CUDAExecutionProvider", {"cudnn_conv_algo_search": "DEFAULT"})
133
+ ]
134
+ sess_options = onnxruntime.SessionOptions()
135
+
136
+ # Collect data for all models in the directory and populate model_configurations
137
+ model_names = detect_onnx_models(models_path)
138
+ for model_name in model_names:
139
+ # Load the configuration data for each model (including speaker_id_map)
140
+ config = load_model_configuration(model_name)
141
+ model_configurations[model_name] = config
142
+
143
  #@app.post("/synthesize")
144
  #@app.post("/", response_class=FileResponse)
145
  @app.post("/", response_class=HTMLResponse)