Update app.py
Browse files
app.py
CHANGED
|
@@ -26,9 +26,33 @@ def init():
|
|
| 26 |
# print(key_list)
|
| 27 |
return(gr.update(label="Voice",choices=key_list,value="lb_LU-marylux-medium",interactive=True))
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
def load_mod(instr="lb_LU-marylux-medium"):
|
| 30 |
load_mes=gr.Info(f"""Loading Model...<br>{instr}""",duration=2)
|
| 31 |
-
|
| 32 |
with open(pp.json_ob,'r') as f:
|
| 33 |
#json_ob=json.dumps(f.read(),indent=4)
|
| 34 |
json_ob=f.read()
|
|
|
|
| 26 |
# print(key_list)
|
| 27 |
return(gr.update(label="Voice",choices=key_list,value="lb_LU-marylux-medium",interactive=True))
|
| 28 |
|
| 29 |
+
def new_load_mod(self, instr="en_US-joe-medium"):
|
| 30 |
+
self.model=instr
|
| 31 |
+
lang=instr.split("_")[0]
|
| 32 |
+
dia=instr.split("-")[0]
|
| 33 |
+
name=instr.split("-")[1]
|
| 34 |
+
style=instr.split("-")[2]
|
| 35 |
+
file=f'{instr}.onnx'
|
| 36 |
+
print(f"Loading model: {file}")
|
| 37 |
+
if not os.path.isfile(f'{os.getcwd()}/voices/{file}'):
|
| 38 |
+
print(f"Model not found locally")
|
| 39 |
+
m_path= f"https://huggingface.co/rhasspy/piper-voices/resolve/main/{lang}/{dia}/{name}/{style}/{file}"
|
| 40 |
+
print("Downloading json...")
|
| 41 |
+
json_file=requests.get(f"{m_path}.json")
|
| 42 |
+
print("Downloading model...")
|
| 43 |
+
mod_file=requests.get(m_path)
|
| 44 |
+
with open(f'{os.getcwd()}/voices/{file}','wb') as m:
|
| 45 |
+
m.write(mod_file.content)
|
| 46 |
+
m.close()
|
| 47 |
+
with open(f'{os.getcwd()}/voices/{file}.json','wb') as j:
|
| 48 |
+
j.write(json_file.content)
|
| 49 |
+
j.close()
|
| 50 |
+
self.json_ob=f'{os.getcwd()}/voices/{file}.json'
|
| 51 |
+
print("Model Loaded")
|
| 52 |
+
|
| 53 |
def load_mod(instr="lb_LU-marylux-medium"):
|
| 54 |
load_mes=gr.Info(f"""Loading Model...<br>{instr}""",duration=2)
|
| 55 |
+
new_load_mod(instr=instr)
|
| 56 |
with open(pp.json_ob,'r') as f:
|
| 57 |
#json_ob=json.dumps(f.read(),indent=4)
|
| 58 |
json_ob=f.read()
|