Downloads · 30 days
0
Ankammarao/Telugu_to_English_Translation_Bot
Telugu_to_English_Translation_Bot is a machine learning model from Ankammarao. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as other.
from telegram import Update from telegram.ext import Updater, CommandHandler, MessageHandler, Filters, CallbackContext from googletrans import Translator
Downloads · 30 days
0
Access
Public
Updated Jul 17, 2023
Repo size
—
Likes
0
Public
Click a slice to open those files.
Other1.6 KB · 58%
From the Hugging Face model README
from telegram import Update from telegram.ext import Updater, CommandHandler, MessageHandler, Filters, CallbackContext from googletrans import Translator
BOT_TOKEN = '6064527106:AAG_cnj0EprbaEpcUXnGfqvZ7zcKkESbM-8'
def start(update: Update, _: CallbackContext): update.message.reply_text("Welcome! I can help you translate Telugu to English. Just send me any Telugu text!")
def translate_telugu_to_english(text): translator = Translator() result = translator.translate(text, src='te', dest='en') return result.text
def translate_message(update: Update, _: CallbackContext): message = update.message.text translation = translate_telugu_to_english(message) update.message.reply_text(f"English Translation: {translation}")
def main(): updater = Updater(BOT_TOKEN)
dispatcher = updater.dispatcher
dispatcher.add_handler(CommandHandler("start", start))
dispatcher.add_handler(MessageHandler(Filters.text & ~Filters.command, translate_message))
updater.start_polling()
print("Bot started polling for messages...")
updater.idle()
if name == "main": main()