This commit is contained in:
talksik
2023-04-29 10:44:48 -07:00
parent 63d04477b2
commit 9dce6de67c
+14 -12
View File
@@ -11,23 +11,25 @@ API_URL = "http://192.168.50.159:5001/tts"
audioInstance = audio.Audio() audioInstance = audio.Audio()
# send request with json
headers = { def say(text):
# send request with json
headers = {
"Content-type": "application/json", "Content-type": "application/json",
} }
response = requests.post( response = requests.post(
API_URL, API_URL,
headers=headers, headers=headers,
json={"text": "hello world. the weather today is sunny."} json={"text": text}
) )
# get the file data from the response and write to temp local file # get the file data from the response and write to temp local file
fileName = "output.wav" fileName = "output.wav"
# todo: move this writing process to audio.py # todo: move this writing process to audio.py
with open(fileName, 'wb') as f: with open(fileName, 'wb') as f:
f.write(response.content) f.write(response.content)
f.close() f.close()
# play the file # play the file
audioInstance.playFile(fileName) audioInstance.playFile(fileName)