diff --git a/speaker_driver.lua b/speaker_driver.lua index 9578e2d..43f5252 100644 --- a/speaker_driver.lua +++ b/speaker_driver.lua @@ -43,8 +43,9 @@ local function playTTSFile(value) local headers = { ["Content-Type"] = "application/x-www-form-urlencoded" } + print("Sending HTTP POST request") - local response = http.request({ + local response = http.post({ url = ttsRoute, method = "POST", body = body, @@ -52,20 +53,10 @@ local function playTTSFile(value) binary = false }) - -- Wait for the response - local event, resUrl, handle - repeat - event, resUrl, handle = os.pullEvent() - if event == "http_failure" and resUrl == url then - print("HTTP POST request failed for: " .. resUrl) - return - end - until event == "http_success" and resUrl == url print("HTTP POST request successful" ) - -- Read and parse response - local data = handle.readAll() + local data = response.readAll() print(data) - handle.close() + response.close() end local function createSoundFile(fileName)