Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,43 +1,29 @@
|
|
1 |
-
# from transformers import pipeline
|
2 |
-
# import gradio as gr
|
3 |
-
|
4 |
-
# pipe = pipeline(model="kk90ujhun/whisper-small-zh") # change to "your-username/the-name-you-picked"
|
5 |
-
|
6 |
-
# def transcribe(audio):
|
7 |
-
# text = pipe(audio)["text"]
|
8 |
-
# return text
|
9 |
-
|
10 |
-
# iface = gr.Interface(
|
11 |
-
# fn=transcribe,
|
12 |
-
# inputs=gr.Audio(source="microphone", type="filepath"),
|
13 |
-
# outputs="text",
|
14 |
-
# title="Whisper Small Chinese",
|
15 |
-
# description="Realtime demo for Chinese speech recognition using a fine-tuned Whisper small model.",
|
16 |
-
# )
|
17 |
-
|
18 |
-
# iface.launch()
|
19 |
-
|
20 |
from transformers import pipeline
|
21 |
-
from pytube import YouTube
|
22 |
import gradio as gr
|
|
|
23 |
|
24 |
-
pipe = pipeline(model="kk90ujhun/whisper-small-zh")
|
25 |
|
26 |
|
27 |
-
def transcribe(
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
|
|
34 |
|
35 |
iface = gr.Interface(
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
41 |
)
|
42 |
|
|
|
43 |
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from transformers import pipeline
|
|
|
2 |
import gradio as gr
|
3 |
+
import pytube
|
4 |
|
5 |
+
pipe = pipeline(model="kk90ujhun/whisper-small-zh")
|
6 |
|
7 |
|
8 |
+
def transcribe(my_url,audio):
|
9 |
+
if my_url:
|
10 |
+
my_audio = pytube.YouTube(my_url).streams.filter(subtype='mp4').first().download()
|
11 |
+
text = pipe(my_audio)["text"]
|
12 |
+
return text
|
13 |
+
else:
|
14 |
+
text = pipe(audio)["text"]
|
15 |
+
return text
|
16 |
|
17 |
iface = gr.Interface(
|
18 |
+
fn=transcribe,
|
19 |
+
inputs=[
|
20 |
+
gr.Textbox(label="Enter your YouTube URL:"),
|
21 |
+
gr.Audio(label="Speak to your microphone",source="microphone", type="filepath"),
|
22 |
+
], #
|
23 |
+
outputs="text",
|
24 |
+
title="Whisper Small Chinese",
|
25 |
+
description="Realtime demo for Chinese speech recognition using a fine-tuned Whisper small model.",
|
26 |
)
|
27 |
|
28 |
+
|
29 |
iface.launch()
|