Spaces:
Running
Running
SevenhuijsenM
commited on
Commit
•
167c051
1
Parent(s):
932a9e1
Attempt for radio
Browse files
app.py
CHANGED
@@ -47,8 +47,25 @@ def audio_to_text(audio):
|
|
47 |
print(text)
|
48 |
return text
|
49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
iface_video_url = gr.Interface(
|
51 |
-
fn=download_audio,
|
52 |
inputs="text",
|
53 |
outputs="text",
|
54 |
title="Whisper Small Dutch - Use a YouTube URL",
|
@@ -56,7 +73,7 @@ iface_video_url = gr.Interface(
|
|
56 |
)
|
57 |
|
58 |
iface_audio = gr.Interface(
|
59 |
-
fn=audio_to_text,
|
60 |
inputs=gr.Audio(sources=["microphone"], type="filepath"),
|
61 |
outputs="text",
|
62 |
title="Whisper Small Dutch - Use your microphone",
|
@@ -64,15 +81,14 @@ iface_audio = gr.Interface(
|
|
64 |
)
|
65 |
|
66 |
iface_radio = gr.Interface(
|
67 |
-
fn=
|
68 |
-
inputs=
|
69 |
outputs="text",
|
70 |
-
title="Whisper Small Dutch - Use a radio URL"
|
71 |
-
description="Demo for dutch speech recognition using a fine-tuned Whisper small model.
|
72 |
)
|
73 |
|
74 |
-
|
75 |
-
app = gr.TabbedInterface([iface_audio, iface_video_url], ["Audio to text", "Video to text"])
|
76 |
|
77 |
if __name__ == "__main__":
|
78 |
app.launch()
|
|
|
47 |
print(text)
|
48 |
return text
|
49 |
|
50 |
+
def radio_to_text(radio_url):
|
51 |
+
# A radio livestream
|
52 |
+
stream_url = radio_url
|
53 |
+
|
54 |
+
r = requests.get(stream_url, stream=True)
|
55 |
+
|
56 |
+
with open('stream.mp3', 'wb') as f:
|
57 |
+
try:
|
58 |
+
for block in r.iter_content(1024):
|
59 |
+
f.write(block)
|
60 |
+
except KeyboardInterrupt:
|
61 |
+
pass
|
62 |
+
|
63 |
+
text = pipe("stream.mp3")["text"]
|
64 |
+
print(text)
|
65 |
+
return text
|
66 |
+
|
67 |
iface_video_url = gr.Interface(
|
68 |
+
fn=download_audio,
|
69 |
inputs="text",
|
70 |
outputs="text",
|
71 |
title="Whisper Small Dutch - Use a YouTube URL",
|
|
|
73 |
)
|
74 |
|
75 |
iface_audio = gr.Interface(
|
76 |
+
fn=audio_to_text,
|
77 |
inputs=gr.Audio(sources=["microphone"], type="filepath"),
|
78 |
outputs="text",
|
79 |
title="Whisper Small Dutch - Use your microphone",
|
|
|
81 |
)
|
82 |
|
83 |
iface_radio = gr.Interface(
|
84 |
+
fn=radio_to_text,
|
85 |
+
inputs="text",
|
86 |
outputs="text",
|
87 |
+
title="Whisper Small Dutch - Use a radio URL",
|
88 |
+
description="Demo for dutch speech recognition using a fine-tuned Whisper small model.",
|
89 |
)
|
90 |
|
91 |
+
app = gr.TabbedInterface([iface_audio, iface_video_url, iface_radio], ["Audio to text", "Video to text", "Radio to text"])
|
|
|
92 |
|
93 |
if __name__ == "__main__":
|
94 |
app.launch()
|