getting request and writing to file working

This commit is contained in:
talksik
2023-04-29 10:18:24 -07:00
parent c51c7ec91f
commit 1f75697640
6 changed files with 24 additions and 11 deletions
+17 -6
View File
@@ -11,12 +11,23 @@ API_URL = "http://192.168.50.159:5001/tts"
audioInstance = audio.Audio()
response = requests.post(API_URL, data={'text': 'hello world'})
print(response)
# send request with json
headers = {
"Content-type": "application/json",
}
response = requests.post(
API_URL,
headers=headers,
json={"text": "hello world. the weather today is sunny."}
)
# get the file data from the response
# write the file data to a file
# save the file
# get the file data from the response and write to temp local file
fileName = "output.wav"
# todo: move this writing process to audio.py
with open(fileName, 'wb') as f:
f.write(response.content)
f.close()
# play the file
audioInstance.playFile('audio.wav')
audioInstance.playFile(fileName)
BIN
View File
Binary file not shown.