Spaces:
Sleeping
Sleeping
Commit
·
108107c
1
Parent(s):
5eed5b4
feat: gradio app
Browse files- .gitattributes +2 -0
- .gitignore +4 -0
- app.py +49 -0
- examples/audio1.mp3 +3 -0
- examples/audio2.mp3 +3 -0
- requirements.txt +2 -0
.gitattributes
CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
*.wav filter=lfs diff=lfs merge=lfs -text
|
37 |
+
*.mp3 filter=lfs diff=lfs merge=lfs -text
|
.gitignore
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
__pycache__
|
2 |
+
*.pyc
|
3 |
+
.gradio
|
4 |
+
.DS_Store
|
app.py
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from huggingface_hub import InferenceClient
|
3 |
+
|
4 |
+
model_id = "JacobLinCool/whisper-large-v3-turbo-common_voice_16_1-zh-TW-2"
|
5 |
+
client = InferenceClient(model_id)
|
6 |
+
|
7 |
+
|
8 |
+
def transcribe_audio(audio: str) -> str:
|
9 |
+
out = client.automatic_speech_recognition(audio)
|
10 |
+
return out.text
|
11 |
+
|
12 |
+
|
13 |
+
with gr.Blocks() as demo:
|
14 |
+
gr.Markdown("# TWASR: Chinese (Taiwan) Automatic Speech Recognition.")
|
15 |
+
gr.Markdown("Upload an audio file or record your voice to transcribe it to text.")
|
16 |
+
gr.Markdown(
|
17 |
+
"First load may take a while to initialize the model, following requests will be faster."
|
18 |
+
)
|
19 |
+
|
20 |
+
with gr.Row():
|
21 |
+
audio_input = gr.Audio(
|
22 |
+
label="Audio", type="filepath", show_download_button=True
|
23 |
+
)
|
24 |
+
text_output = gr.Textbox(label="Transcription")
|
25 |
+
|
26 |
+
transcribe_button = gr.Button("Transcribe with Inference API")
|
27 |
+
transcribe_button.click(
|
28 |
+
fn=transcribe_audio, inputs=[audio_input], outputs=[text_output]
|
29 |
+
)
|
30 |
+
|
31 |
+
gr.Examples(
|
32 |
+
[
|
33 |
+
["./examples/audio1.mp3"],
|
34 |
+
["./examples/audio2.mp3"],
|
35 |
+
],
|
36 |
+
inputs=[audio_input],
|
37 |
+
outputs=[text_output],
|
38 |
+
fn=transcribe_audio,
|
39 |
+
cache_examples=True,
|
40 |
+
cache_mode="lazy",
|
41 |
+
run_on_click=True,
|
42 |
+
)
|
43 |
+
|
44 |
+
gr.Markdown(
|
45 |
+
f"Current model: {model_id}. For more information, visit the [model hub](https://huggingface.co/{model_id})."
|
46 |
+
)
|
47 |
+
|
48 |
+
if __name__ == "__main__":
|
49 |
+
demo.launch()
|
examples/audio1.mp3
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:033a08d5a16f5f6f6ddfa7dd6eea87c15f06060bc08ebbb2b2746579022bac13
|
3 |
+
size 40557
|
examples/audio2.mp3
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2d2cca183511d5db331624d01f4f3a01404052eaba3bbfa6c0c2f2bcd50b8934
|
3 |
+
size 33837
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
gradio==5.4.0
|
2 |
+
huggingface_hub==0.26.2
|