aliceer commited on
Commit
049d5e8
·
0 Parent(s):

initial commit

Browse files
Files changed (3) hide show
  1. README.md +16 -0
  2. app.py +32 -0
  3. requirements.txt +4 -0
README.md ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Thai Speech Recognition App
2
+
3
+ แอปพลิเคชันแปลงเสียงพูดภาษาไทยเป็นข้อความ โดยใช้โมเดล Whisper ที่ปรับแต่งสำหรับภาษาไทย
4
+
5
+ ## วิธีใช้งาน
6
+
7
+ 1. อัปโหลดไฟล์เสียงที่มีการพูดภาษาไทย (รองรับไฟล์เสียงหลายรูปแบบ เช่น .mp3, .wav)
8
+ 2. รอสักครู่ระบบจะประมวลผลและแสดงข้อความที่ถอดความได้
9
+ 3. สามารถอัปโหลดไฟล์ใหม่เพื่อทำการถอดความต่อไปได้
10
+
11
+ ## เทคโนโลยีที่ใช้
12
+
13
+ - Hugging Face Transformers
14
+ - Whisper Model (biodatlab/whisper-th-medium-combined)
15
+ - Gradio
16
+ - PyTorch
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import gradio as gr
3
+ from transformers import pipeline
4
+
5
+ MODEL_NAME = "biodatlab/whisper-th-medium-combined"
6
+ device = 0 if torch.cuda.is_available() else "cpu"
7
+
8
+ pipe = pipeline(
9
+ task="automatic-speech-recognition",
10
+ model=MODEL_NAME,
11
+ chunk_length_s=30,
12
+ device=device,
13
+ )
14
+
15
+ def transcribe_audio(audio_file):
16
+ try:
17
+ result = pipe(audio_file, generate_kwargs={"language":"<|th|>", "task":"transcribe"}, batch_size=16)
18
+ return result["text"]
19
+ except Exception as e:
20
+ return str(e)
21
+
22
+ # สร้าง Gradio Interface
23
+ demo = gr.Interface(
24
+ fn=transcribe_audio,
25
+ inputs=gr.Audio(type="filepath"),
26
+ outputs="text",
27
+ title="Thai Speech Recognition",
28
+ description="อัปโหลดไฟล์เสียงภาษาไทยเพื่อแปลงเป็นข้อความ",
29
+ )
30
+
31
+ if __name__ == "__main__":
32
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ transformers
2
+ torch
3
+ librosa
4
+ gradio