This repository has been archived on 2021-04-24. You can view files and clone it, but cannot push or open issues or pull requests.
Mikubot/plugins/tts.lua
Akamaru 2c8c66cce3 tts verwendet nun Baidu (nur Englisch)
Shimakaze zum NSFW-Rpic-Plugin hinzugefügt
2016-04-07 19:46:11 +02:00

33 lines
993 B
Lua

local function run(msg, matches)
local receiver = get_receiver(msg)
local text = matches[1]
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")
local text = string.gsub(text, "%&", "und")
local text = string.gsub(text, " ", "+")
local url = "http://tts.baidu.com/text2audio?lan=en&ie=UTF-8&text="..text
local file = download_to_file(url, text..'.mp3')
if file == nil then
return "Ein Fehler ist aufgetreten, besuche die URL eventuell direkt?\n"..url
end
local cb_extra = {file_path=file}
send_audio(receiver, file, rmtmp_cb, cb_extra)
end
return {
description = "Text-To-Speech",
usage = {
"/tts [Text]: Sendet Sprachnachricht mit dem Text"
},
patterns = {
"^/tts (.+)$"
},
run = run
}