Spaces:
Runtime error
Runtime error
ayberkuckun
commited on
Commit
•
e63079d
1
Parent(s):
defe819
chunking
Browse files- app.py +9 -12
- latest_titanic.png +0 -0
app.py
CHANGED
@@ -11,38 +11,35 @@ fs = project.get_feature_store()
|
|
11 |
|
12 |
dataset_api = project.get_dataset_api()
|
13 |
|
14 |
-
dataset_api.download("Resources/titanic/images/latest_titanic.png", overwrite=True)
|
15 |
-
# dataset_api.download("Resources/images/deadImage.png", overwrite=True) # change link
|
16 |
-
|
17 |
|
18 |
# pipe = pipeline(model="fimster/whisper-small-sv-SE") # change model
|
19 |
# pipe = pipeline(model="ayberkuckun/whisper-small-sv-SE")
|
20 |
-
pipe = pipeline(model="openai/whisper-small")
|
21 |
|
22 |
|
23 |
def transcribe(url):
|
24 |
selected_video = YouTube(url)
|
25 |
|
26 |
try:
|
27 |
-
audio = selected_video.streams.filter(only_audio=True
|
28 |
except:
|
29 |
raise Exception("Can't find an mp4 audio.")
|
30 |
|
31 |
-
audio.download(filename="audio.
|
32 |
|
33 |
-
speech_array,
|
34 |
|
35 |
-
output = pipe(speech_array
|
36 |
|
37 |
return output["text"]
|
38 |
|
39 |
|
40 |
iface = gr.Interface(
|
41 |
-
fn=transcribe,
|
42 |
inputs=gr.Textbox("https://www.youtube.com/watch?v=n9g12Xm9UJM", label="Paste a YouTube video URL"),
|
43 |
-
outputs=[gr.Textbox(label="
|
44 |
-
|
45 |
-
# gr.Image("deadImage.png", elem_id="predicted-img", label="Model Scores")],
|
46 |
title="Whisper Small Swedish",
|
47 |
description="Realtime demo for Swedish speech recognition using a fine-tuned Whisper small model.",
|
48 |
allow_flagging="never"
|
|
|
11 |
|
12 |
dataset_api = project.get_dataset_api()
|
13 |
|
14 |
+
dataset_api.download("Resources/titanic/images/latest_titanic.png", overwrite=True) # change link
|
|
|
|
|
15 |
|
16 |
# pipe = pipeline(model="fimster/whisper-small-sv-SE") # change model
|
17 |
# pipe = pipeline(model="ayberkuckun/whisper-small-sv-SE")
|
18 |
+
pipe = pipeline(model="openai/whisper-small", task="automatic-speech-recognition", chunk_length_s=30)
|
19 |
|
20 |
|
21 |
def transcribe(url):
|
22 |
selected_video = YouTube(url)
|
23 |
|
24 |
try:
|
25 |
+
audio = selected_video.streams.filter(only_audio=True)[0]
|
26 |
except:
|
27 |
raise Exception("Can't find an mp4 audio.")
|
28 |
|
29 |
+
audio.download(filename="audio.mp3")
|
30 |
|
31 |
+
speech_array, _ = librosa.load("audio.mp3", sr=16000)
|
32 |
|
33 |
+
output = pipe(speech_array)
|
34 |
|
35 |
return output["text"]
|
36 |
|
37 |
|
38 |
iface = gr.Interface(
|
39 |
+
fn=transcribe,
|
40 |
inputs=gr.Textbox("https://www.youtube.com/watch?v=n9g12Xm9UJM", label="Paste a YouTube video URL"),
|
41 |
+
outputs=[gr.Textbox(label="Transcription"),
|
42 |
+
gr.Image("latest_titanic.png", label="Model Scores")],
|
|
|
43 |
title="Whisper Small Swedish",
|
44 |
description="Realtime demo for Swedish speech recognition using a fine-tuned Whisper small model.",
|
45 |
allow_flagging="never"
|
latest_titanic.png
DELETED
Binary file (45.7 kB)
|
|