Spaces:
Runtime error
Runtime error
Sandiago21
commited on
Commit
•
10d27b0
1
Parent(s):
b4676ae
Upload folder using huggingface_hub
Browse files- README.md +3 -9
- app.py +54 -0
- example.wav +0 -0
- requirements.txt +2 -0
README.md
CHANGED
@@ -1,12 +1,6 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji: 📚
|
4 |
-
colorFrom: indigo
|
5 |
-
colorTo: pink
|
6 |
-
sdk: gradio
|
7 |
-
sdk_version: 3.38.0
|
8 |
app_file: app.py
|
9 |
-
|
|
|
10 |
---
|
11 |
-
|
12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
+
title: automatic-speech-recognition-french
|
|
|
|
|
|
|
|
|
|
|
3 |
app_file: app.py
|
4 |
+
sdk: gradio
|
5 |
+
sdk_version: 3.36.0
|
6 |
---
|
|
|
|
app.py
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
import gradio as gr
|
3 |
+
from transformers import pipeline
|
4 |
+
|
5 |
+
model_id = "Sandiago21/whisper-large-v2-french" # update with your model id
|
6 |
+
pipe = pipeline("automatic-speech-recognition", model=model_id)
|
7 |
+
|
8 |
+
|
9 |
+
title = "Automatic Speech Recognition (ASR)"
|
10 |
+
description = """
|
11 |
+
Demo for automatic speech recognition in French. Demo uses [Sandiago21/whisper-large-v2-french](https://huggingface.co/Sandiago21/whisper-large-v2-french) checkpoint, which is based on OpenAI's
|
12 |
+
[Whisper](https://huggingface.co/openai/whisper-large-v2) model and is fine-tuned in French Audio dataset
|
13 |
+
![Automatic Speech Recognition (ASR)"](https://datasets-server.huggingface.co/assets/huggingface-course/audio-course-images/--/huggingface-course--audio-course-images/train/2/image/image.png "Diagram of Automatic Speech Recognition (ASR)")
|
14 |
+
"""
|
15 |
+
|
16 |
+
def transcribe_speech(filepath):
|
17 |
+
output = pipe(
|
18 |
+
filepath,
|
19 |
+
max_new_tokens=256,
|
20 |
+
generate_kwargs={
|
21 |
+
"task": "transcribe",
|
22 |
+
"language": "french",
|
23 |
+
}, # update with the language you've fine-tuned on
|
24 |
+
chunk_length_s=30,
|
25 |
+
batch_size=8,
|
26 |
+
)
|
27 |
+
return output["text"]
|
28 |
+
|
29 |
+
demo = gr.Blocks()
|
30 |
+
|
31 |
+
mic_transcribe = gr.Interface(
|
32 |
+
fn=transcribe_speech,
|
33 |
+
inputs=gr.Audio(source="microphone", type="filepath"),
|
34 |
+
outputs=gr.outputs.Textbox(),
|
35 |
+
tilte=title,
|
36 |
+
description=description,
|
37 |
+
)
|
38 |
+
|
39 |
+
file_transcribe = gr.Interface(
|
40 |
+
fn=transcribe_speech,
|
41 |
+
inputs=gr.Audio(source="upload", type="filepath"),
|
42 |
+
outputs=gr.outputs.Textbox(),
|
43 |
+
examples=[["./example.wav"]],
|
44 |
+
tilte=title,
|
45 |
+
description=description,
|
46 |
+
)
|
47 |
+
|
48 |
+
with demo:
|
49 |
+
gr.TabbedInterface(
|
50 |
+
[mic_transcribe, file_transcribe],
|
51 |
+
["Transcribe Microphone", "Transcribe Audio File"],
|
52 |
+
),
|
53 |
+
|
54 |
+
demo.launch()
|
example.wav
ADDED
Binary file (247 kB). View file
|
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
transformers
|
2 |
+
torch
|