updated
This commit is contained in:
@@ -15,7 +15,7 @@ local function startup()
|
|||||||
--speakerDriver.playControlRoomAlarm(controlRoomSpeakers)
|
--speakerDriver.playControlRoomAlarm(controlRoomSpeakers)
|
||||||
--speakerDriver.playExternalAlarm(controlRoomSpeakers)
|
--speakerDriver.playExternalAlarm(controlRoomSpeakers)
|
||||||
--speakerDriver.playInternalAlarm(controlRoomSpeakers)
|
--speakerDriver.playInternalAlarm(controlRoomSpeakers)
|
||||||
speakerDriver.playTTSFile("test")
|
speakerDriver.playTTSFile(controlRoomSpeakers, "test")
|
||||||
end
|
end
|
||||||
|
|
||||||
local function run()
|
local function run()
|
||||||
|
|||||||
@@ -34,9 +34,9 @@ local function playInternalAlarm(speakers)
|
|||||||
playSound(speakers,"internal_alarm")
|
playSound(speakers,"internal_alarm")
|
||||||
end
|
end
|
||||||
|
|
||||||
local function playTTSFile(value)
|
local function playTTSFile(speakers, value)
|
||||||
local ttsRoute = "https://ttsmp3.com/makemp3_new.php"
|
local ttsRoute = "https://ttsmp3.com/makemp3_new.php"
|
||||||
local fileName = "tts"
|
local fileName = "tts.dfpwm"
|
||||||
local encodedValue = textutils.urlEncode(value)
|
local encodedValue = textutils.urlEncode(value)
|
||||||
print("Encoded TTS value: " .. encodedValue)
|
print("Encoded TTS value: " .. encodedValue)
|
||||||
local body = "msg=" .. encodedValue .. "&lang=Gwyneth&source=ttsmp3"
|
local body = "msg=" .. encodedValue .. "&lang=Gwyneth&source=ttsmp3"
|
||||||
@@ -55,10 +55,24 @@ local function playTTSFile(value)
|
|||||||
|
|
||||||
print("HTTP POST request successful" )
|
print("HTTP POST request successful" )
|
||||||
local data = response.readAll()
|
local data = response.readAll()
|
||||||
local responseData = textutils.unserialiseJSON(data, { parse_null = true })
|
|
||||||
print(responseData.MP3)
|
|
||||||
print(responseData.URL)
|
|
||||||
response.close()
|
response.close()
|
||||||
|
|
||||||
|
local responseData = textutils.unserialiseJSON(data, { parse_null = true })
|
||||||
|
local soundRequest = http.get({
|
||||||
|
url = responseData.URL,
|
||||||
|
binary = true
|
||||||
|
})
|
||||||
|
|
||||||
|
local soundData = soundRequest.readAll()
|
||||||
|
soundRequest.close()
|
||||||
|
|
||||||
|
local encodedData = encoder(soundData)
|
||||||
|
|
||||||
|
local file = fs.open(fileName, "w")
|
||||||
|
file.write(encodedData)
|
||||||
|
file.close()
|
||||||
|
|
||||||
|
playSound(speakers, fileName)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function createSoundFile(fileName)
|
local function createSoundFile(fileName)
|
||||||
|
|||||||
Reference in New Issue
Block a user