Spaces:
Runtime error
Runtime error
Commit
·
cee3120
1
Parent(s):
cdf1505
Upload folder using huggingface_hub
Browse files- README.md +3 -9
- app.py +41 -0
- requirements.txt +2 -0
README.md
CHANGED
|
@@ -1,12 +1,6 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji: 🚀
|
| 4 |
-
colorFrom: pink
|
| 5 |
-
colorTo: green
|
| 6 |
-
sdk: gradio
|
| 7 |
-
sdk_version: 3.36.1
|
| 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-greek
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
app_file: app.py
|
| 4 |
+
sdk: gradio
|
| 5 |
+
sdk_version: 3.36.0
|
| 6 |
---
|
|
|
|
|
|
app.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
import gradio as gr
|
| 3 |
+
from transformers import pipeline
|
| 4 |
+
|
| 5 |
+
model_id = "Sandiago21/whisper-large-v2-greek" # update with your model id
|
| 6 |
+
pipe = pipeline("automatic-speech-recognition", model=model_id)
|
| 7 |
+
|
| 8 |
+
def transcribe_speech(filepath):
|
| 9 |
+
output = pipe(
|
| 10 |
+
filepath,
|
| 11 |
+
max_new_tokens=256,
|
| 12 |
+
generate_kwargs={
|
| 13 |
+
"task": "transcribe",
|
| 14 |
+
"language": "greek",
|
| 15 |
+
}, # update with the language you've fine-tuned on
|
| 16 |
+
chunk_length_s=30,
|
| 17 |
+
batch_size=8,
|
| 18 |
+
)
|
| 19 |
+
return output["text"]
|
| 20 |
+
|
| 21 |
+
demo = gr.Blocks()
|
| 22 |
+
|
| 23 |
+
mic_transcribe = gr.Interface(
|
| 24 |
+
fn=transcribe_speech,
|
| 25 |
+
inputs=gr.Audio(source="microphone", type="filepath"),
|
| 26 |
+
outputs=gr.outputs.Textbox(),
|
| 27 |
+
)
|
| 28 |
+
|
| 29 |
+
file_transcribe = gr.Interface(
|
| 30 |
+
fn=transcribe_speech,
|
| 31 |
+
inputs=gr.Audio(source="upload", type="filepath"),
|
| 32 |
+
outputs=gr.outputs.Textbox(),
|
| 33 |
+
)
|
| 34 |
+
|
| 35 |
+
with demo:
|
| 36 |
+
gr.TabbedInterface(
|
| 37 |
+
[mic_transcribe, file_transcribe],
|
| 38 |
+
["Transcribe Microphone", "Transcribe Audio File"],
|
| 39 |
+
)
|
| 40 |
+
|
| 41 |
+
demo.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
transformers
|
| 2 |
+
torch
|