Actor_game / app.py
Last commit not found
raw
history blame
1.05 kB
from transformers import pipeline
import gradio as gr
import random
pipe = pipeline("text-classification", model="muhnatha/distilbert-base-uncased-game")
question = {
"sadness": "Be a student who just had a bad grade",
"joy": "Be a football player who just won the world cup",
"love": "Be a teenager who has a crush but she can only talk to her friend",
"anger": "Be a student who angry because he was bullied",
"fear": "Be a grandpa who tries to run away because there is an alien in his farm",
"surprise": "Be a child who just got a birthday surprise"
}
task = random.choice(list(question.items()))
def actor_game(text, emotion):
pred_emotion = pipe(text)
if pred_emotion[0]['label'] == emotion:
return "YOU WON"
else:
return "YOU LOSE"
iface = gr.Interface(
fn=actor_game,
inputs=[gr.Textbox(label="Your dialog"),
gr.Textbox(task[0],visible=False)],
outputs=[gr.Textbox(label=task[1])],
title="Be an Actor",
description="Type your dialog",
)
iface.launch()