t
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
local dfpwm = require("cc.audio.dfpwm")
|
local dfpwm = require("cc.audio.dfpwm")
|
||||||
|
local ffmpeg = require('ffmpeg')
|
||||||
|
|
||||||
local encoder = dfpwm.make_encoder()
|
local encoder = dfpwm.make_encoder()
|
||||||
local decoder = dfpwm.make_decoder()
|
local decoder = dfpwm.make_decoder()
|
||||||
local baseRoute = "https://git.astrocore.space/root/NovaCorpLLC/raw/branch/main/"
|
local baseRoute = "https://git.astrocore.space/root/NovaCorpLLC/raw/branch/main/"
|
||||||
@@ -35,44 +37,57 @@ local function playInternalAlarm(speakers)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function playTTSFile(speakers, value)
|
local function playTTSFile(speakers, value)
|
||||||
local ttsRoute = "https://ttsmp3.com/makemp3_new.php"
|
|
||||||
local fileName = "tts.dfpwm"
|
|
||||||
local encodedValue = textutils.urlEncode(value)
|
|
||||||
print("Encoded TTS value: " .. encodedValue)
|
|
||||||
local body = "msg=" .. encodedValue .. "&lang=Gwyneth&source=ttsmp3"
|
|
||||||
local headers = {
|
|
||||||
["Content-Type"] = "application/x-www-form-urlencoded"
|
|
||||||
}
|
|
||||||
|
|
||||||
print("Sending HTTP POST request")
|
local url = "https://music.madefor.cc/tts?text=" .. textutils.urlEncode(message)
|
||||||
local response = http.post({
|
local response, err = http.get { url = url, binary = true }
|
||||||
url = ttsRoute,
|
if not response then error(err, 0) end
|
||||||
method = "POST",
|
while true do
|
||||||
body = body,
|
local chunk = response.read(16 * 1024)
|
||||||
headers = headers,
|
if not chunk then break end
|
||||||
binary = false
|
|
||||||
})
|
|
||||||
|
|
||||||
print("HTTP POST request successful" )
|
local buffer = decoder(chunk)
|
||||||
local data = response.readAll()
|
while not speaker.playAudio(buffer) do
|
||||||
response.close()
|
os.pullEvent("speaker_audio_empty")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- local ttsRoute = "https://ttsmp3.com/makemp3_new.php"
|
||||||
|
-- local fileName = "tts.dfpwm"
|
||||||
|
-- local encodedValue = textutils.urlEncode(value)
|
||||||
|
-- print("Encoded TTS value: " .. encodedValue)
|
||||||
|
-- local body = "msg=" .. encodedValue .. "&lang=Gwyneth&source=ttsmp3"
|
||||||
|
-- local headers = {
|
||||||
|
-- ["Content-Type"] = "application/x-www-form-urlencoded"
|
||||||
|
-- }
|
||||||
|
|
||||||
local responseData = textutils.unserialiseJSON(data, { parse_null = true })
|
-- print("Sending HTTP POST request")
|
||||||
local soundRequest = http.get({
|
-- local response = http.post({
|
||||||
url = responseData.URL,
|
-- url = ttsRoute,
|
||||||
binary = true
|
-- method = "POST",
|
||||||
})
|
-- body = body,
|
||||||
|
-- headers = headers,
|
||||||
|
-- binary = false
|
||||||
|
-- })
|
||||||
|
|
||||||
local soundData = soundRequest.readAll()
|
-- print("HTTP POST request successful" )
|
||||||
soundRequest.close()
|
-- local data = response.readAll()
|
||||||
|
-- response.close()
|
||||||
|
|
||||||
local encodedData = encoder(soundData)
|
-- local responseData = textutils.unserialiseJSON(data, { parse_null = true })
|
||||||
|
-- local soundRequest = http.get({
|
||||||
|
-- url = responseData.URL,
|
||||||
|
-- binary = true
|
||||||
|
-- })
|
||||||
|
|
||||||
local file = fs.open(fileName, "w")
|
-- local soundData = soundRequest.readAll()
|
||||||
file.write(encodedData)
|
-- soundRequest.close()
|
||||||
file.close()
|
|
||||||
|
|
||||||
playSound(speakers, fileName)
|
-- local encodedData = encoder.encode(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