This commit is contained in:
2025-06-15 22:14:08 -04:00
parent 9c7005b4f7
commit 6a5517609c
2 changed files with 23 additions and 11 deletions

View File

@@ -12,9 +12,10 @@ end
local function startup() local function startup()
speakerDriver.startup() speakerDriver.startup()
speakerDriver.playControlRoomAlarm(controlRoomSpeakers) --speakerDriver.playControlRoomAlarm(controlRoomSpeakers)
speakerDriver.playExternalAlarm(controlRoomSpeakers) --speakerDriver.playExternalAlarm(controlRoomSpeakers)
speakerDriver.playInternalAlarm(controlRoomSpeakers) --speakerDriver.playInternalAlarm(controlRoomSpeakers)
speakerDriver.playTTSFile(controlRoomSpeakers, "test")
end end
local function run() local function run()

View File

@@ -34,24 +34,35 @@ local function playInternalAlarm(speakers)
playSound(speakers,"internal_alarm") playSound(speakers,"internal_alarm")
end end
local function playTTSFile() local function playTTSFile(value)
local ttsRoute = "https://ttsmp3.com/makemp3_new.php" local ttsRoute = "https://ttsmp3.com/makemp3_new.php"
local fileName = "tts" local fileName = "tts"
local params = { local body = "msg=" .. textutils.urlEncode(value) .. "&lang=Gwyneth&source=ttsmp3"
msg = "Test", local headers = {
lang = "Gwyneth", ["Content-Type"] = "application/x-www-form-urlencoded"
source = "ttsmp3"
} }
local stringBody = textutils.serialiseJSON(params)
local response = http.request({ local response = http.request({
url = ttsRoute, url = ttsRoute,
method = "POST", method = "POST",
body = stringBody, body = body,
headers = headers, headers = headers,
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
-- Read and parse response
local data = handle.readAll()
print(data)
handle.close()
end end
local function createSoundFile(fileName) local function createSoundFile(fileName)