Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -209,25 +209,22 @@ def function(Textbox, Textbox2, Textbox3, Dropdown):
|
|
209 |
# reply = reply.replace(" ", "%20")
|
210 |
# image_array = download_image(f"https://api.placid.app/u/pydav4ibo?quote[text]={reply}")
|
211 |
data["messages"].append({"role": "assistant", "content": reply})
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
)
|
219 |
-
output =
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
# def convert_wav_to_mp3(wav_file, mp3_file):
|
224 |
-
# audio = AudioSegment.from_wav(wav_file)
|
225 |
-
# audio.export(mp3_file, format='mp3')
|
226 |
|
227 |
# output_file = "audio.wav"
|
228 |
output_file = "audio.mp3"
|
229 |
|
230 |
-
download_audio(
|
231 |
# convert_wav_to_mp3(output_file, "audio.mp3")
|
232 |
|
233 |
return "https://tommy24-flasktestgradio.hf.space/file=audio.mp3"
|
|
|
209 |
# reply = reply.replace(" ", "%20")
|
210 |
# image_array = download_image(f"https://api.placid.app/u/pydav4ibo?quote[text]={reply}")
|
211 |
data["messages"].append({"role": "assistant", "content": reply})
|
212 |
+
headers = {"Content-Type": "application/json"}
|
213 |
+
voice = {
|
214 |
+
"text": reply,
|
215 |
+
"key": "3637c6b5-09c9-4d49-b8fe-a9ffecc36f86",
|
216 |
+
"voice_id": "male"
|
217 |
+
}
|
218 |
+
response = requests.post(url, headers=headers, json=data)
|
219 |
+
output = responsee.json()
|
220 |
+
output_url = output[0]
|
221 |
+
def download_audio(output_url, output_file):
|
222 |
+
urllib.request.urlretrieve(output_url, output_file)
|
|
|
|
|
|
|
223 |
|
224 |
# output_file = "audio.wav"
|
225 |
output_file = "audio.mp3"
|
226 |
|
227 |
+
download_audio(output_url, output_file)
|
228 |
# convert_wav_to_mp3(output_file, "audio.mp3")
|
229 |
|
230 |
return "https://tommy24-flasktestgradio.hf.space/file=audio.mp3"
|