Create POST /{format} endpoint (file.lua)
This commit is contained in:
18
app/src/main/res/raw/file.lua
Normal file
18
app/src/main/res/raw/file.lua
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user