fixed tts.lua

thx @Brawl345
This commit is contained in:
Akamaru 2015-09-07 18:12:27 +02:00
parent a0307c84b3
commit ad81e3b55e

View File

@ -15,7 +15,9 @@ local function run(msg, matches)
text,b = text:gsub('^+','+')
text = text:trim()
end
local text = string.gsub(text, "%s+", "+")
-- because everyone loves german umlauts, right? :3
local text = string.gsub(text, "ä", "ae")
local text = string.gsub(text, "Ä", "Ae")
local text = string.gsub(text, "ö", "oe")
@ -23,15 +25,22 @@ local function run(msg, matches)
local text = string.gsub(text, "ü", "ue")
local text = string.gsub(text, "Ü", "Ue")
local text = string.gsub(text, "ß", "ss")
local url = "http://translate.google.com/translate_tts?tl="..lang.."&q=" .. text
local text = string.gsub(text, "%&", "und")
local url = "http://translate.google.com/translate_tts?tl="..lang.."&q="..text.."&ie=UTF-8&total=1&idx=0&client=t"
local file = download_to_file(url)
if file == nil then
return "Google hat den Zugriff auf die API geblockt. URL: "..url
end
local cb_extra = {file_path=file}
send_audio(receiver, file, rmtmp_cb, cb_extra)
end
return {
description = "Text To Speech",
usage = "/tts [whatever]",
description = "Text-To-Speech",
usage = {
"/tts [Text]: Sendet Sprachnachricht mit dem Text",
"/tts(Sprache) [Text]: Sendet Sprachnachricht in der Sprache mit dem Text (bspw. !ttsen Hello)"
},
patterns = {
"^/tts (.+)$",
"^/tts(%w+) (.+)$"