async def google_tts(self, ctx, text): await ctx.send("if you have a lot of text it may take a bit") mp3_fp = io.BytesIO() tts = aiogtts.aiogTTS() await tts.write_to_fp(text, mp3_fp, lang="en") mp3_fp.seek(0) file = discord.File(mp3_fp, "tts.mp3") await ctx.send(file=file)
async def tts(self, ctx: Context, *, text): """ Text to speech! Takes your text and converts to audio and sends it to the channel """ async with ctx.channel.typing(): aiogtts = aiogTTS() buffer = BytesIO() await aiogtts.write_to_fp(text, buffer, lang="en") buffer.seek(0) file = discord.File(buffer, f"{ctx.author.name}-tts.mp3") await ctx.send(file=file)
def __init__(self, bot): self.bot = bot self.tts = aiogTTS()
from vk import VK from vk.utils import TaskManager from vk.bot_framework import Dispatcher from vk.constants import JSON_LIBRARY import asyncio import logging from io import BytesIO from aiogtts import aiogTTS import aiohttp with open("config.json", "r") as config: config = JSON_LIBRARY.load(config) logging.basicConfig(level=config["logging_level"], format="%(asctime)s - %(levelname)s:: %(message)s", handlers=[ logging.FileHandler("{0}/{1}".format( config["logging_path"], config["logging_file"])), logging.StreamHandler() ]) vk = VK(config["token"]) task_manager = TaskManager(vk.loop) dp = Dispatcher(vk, config["group_id"]) api = vk.get_api() aiogtts = aiogTTS()
else: parsed = BeautifulSoup(response.text, 'html.parser') main = parsed.body.find('main') definition = main.find('p').get_text() example = main.find('blockquote') example = f'\n\nPrzyklad/y: { example.get_text() }' if example else '' msg = f'{ arg }\nDefinicja: { definition }{ example }' return Response(event, text=msg) # constants __tts_gtts = aiogTTS() @MessageEventDispatcher.register() async def tts(event: fbchat.MessageEvent) -> Response: """ Użycie: {command} (lang=kod) <tekst> Zwraca: wiadomość głosową text-to-speech Informacje: spis kodów języków na wiertarbot.pl/tts Przykład: {command} lang=en hello world """