Spaces:
Running
on
Zero
Running
on
Zero
Ankush Rana
commited on
Commit
路
5208902
1
Parent(s):
94ca74e
fix bug wav audio int8
Browse files- app.py +7 -21
- requirements.txt +1 -0
app.py
CHANGED
|
@@ -4,6 +4,7 @@ import gradio as gr
|
|
| 4 |
import yt_dlp as youtube_dl
|
| 5 |
from transformers import pipeline
|
| 6 |
from transformers.pipelines.audio_utils import ffmpeg_read
|
|
|
|
| 7 |
|
| 8 |
import tempfile
|
| 9 |
import os
|
|
@@ -26,11 +27,11 @@ def transcribe(inputs, task):
|
|
| 26 |
raise gr.Error("Cap fitxer d'脿udio introduit! Si us plau pengeu un fitxer "\
|
| 27 |
"o enregistreu un 脿udio abans d'enviar la vostra sol路licitud")
|
| 28 |
|
|
|
|
| 29 |
text = pipe(inputs, batch_size=BATCH_SIZE, generate_kwargs={"task": task}, return_timestamps=True)["text"]
|
| 30 |
return text
|
| 31 |
|
| 32 |
|
| 33 |
-
demo = gr.Blocks()
|
| 34 |
description_string = "Transcripci贸 automatica de micr貌fon o de fitxers d'audio.\n Aquest demostrador est谩 desenvolupat per"\
|
| 35 |
" comprovar els models de reconeixement de parla pels m贸bils. Per ara utilitza el checkpoint "\
|
| 36 |
f"[{MODEL_NAME}](https://huggingface.co/{MODEL_NAME}) i la llibreria de 馃 Transformers per la transcripci贸."
|
|
@@ -38,33 +39,18 @@ description_string = "Transcripci贸 automatica de micr貌fon o de fitxers d'audio
|
|
| 38 |
file_transcribe = gr.Interface(
|
| 39 |
fn=transcribe,
|
| 40 |
inputs=[
|
| 41 |
-
gr.
|
| 42 |
-
gr.
|
| 43 |
],
|
| 44 |
outputs="text",
|
| 45 |
-
layout="horizontal",
|
| 46 |
-
theme="huggingface",
|
| 47 |
title="Transcripci贸 autom脿tica d'脿udio",
|
| 48 |
description=(description_string),
|
| 49 |
allow_flagging="never",
|
| 50 |
)
|
| 51 |
|
| 52 |
-
mf_transcribe = gr.Interface(
|
| 53 |
-
fn=transcribe,
|
| 54 |
-
inputs=[
|
| 55 |
-
gr.inputs.Audio(source="microphone", type="filepath", optional=True),
|
| 56 |
-
gr.inputs.Radio(["transcribe", "translate"], label="Task", default="transcribe"),
|
| 57 |
-
],
|
| 58 |
-
outputs="text",
|
| 59 |
-
layout="horizontal",
|
| 60 |
-
theme="huggingface",
|
| 61 |
-
title="Whisper Large V3: Transcribe Audio",
|
| 62 |
-
description=(description_string),
|
| 63 |
-
allow_flagging="never",
|
| 64 |
-
)
|
| 65 |
|
| 66 |
-
|
| 67 |
-
gr.TabbedInterface([file_transcribe, mf_transcribe], ["Fitxer d'脌udio", "Micr貌fon"])
|
| 68 |
|
| 69 |
-
|
|
|
|
| 70 |
|
|
|
|
| 4 |
import yt_dlp as youtube_dl
|
| 5 |
from transformers import pipeline
|
| 6 |
from transformers.pipelines.audio_utils import ffmpeg_read
|
| 7 |
+
from AinaTheme import theme
|
| 8 |
|
| 9 |
import tempfile
|
| 10 |
import os
|
|
|
|
| 27 |
raise gr.Error("Cap fitxer d'脿udio introduit! Si us plau pengeu un fitxer "\
|
| 28 |
"o enregistreu un 脿udio abans d'enviar la vostra sol路licitud")
|
| 29 |
|
| 30 |
+
|
| 31 |
text = pipe(inputs, batch_size=BATCH_SIZE, generate_kwargs={"task": task}, return_timestamps=True)["text"]
|
| 32 |
return text
|
| 33 |
|
| 34 |
|
|
|
|
| 35 |
description_string = "Transcripci贸 automatica de micr貌fon o de fitxers d'audio.\n Aquest demostrador est谩 desenvolupat per"\
|
| 36 |
" comprovar els models de reconeixement de parla pels m贸bils. Per ara utilitza el checkpoint "\
|
| 37 |
f"[{MODEL_NAME}](https://huggingface.co/{MODEL_NAME}) i la llibreria de 馃 Transformers per la transcripci贸."
|
|
|
|
| 39 |
file_transcribe = gr.Interface(
|
| 40 |
fn=transcribe,
|
| 41 |
inputs=[
|
| 42 |
+
gr.Audio(sources=["upload", "microphone"], type="filepath", label="Audio"),
|
| 43 |
+
gr.Radio(["transcribe", "translate"], label="Task", value="transcribe"),
|
| 44 |
],
|
| 45 |
outputs="text",
|
|
|
|
|
|
|
| 46 |
title="Transcripci贸 autom脿tica d'脿udio",
|
| 47 |
description=(description_string),
|
| 48 |
allow_flagging="never",
|
| 49 |
)
|
| 50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
+
demo = gr.TabbedInterface([file_transcribe], ["Fitxer"], theme=theme)
|
|
|
|
| 53 |
|
| 54 |
+
if __name__ == "__main__":
|
| 55 |
+
demo.launch()
|
| 56 |
|
requirements.txt
CHANGED
|
@@ -1,3 +1,4 @@
|
|
| 1 |
git+https://github.com/huggingface/transformers
|
| 2 |
torch
|
| 3 |
yt-dlp
|
|
|
|
|
|
| 1 |
git+https://github.com/huggingface/transformers
|
| 2 |
torch
|
| 3 |
yt-dlp
|
| 4 |
+
gradio==4.20.0
|