Spaces:
Runtime error
Runtime error
Edward Nagy
commited on
Update transcribe function to handle input data
Browse files
app.py
CHANGED
@@ -7,13 +7,16 @@ import os
|
|
7 |
# pipe = pipeline(model="esnagy/whisper-small-hu")
|
8 |
|
9 |
def transcribe_audio(audio_file):
|
10 |
-
text = "
|
11 |
# text = pipe(audio_file)["text"]
|
12 |
os.remove(audio_file) # Remove temporary audio file
|
13 |
return text
|
14 |
|
15 |
-
def transcribe(
|
16 |
-
if
|
|
|
|
|
|
|
17 |
# Download the video from the URL
|
18 |
video_filename = "temp_video.mp4"
|
19 |
with open(video_filename, 'wb') as f:
|
@@ -35,24 +38,15 @@ def transcribe(video_url, audio=None):
|
|
35 |
|
36 |
return text
|
37 |
|
38 |
-
|
39 |
-
return transcribe_audio(audio)
|
40 |
-
|
41 |
-
iface_video = gr.Interface(
|
42 |
-
fn=transcribe,
|
43 |
-
inputs=gr.Textbox(label="Enter video URL", placeholder="Or leave empty to use microphone"),
|
44 |
-
outputs="text",
|
45 |
-
title="Whisper Small Hungarian - Video",
|
46 |
-
description="Realtime demo for Hungarian speech recognition using a fine-tuned Whisper small model. Enter a video URL to transcribe its audio."
|
47 |
-
)
|
48 |
-
|
49 |
-
iface_audio = gr.Interface(
|
50 |
fn=transcribe,
|
51 |
-
inputs=
|
52 |
-
|
53 |
-
|
54 |
-
|
|
|
|
|
|
|
55 |
)
|
56 |
|
57 |
-
|
58 |
-
iface_audio.launch(share=True)
|
|
|
7 |
# pipe = pipeline(model="esnagy/whisper-small-hu")
|
8 |
|
9 |
def transcribe_audio(audio_file):
|
10 |
+
text = "Text text"
|
11 |
# text = pipe(audio_file)["text"]
|
12 |
os.remove(audio_file) # Remove temporary audio file
|
13 |
return text
|
14 |
|
15 |
+
def transcribe(input_data):
|
16 |
+
if input_data["audio"]:
|
17 |
+
return transcribe_audio(input_data["audio"].name)
|
18 |
+
elif input_data["video_url"]:
|
19 |
+
video_url = input_data["video_url"]
|
20 |
# Download the video from the URL
|
21 |
video_filename = "temp_video.mp4"
|
22 |
with open(video_filename, 'wb') as f:
|
|
|
38 |
|
39 |
return text
|
40 |
|
41 |
+
iface = gr.Interface(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
fn=transcribe,
|
43 |
+
inputs=[
|
44 |
+
gr.Input("text", label="Enter video URL", name="video_url", placeholder="Or leave empty to use microphone"),
|
45 |
+
gr.Input("audio", label="Or record your voice", name="audio", source="microphone")
|
46 |
+
],
|
47 |
+
outputs=gr.Output("text"),
|
48 |
+
title="Whisper Small Hungarian",
|
49 |
+
description="Realtime demo for Hungarian speech recognition using a fine-tuned Whisper small model. Enter a video URL or record your voice to transcribe."
|
50 |
)
|
51 |
|
52 |
+
iface.launch()
|
|