From 6427ddc65606a15d83978a7599780a8b159142b6 Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Sat, 9 Oct 2021 22:33:54 +0700 Subject: [PATCH] deleted --- bot/tts.py | 42 ------------------------------------------ 1 file changed, 42 deletions(-) delete mode 100644 bot/tts.py diff --git a/bot/tts.py b/bot/tts.py deleted file mode 100644 index 2b96ff8..0000000 --- a/bot/tts.py +++ /dev/null @@ -1,42 +0,0 @@ -# text to speech funtion -# ported from juvia group bot / module / tts.py -# Copyright (C) 2021 Veez Project - -import traceback -from asyncio import get_running_loop -from io import BytesIO - -from googletrans import Translator -from gtts import gTTS -from pyrogram import filters, Client -from pyrogram.types import Message - - -def convert(text): - audio = BytesIO() - i = Translator().translate(text, dest="en") - lang = i.src - tts = gTTS(text, lang=lang) - audio.name = lang + ".mp3" - tts.write_to_fp(audio) - return audio - - -@Client.on_message(filters.command("tts")) -async def text_to_speech(_, message: Message): - if not message.reply_to_message: - return await message.reply_text("💡 reply to some text...") - if not message.reply_to_message.text: - return await message.reply_text("💡 reply to some text...") - m = await message.reply_text("🔁 processing...") - text = message.reply_to_message.text - try: - loop = get_running_loop() - audio = await loop.run_in_executor(None, convert, text) - await message.reply_audio(audio) - await m.delete() - audio.close() - except Exception as e: - await m.edit(str(e)) - es = traceback.format_exc() - print(es)