antonbol commited on
Commit
9b36fa7
·
1 Parent(s): e7c815d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -2
app.py CHANGED
@@ -4,10 +4,20 @@ from numpy import random
4
  pipe = pipeline(model="fimster/whisper-small-sv-SE") # change to "your-username/the-name-you-picked"
5
  images = ["katt", "melon", "hund", "banan"]
6
  image = random.choice(images)
7
- query_image = gr.Image("./images/" + image + ".jpeg")
 
 
 
 
 
8
  def transcribe(audio):
9
  text = pipe(audio)["text"]
10
- return text
 
 
 
 
 
11
 
12
  iface = gr.Interface(
13
  fn=transcribe,
 
4
  pipe = pipeline(model="fimster/whisper-small-sv-SE") # change to "your-username/the-name-you-picked"
5
  images = ["katt", "melon", "hund", "banan"]
6
  image = random.choice(images)
7
+ query_image = Image.open("./images/" + image + ".jpeg")
8
+
9
+ with gr.Blocks as demo:
10
+ with gr.row():
11
+ gr.Label("Vad är detta? Spela in ditt svar med inspelningsknappen!")
12
+ input_img = gr.Image(query_image)
13
  def transcribe(audio):
14
  text = pipe(audio)["text"]
15
+ returntext = ""
16
+ if text.lower() != image.lower():
17
+ returntext = "Du svarade fel, ditt svar var: " + text + ", rätt svar var: " + image
18
+ else:
19
+ returntext = "Du hade rätt, svaret var: " + image
20
+ return returntext
21
 
22
  iface = gr.Interface(
23
  fn=transcribe,