Create working PoC of /sonos endpoint

This commit is contained in:
2020-07-07 21:18:38 +02:00
parent 160f4fea29
commit 01a19ccd02
5 changed files with 84 additions and 12 deletions

View File

@@ -1,17 +1,16 @@
return {
uri = "/{format}",
method = Method.POST,
accepts = Mime.JSON,
uri = "/tts.{ext}",
method = Method.GET,
consumer = function(request)
local body = json.decode(request.body)
local format = (request.params.format or "WAV"):upper()
local format = (request.path.ext or "wav"):upper()
local audioFormat = AudioFormat[format]
local mime = Mime[format]
local file = tts.sayToFile(body.text, body.language or "en", audioFormat)
local file = tts.sayToFile(request.query.phrase, request.query.lang or "en", audioFormat)
return {
mime = mime,
cached = false,
data = file
}
end