Spaces:
Sleeping
Sleeping
frist commit
Browse files- app.py +29 -0
- requirements.txt +3 -0
app.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline, WhisperProcessor, WhisperForConditionalGeneration
|
3 |
+
|
4 |
+
# load mode
|
5 |
+
model_name = "openai/whisper-medium"
|
6 |
+
processor = WhisperProcessor.from_pretrained(model_name,language="lo")
|
7 |
+
model = WhisperForConditionalGeneration.from_pretrained(model_dir)
|
8 |
+
|
9 |
+
asr = pipeline(
|
10 |
+
"automatic-speech-recognition",
|
11 |
+
model= "LuoYiSULIXAY/whisper-lao-finetuned_laonlp",
|
12 |
+
tokenizer=processor.tokenizer,
|
13 |
+
feature_extractor=processor.feature_extractor,
|
14 |
+
device=-1
|
15 |
+
)
|
16 |
+
|
17 |
+
def transcribe(audio):
|
18 |
+
result = asr(audio, generate_kwargs={"language": "lao", "task": "transcribe"})
|
19 |
+
return result["text"]
|
20 |
+
|
21 |
+
demo = gr.Interface(
|
22 |
+
fn=transcribe,
|
23 |
+
inputs=gr.Audio(type="filepath",streaming=False), # ✅ 正确写法
|
24 |
+
outputs="text",
|
25 |
+
title="Whisper Lao",
|
26 |
+
description="Realtime demo for Lao speech recognition using a fine-tuned Whisper model.",
|
27 |
+
)
|
28 |
+
|
29 |
+
demo.launch(share=True)
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
transformers
|
3 |
+
torchaudio
|