This commit is contained in:
2025-06-15 22:24:33 -04:00
parent f5de4c3a5b
commit 0e11c919b8

View File

@@ -43,8 +43,9 @@ local function playTTSFile(value)
local headers = { local headers = {
["Content-Type"] = "application/x-www-form-urlencoded" ["Content-Type"] = "application/x-www-form-urlencoded"
} }
print("Sending HTTP POST request") print("Sending HTTP POST request")
local response = http.request({ local response = http.post({
url = ttsRoute, url = ttsRoute,
method = "POST", method = "POST",
body = body, body = body,
@@ -52,20 +53,10 @@ local function playTTSFile(value)
binary = false 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" ) print("HTTP POST request successful" )
-- Read and parse response local data = response.readAll()
local data = handle.readAll()
print(data) print(data)
handle.close() response.close()
end end
local function createSoundFile(fileName) local function createSoundFile(fileName)