updated
This commit is contained in:
@@ -34,24 +34,35 @@ local function playInternalAlarm(speakers)
|
||||
playSound(speakers,"internal_alarm")
|
||||
end
|
||||
|
||||
local function playTTSFile()
|
||||
local function playTTSFile(value)
|
||||
local ttsRoute = "https://ttsmp3.com/makemp3_new.php"
|
||||
local fileName = "tts"
|
||||
local params = {
|
||||
msg = "Test",
|
||||
lang = "Gwyneth",
|
||||
source = "ttsmp3"
|
||||
local body = "msg=" .. textutils.urlEncode(value) .. "&lang=Gwyneth&source=ttsmp3"
|
||||
local headers = {
|
||||
["Content-Type"] = "application/x-www-form-urlencoded"
|
||||
}
|
||||
|
||||
|
||||
local stringBody = textutils.serialiseJSON(params)
|
||||
local response = http.request({
|
||||
url = ttsRoute,
|
||||
method = "POST",
|
||||
body = stringBody,
|
||||
body = body,
|
||||
headers = headers,
|
||||
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
|
||||
|
||||
local function createSoundFile(fileName)
|
||||
|
||||
Reference in New Issue
Block a user