Urdu2English / app.py
Hira99's picture
Create app.py
1766fcc verified
raw
history blame
790 Bytes
import gradio as gr
from transformers import pipeline
# Load the conversational model
def load_chat_model():
return pipeline("text-generation", model="microsoft/DialoGPT-medium")
chat_model = load_chat_model()
# Define the chat function
def chat_with_bot(user_input):
# Generate response from the chatbot model
response = chat_model(user_input, max_length=100, num_return_sequences=1)
return response[0]['generated_text']
# Create the Gradio interface
iface = gr.Interface(
fn=chat_with_bot,
inputs=gr.inputs.Textbox(label="You:"),
outputs=gr.outputs.Textbox(label="Bot:"),
title="English Learning Chatbot",
description="Talk to the chatbot to practice English.",
theme="default"
)
# Launch the app
if __name__ == "__main__":
iface.launch()