updated
This commit is contained in:
@@ -9,12 +9,12 @@ local function getFileName(name)
|
||||
return fullFile
|
||||
end
|
||||
|
||||
local function randomFileName(extension)
|
||||
local function randomFileName()
|
||||
local name = ""
|
||||
for i = 1, 12 do
|
||||
name = name .. string.char(math.random(97, 122)) -- a–z
|
||||
end
|
||||
return name .. (extension or "")
|
||||
return name
|
||||
end
|
||||
|
||||
local function playSound(speaker, fileName)
|
||||
@@ -45,14 +45,16 @@ local function playTTSFile(speakers, value)
|
||||
local message = textutils.urlEncode(value)
|
||||
local url = "http://api.astrocore.space/api/TextToSpeech?message=" .. message
|
||||
local response, err = http.get { url = url, binary = true }
|
||||
local name = randomFileName(".dfpwm")
|
||||
local name = randomFileName()
|
||||
local fileName = name .. ".dfpwm"
|
||||
|
||||
local fileData = response.readAll()
|
||||
local file = fs.open(name,"w")
|
||||
local file = fs.open(fileName,"w")
|
||||
file.write(fileData)
|
||||
file.close()
|
||||
response.close()
|
||||
playSound(speakers, name)
|
||||
shell.execute("rm", name)
|
||||
shell.execute("rm", fileName)
|
||||
end
|
||||
|
||||
local function createSoundFile(fileName)
|
||||
|
||||
Reference in New Issue
Block a user