Spaces:
Build error
Build error
Commit
·
d91fab7
1
Parent(s):
7d11cd2
reduce input to only audio
Browse files
app.py
CHANGED
|
@@ -2,28 +2,17 @@ from transformers import pipeline
|
|
| 2 |
import gradio as gr
|
| 3 |
from numpy import random
|
| 4 |
from PIL import Image
|
| 5 |
-
pipe = pipeline(model="
|
| 6 |
-
images = ["katt", "melon", "hund", "banan"]
|
| 7 |
-
image = random.choice(images)
|
| 8 |
|
| 9 |
def transcribe(audio, img):
|
| 10 |
text = pipe(audio)["text"]
|
| 11 |
-
|
| 12 |
-
text = text.replace(".", "")
|
| 13 |
-
text = text.replace(",", "")
|
| 14 |
-
returntext = ""
|
| 15 |
-
if text.lower() != image.lower():
|
| 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"),
|
| 24 |
outputs="text",
|
| 25 |
-
title="
|
| 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 |
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
from numpy import random
|
| 4 |
from PIL import Image
|
| 5 |
+
pipe = pipeline(model="openai/whisper-medium") # change to "your-username/the-name-you-picked"
|
|
|
|
|
|
|
| 6 |
|
| 7 |
def transcribe(audio, img):
|
| 8 |
text = pipe(audio)["text"]
|
| 9 |
+
return text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
iface = gr.Interface(
|
| 12 |
fn=transcribe,
|
| 13 |
+
inputs=[gr.Audio(source="microphone", type="filepath"),],
|
| 14 |
outputs="text",
|
| 15 |
+
title="Make transcription of audio",
|
|
|
|
| 16 |
)
|
| 17 |
|
| 18 |
|