From 9dce6de67c5dd451e672dc6a177392a7685e8b6d Mon Sep 17 00:00:00 2001 From: talksik Date: Sat, 29 Apr 2023 10:44:48 -0700 Subject: [PATCH] cleanup --- tts/app.py | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/tts/app.py b/tts/app.py index ae0bf1b..4de928f 100644 --- a/tts/app.py +++ b/tts/app.py @@ -11,23 +11,25 @@ API_URL = "http://192.168.50.159:5001/tts" audioInstance = audio.Audio() -# 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 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) +def say(text): + # send request with json + headers = { + "Content-type": "application/json", + } + response = requests.post( + API_URL, + headers=headers, + json={"text": text} + ) - f.close() + # 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) -# play the file -audioInstance.playFile(fileName) + f.close() + + # play the file + audioInstance.playFile(fileName)