Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,21 +1,23 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
#
|
5 |
-
asr = pipeline("automatic-speech-recognition", model="
|
6 |
|
|
|
7 |
def transcribe(audio_file):
|
8 |
if audio_file is None:
|
9 |
return "Chưa có file âm thanh."
|
10 |
result = asr(audio_file)
|
11 |
return result["text"]
|
12 |
|
|
|
13 |
demo = gr.Interface(
|
14 |
fn=transcribe,
|
15 |
inputs=gr.Audio(type="filepath", label="Tải lên file âm thanh (.wav, .mp3...)"),
|
16 |
outputs=gr.Textbox(label="Kết quả chuyển văn bản"),
|
17 |
-
title="Nhận diện
|
18 |
-
description="
|
19 |
)
|
20 |
|
21 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
# Tạo pipeline nhận diện giọng nói
|
5 |
+
asr = pipeline("automatic-speech-recognition", model="openai/whisper-base")
|
6 |
|
7 |
+
# Hàm xử lý âm thanh
|
8 |
def transcribe(audio_file):
|
9 |
if audio_file is None:
|
10 |
return "Chưa có file âm thanh."
|
11 |
result = asr(audio_file)
|
12 |
return result["text"]
|
13 |
|
14 |
+
# Giao diện Gradio
|
15 |
demo = gr.Interface(
|
16 |
fn=transcribe,
|
17 |
inputs=gr.Audio(type="filepath", label="Tải lên file âm thanh (.wav, .mp3...)"),
|
18 |
outputs=gr.Textbox(label="Kết quả chuyển văn bản"),
|
19 |
+
title="Nhận diện giọng nói bằng Whisper",
|
20 |
+
description="Tải file âm thanh và hệ thống sẽ nhận diện nội dung giọng nói bằng mô hình Whisper của OpenAI."
|
21 |
)
|
22 |
|
23 |
demo.launch()
|