Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,7 @@ from numpy import random
|
|
4 |
from PIL import Image
|
5 |
pipe = pipeline(model="fimster/whisper-small-sv-SE") # change to "your-username/the-name-you-picked"
|
6 |
images = ["katt", "melon", "hund", "banan"]
|
7 |
-
image = random.choice(images)
|
8 |
|
9 |
def transcribe(audio, img):
|
10 |
text = pipe(audio)["text"]
|
@@ -16,17 +16,14 @@ def transcribe(audio, img):
|
|
16 |
returntext = "Du svarade fel, ditt svar var: " + text + ", rätt svar var: " + image
|
17 |
else:
|
18 |
returntext = "Du hade rätt, svaret var: " + image
|
19 |
-
global image
|
20 |
-
image = random.choice(images)
|
21 |
return returntext
|
22 |
|
23 |
iface = gr.Interface(
|
24 |
fn=transcribe,
|
25 |
-
inputs=[gr.Audio(source="microphone", type="filepath"), gr.Image("./images/" +
|
26 |
outputs="text",
|
27 |
title="Whisper Small Swedish",
|
28 |
description="Demo of whisper small ASR fine tuned to swedish. Vad är det på bilden? Spela in ditt svar genom att trycka på inspelningsknappen!",
|
29 |
)
|
30 |
|
31 |
-
|
32 |
-
iface.launch()
|
|
|
4 |
from PIL import Image
|
5 |
pipe = pipeline(model="fimster/whisper-small-sv-SE") # change to "your-username/the-name-you-picked"
|
6 |
images = ["katt", "melon", "hund", "banan"]
|
7 |
+
# image = random.choice(images)
|
8 |
|
9 |
def transcribe(audio, img):
|
10 |
text = pipe(audio)["text"]
|
|
|
16 |
returntext = "Du svarade fel, ditt svar var: " + text + ", rätt svar var: " + image
|
17 |
else:
|
18 |
returntext = "Du hade rätt, svaret var: " + image
|
|
|
|
|
19 |
return returntext
|
20 |
|
21 |
iface = gr.Interface(
|
22 |
fn=transcribe,
|
23 |
+
inputs=[gr.Audio(source="microphone", type="filepath"), gr.Image("./images/" + random.choice(images) + ".jpeg")],
|
24 |
outputs="text",
|
25 |
title="Whisper Small Swedish",
|
26 |
description="Demo of whisper small ASR fine tuned to swedish. Vad är det på bilden? Spela in ditt svar genom att trycka på inspelningsknappen!",
|
27 |
)
|
28 |
|
29 |
+
iface.launch()
|
|