2015-06-06 22:16:11 +02:00
|
|
|
local function run(msg, matches)
|
|
|
|
local receiver = get_receiver(msg)
|
2016-04-07 19:46:11 +02:00
|
|
|
local text = matches[1]
|
2015-09-07 18:12:27 +02:00
|
|
|
|
2015-06-06 22:16:11 +02:00
|
|
|
local text = string.gsub(text, "ä", "ae")
|
|
|
|
local text = string.gsub(text, "Ä", "Ae")
|
|
|
|
local text = string.gsub(text, "ö", "oe")
|
|
|
|
local text = string.gsub(text, "Ö", "Oe")
|
|
|
|
local text = string.gsub(text, "ü", "ue")
|
|
|
|
local text = string.gsub(text, "Ü", "Ue")
|
|
|
|
local text = string.gsub(text, "ß", "ss")
|
2015-09-07 18:12:27 +02:00
|
|
|
local text = string.gsub(text, "%&", "und")
|
2016-04-07 19:46:11 +02:00
|
|
|
local text = string.gsub(text, " ", "+")
|
|
|
|
|
|
|
|
local url = "http://tts.baidu.com/text2audio?lan=en&ie=UTF-8&text="..text
|
2015-11-12 17:42:03 +01:00
|
|
|
local file = download_to_file(url, text..'.mp3')
|
2015-09-07 18:12:27 +02:00
|
|
|
if file == nil then
|
2015-11-12 17:42:03 +01:00
|
|
|
return "Ein Fehler ist aufgetreten, besuche die URL eventuell direkt?\n"..url
|
2015-09-07 18:12:27 +02:00
|
|
|
end
|
2015-06-06 22:16:11 +02:00
|
|
|
local cb_extra = {file_path=file}
|
|
|
|
send_audio(receiver, file, rmtmp_cb, cb_extra)
|
|
|
|
end
|
|
|
|
|
|
|
|
return {
|
2015-09-07 18:12:27 +02:00
|
|
|
description = "Text-To-Speech",
|
|
|
|
usage = {
|
2016-04-07 19:46:11 +02:00
|
|
|
"/tts [Text]: Sendet Sprachnachricht mit dem Text"
|
2015-09-07 18:12:27 +02:00
|
|
|
},
|
|
|
|
patterns = {
|
2016-04-07 19:46:11 +02:00
|
|
|
"^/tts (.+)$"
|
2015-09-07 18:12:27 +02:00
|
|
|
},
|
|
|
|
run = run
|
2015-06-06 22:16:11 +02:00
|
|
|
}
|