Create POST /{format} endpoint (file.lua)

This commit is contained in:
2020-07-06 20:59:23 +02:00
parent abe02d4f02
commit fde05671d3
5 changed files with 45 additions and 5 deletions

View File

@@ -0,0 +1,18 @@
return {
uri = "/{format}",
method = Method.POST,
accepts = Mime.JSON,
consumer = function(request)
local body = json.decode(request.body)
local format = (request.params.format or "WAV"):upper()
local audioFormat = AudioFormat[format]
local mime = Mime[format]
local file = tts.sayToFile(body.text, body.language or "en", audioFormat)
return {
mime = mime,
data = file
}
end
}