antonbol's picture
Update app.py
8a7e5e8
from transformers import pipeline
import gradio as gr
from numpy import random
from PIL import Image
pipe = pipeline(model="fimster/whisper-small-sv-SE") # change to "your-username/the-name-you-picked"
images = ["katt", "melon", "banan"]
image = random.choice(images)
def transcribe(audio, img):
text = pipe(audio)["text"]
text = text.replace("!", "")
text = text.replace(".", "")
text = text.replace(",", "")
returntext = ""
if text.lower() != image.lower():
returntext = "Du svarade fel, ditt svar var: " + text + ", rätt svar var: " + image
else:
returntext = "Du hade rätt, svaret var: " + image
return returntext
iface = gr.Interface(
fn=transcribe,
inputs=[gr.Audio(source="microphone", type="filepath"), gr.Image("./images/" + image + ".jpeg")],
outputs="text",
title="Whisper Small Swedish",
description="Proof of concept for Duolingo-type gamified language learning. Record and say what the thing in the picture is, then click submit and the model will check if you were correct!",
)
iface.launch()