Spaces:
Runtime error
Runtime error
Commit
·
4e218e5
1
Parent(s):
5e7d3cb
fix main
Browse files
app.py
CHANGED
|
@@ -9,12 +9,11 @@ import shutil
|
|
| 9 |
if not shutil.which("ffmpeg"):
|
| 10 |
raise EnvironmentError("ffmpeg not found. Please install ffmpeg and ensure it's in PATH.")
|
| 11 |
|
| 12 |
-
# ✅
|
| 13 |
-
os.environ["PATH"] += os.pathsep + r"C:\ffmpeg\ffmpeg-master-latest-win64-gpl\ffmpeg-master-latest-win64-gpl\bin"
|
| 14 |
|
| 15 |
# ✅ โหลดโมเดล
|
| 16 |
-
|
| 17 |
-
MODEL_NAME = "biodatlab/whisper-th-medium-combined"
|
| 18 |
device = 0 if torch.cuda.is_available() else "cpu"
|
| 19 |
|
| 20 |
pipe = pipeline(
|
|
@@ -47,15 +46,11 @@ def get_download_filepath(filepath):
|
|
| 47 |
# ✅ UI Layout
|
| 48 |
with gr.Blocks() as demo:
|
| 49 |
gr.Markdown("## 🎤 แปลงเสียงพูดภาษาไทยเป็นข้อความ")
|
| 50 |
-
|
| 51 |
with gr.Row():
|
| 52 |
-
|
| 53 |
-
with gr.Column():
|
| 54 |
audio_input = gr.Audio(label="🎵 อัปโหลดไฟล์เสียง (MP3, WAV, M4A)", type="filepath")
|
| 55 |
transcribe_btn = gr.Button("🔄 แปลงเสียงเป็นข้อความ")
|
| 56 |
-
|
| 57 |
-
# 🔵 Output ขวา
|
| 58 |
-
with gr.Column():
|
| 59 |
transcribed_text = gr.Textbox(label="📜 ข้อความที่แปลงแล้ว", lines=11)
|
| 60 |
with gr.Row():
|
| 61 |
copy_button = gr.Button("📋 คัดลอกข้อความ")
|
|
@@ -80,4 +75,5 @@ with gr.Blocks() as demo:
|
|
| 80 |
# Action ดาวน์โหลด
|
| 81 |
download_button.click(fn=get_download_filepath, inputs=download_button, outputs=download_button)
|
| 82 |
|
|
|
|
| 83 |
demo.launch(auth=[("client1", "pass123"), ("client2", "pass456")])
|
|
|
|
| 9 |
if not shutil.which("ffmpeg"):
|
| 10 |
raise EnvironmentError("ffmpeg not found. Please install ffmpeg and ensure it's in PATH.")
|
| 11 |
|
| 12 |
+
# ✅ ลบ path ffmpeg เฉพาะ local เพราะ Spaces มี ffmpeg ติดตั้งแล้ว
|
| 13 |
+
# os.environ["PATH"] += os.pathsep + r"C:\ffmpeg\ffmpeg-master-latest-win64-gpl\ffmpeg-master-latest-win64-gpl\bin"
|
| 14 |
|
| 15 |
# ✅ โหลดโมเดล
|
| 16 |
+
MODEL_NAME = "biodatlab/whisper-th-small-combined"
|
|
|
|
| 17 |
device = 0 if torch.cuda.is_available() else "cpu"
|
| 18 |
|
| 19 |
pipe = pipeline(
|
|
|
|
| 46 |
# ✅ UI Layout
|
| 47 |
with gr.Blocks() as demo:
|
| 48 |
gr.Markdown("## 🎤 แปลงเสียงพูดภาษาไทยเป็นข้อความ")
|
|
|
|
| 49 |
with gr.Row():
|
| 50 |
+
with gr.Column(scale=1):
|
|
|
|
| 51 |
audio_input = gr.Audio(label="🎵 อัปโหลดไฟล์เสียง (MP3, WAV, M4A)", type="filepath")
|
| 52 |
transcribe_btn = gr.Button("🔄 แปลงเสียงเป็นข้อความ")
|
| 53 |
+
with gr.Column(scale=2):
|
|
|
|
|
|
|
| 54 |
transcribed_text = gr.Textbox(label="📜 ข้อความที่แปลงแล้ว", lines=11)
|
| 55 |
with gr.Row():
|
| 56 |
copy_button = gr.Button("📋 คัดลอกข้อความ")
|
|
|
|
| 75 |
# Action ดาวน์โหลด
|
| 76 |
download_button.click(fn=get_download_filepath, inputs=download_button, outputs=download_button)
|
| 77 |
|
| 78 |
+
# รันใน Hugging Face Spaces ด้วย auth
|
| 79 |
demo.launch(auth=[("client1", "pass123"), ("client2", "pass456")])
|