CavidanZ commited on
Commit
0a83acd
·
verified ·
1 Parent(s): 5d59708

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -1
app.py CHANGED
@@ -21,6 +21,7 @@ URL_PIPER_DOWNLOAD = "https://github.com/rhasspy/piper/releases/download/v1.2.0/
21
  # TTS model files
22
  URL_TTS_ONNX = "https://huggingface.co/spaces/CavidanZ/TTS-azerbaijani-model/resolve/main/last.onnx"
23
  URL_TTS_ONNX_2 = "https://huggingface.co/spaces/CavidanZ/TTS-azerbaijani-model/resolve/main/last2.onnx"
 
24
  URL_TACOTRON2 = "https://huggingface.co/spaces/CavidanZ/TTS-azerbaijani-model/resolve/main/Audiobook_based"
25
  TMP_PIPER_FILENAME = os.path.join(BASE_PATH, "piper.tgz")
26
 
@@ -85,6 +86,23 @@ if os.path.exists(BASE_PATH_MODEL) == False:
85
  else:
86
  st.markdown(f"Failed to download TTS json from {URL_TTS_ONNX}.json (Status code: {response.status_code})")
87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  ###########################
89
  # MODEL DOWNLOAD FINISHED #
90
  ###########################
@@ -105,7 +123,7 @@ st.header('A text-to-speech (TTS) model in Azerbaijani language')
105
  with st.form("my_form"):
106
  option = st.selectbox(
107
  'Choose the model.',
108
- ('VITS Model 1','VITS Model 2'))
109
 
110
  text = st.text_area("Text to generate audio from:",max_chars=500)
111
  # Default parameter values
@@ -124,6 +142,9 @@ with st.form("my_form"):
124
  MODEL = "last2.onnx"
125
  case "VITS Model 2":
126
  MODEL = "last.onnx"
 
 
 
127
 
128
  cmd = "echo '" + text + "' | " + BASE_PATH + "/piper/piper --model " + os.path.join(BASE_PATH_MODEL, MODEL) + " --speaker " + SPEAKER_ID + " --output_file " + filename.name + " --length-scale " + str(length_scale)
129
 
 
21
  # TTS model files
22
  URL_TTS_ONNX = "https://huggingface.co/spaces/CavidanZ/TTS-azerbaijani-model/resolve/main/last.onnx"
23
  URL_TTS_ONNX_2 = "https://huggingface.co/spaces/CavidanZ/TTS-azerbaijani-model/resolve/main/last2.onnx"
24
+ URL_TTS_FH = "https://huggingface.co/spaces/CavidanZ/TTS-azerbaijani-model/resolve/main/last_FH.onnx"
25
  URL_TACOTRON2 = "https://huggingface.co/spaces/CavidanZ/TTS-azerbaijani-model/resolve/main/Audiobook_based"
26
  TMP_PIPER_FILENAME = os.path.join(BASE_PATH, "piper.tgz")
27
 
 
86
  else:
87
  st.markdown(f"Failed to download TTS json from {URL_TTS_ONNX}.json (Status code: {response.status_code})")
88
 
89
+ # --- Download TTS model - VITS Version FH --- #
90
+ response = requests.get(URL_TTS_FH, headers=headers)
91
+ if response.status_code == 200:
92
+ with open(os.path.join(BASE_PATH_MODEL, "last2.onnx"), 'wb') as f:
93
+ f.write(response.content)
94
+ else:
95
+ st.markdown(f"Failed to download TTS from {URL_TTS_ONNX} (Status code: {response.status_code})")
96
+
97
+
98
+ response = requests.get((URL_TTS_FH + ".json"), headers=headers)
99
+ if response.status_code == 200:
100
+ with open(os.path.join(BASE_PATH_MODEL, "last2.onnx.json"), 'wb') as f:
101
+ f.write(response.content)
102
+ else:
103
+ st.markdown(f"Failed to download TTS json from {URL_TTS_ONNX}.json (Status code: {response.status_code})")
104
+
105
+
106
  ###########################
107
  # MODEL DOWNLOAD FINISHED #
108
  ###########################
 
123
  with st.form("my_form"):
124
  option = st.selectbox(
125
  'Choose the model.',
126
+ ('VITS Model 1','VITS Model 2','FH'))
127
 
128
  text = st.text_area("Text to generate audio from:",max_chars=500)
129
  # Default parameter values
 
142
  MODEL = "last2.onnx"
143
  case "VITS Model 2":
144
  MODEL = "last.onnx"
145
+ case "FH":
146
+ MODEL = "last_FH.onnx"
147
+
148
 
149
  cmd = "echo '" + text + "' | " + BASE_PATH + "/piper/piper --model " + os.path.join(BASE_PATH_MODEL, MODEL) + " --speaker " + SPEAKER_ID + " --output_file " + filename.name + " --length-scale " + str(length_scale)
150