thai-subtitles
Skill1 starsChanged 3 months agoMITView on GitHub
Generate, clean up, and burn Thai subtitles (ซับไทย / คำบรรยายภาษาไทย) for a video or audio file — transcribe Thai speech with Whisper, fix Thai line breaks (Thai has no spaces between words), and hard-sub with a Thai font via ffmpeg. Use when the user asks for ซับไทย, ทำซับ, ถอดเสียง, แกะเทป, subtitles, captions, SRT, or burning captions onto a clip in Thai.
- Installs packages
In this repository5 other files it gives its agents.
- capcutSkill
- cut-silenceSkill
- edit-videoSkill
- thai-motionSkill
- thai-shortsSkill
The file
Files
ซับไทย (Thai subtitles)
ตอบผู้ใช้เป็นภาษาไทย ถ้าผู้ใช้ไม่ได้พิมพ์ภาษาอื่นมา
ขั้นตอน
1. เช็กเครื่องมือ
ffmpeg -version | head -1
ffmpeg -hide_banner -filters | grep -E " (subtitles|ass) " # ต้องมี ถึงจะฝังซับได้
python3 -c "import pythainlp" 2>/dev/null || pip install pythainlp # ตัดคำไทยถ้า ffmpeg ไม่มี filter subtitles (ไม่ได้ build กับ libass) มีสองทาง: แนะนำ brew install ffmpeg-full (macOS) หรือฝังซับด้วย HyperFrames ผ่าน skill thai-motion (ไม่ต้องใช้ libass และได้ซับแบบเด้งทีละคำด้วย)
2. ถอดเสียง → SRT
ดึงเสียงออกมาก่อน (เร็วกว่า และ Whisper ต้องการ 16 kHz mono):
ffmpeg -i input.mp4 -vn -ac 1 -ar 16000 audio.wavเลือกตัวที่มีในเครื่อง ตามลำดับนี้:
| เครื่องมือ | คำสั่ง |
whisper-cli (whisper.cpp, brew install whisper-cpp) | whisper-cli -m ggml-large-v3-turbo-q5_0.bin -l th -f audio.wav -osrt -of audio |
npx hyperframes transcribe (ใช้ whisper.cpp ข้างใน) | npx hyperframes transcribe audio.wav --model large-v3 --language th --to srt -o audio.srt |
mlx-whisper (Apple Silicon) | mlx_whisper audio.wav --model mlx-community/whisper-large-v3-turbo --language th --output-format srt --word-timestamps True |
whisper-ctranslate2 / faster-whisper (NVIDIA/CPU) | whisper-ctranslate2 audio.wav --model large-v3 --language th --output_format srt --word_timestamps True |
openai-whisper | whisper audio.wav --model large-v3 --language th --output_format srt |
- ต้องใส่
--language thเสมอ ไม่งั้นช่วงที่พูดทับศัพท์อังกฤษเยอะจะถูกตีเป็นภาษาอังกฤษ - งานที่เน้นความแม่นภาษาไทย แนะนำโมเดล fine-tune ภาษาไทย เช่น
biodatlab/whisper-th-large-v3-combined(ใช้ผ่าน transformers) - โมเดลเล็ก (
small,base,*.en) ใช้กับภาษาไทยไม่ได้จริง ขั้นต่ำlarge-v3-turbo(ไฟล์ q5_0 ~550 MB, ถอด 19 วินาทีเสร็จใน ~2.5 วินาทีบน M4) - ถ้าผู้ใช้ให้รายชื่อเฉพาะ (ชื่อคน/แบรนด์/ศัพท์เทคนิค) ส่งเป็น
--initial_prompt "..."ช่วยให้สะกดถูก
3. จัดบรรทัดซับไทย
Whisper ตัดบรรทัดตามความยาว ทำให้คำไทยขาดกลางคำ ใช้สคริปต์นี้ (อยู่ในโฟลเดอร์เดียวกับไฟล์นี้):
python3 scripts/thai_srt.py audio.srt -o th.srt --max-chars 30 --strip-fillers--max-charsนับเฉพาะตัวที่กินที่ (สระบน/ล่าง วรรณยุกต์ไม่นับ): แนวนอน 16:9 ≈ 30–38, แนวตั้ง 9:16 ≈ 16–20--strip-fillersลบ เอ่อ/อ่า/อืม ออกจากซับ (ไม่ตัดวิดีโอ ถ้าจะตัดเสียงด้วยใช้ skillcut-silence)
4. ตรวจทานคำผิด (สำคัญ)
อ่าน th.srt แล้วแก้เองก่อนฝัง อย่าแก้ timestamp:
- ตัวอย่างที่เจอจริงตอนทดสอบ (large-v3-turbo): ภาษาไทย→"พาศาทาย", ซับไทย→"ซับทาย", ช่วงเงียบ→"ช่วงเมียบ", กราฟิก→"กลาสกิก", ปลั๊กอิน→"ปลักอิน", ผู้พูดหญิงแต่ถอดเป็น "ครับ", คำอังกฤษอย่าง "AI" หายไปเลย
- คำพ้องเสียงที่ Whisper ชอบผิด: คะ/ค่ะ, นะคะ/นะค่ะ, ทำไม/ทำไหม, อนุญาต/อนุญาติ, ศัพท์อังกฤษที่ถอดเป็นไทย (เช่น "เอไอ" → "AI" ถ้าผู้ใช้ต้องการ)
- ตัวเลข: ใช้เลขอารบิกเป็นค่าเริ่มต้น
- ไม่ต้องใส่ ฯลฯ หรือจุดท้ายประโยค ซับไทยไม่นิยมใส่
. - ถ้าแก้ข้อความจนยาวขึ้น ให้รัน
thai_srt.pyซ้ำ
5. ฝังซับ (hard-sub)
ฟอนต์ไทยฟรี (OFL จาก Google Fonts): Kanit, Prompt, Sarabun, Noto Sans Thai ถ้าเครื่องไม่มี ให้โหลดใส่ ./fonts/ แล้วชี้ fontsdir
ffmpeg -i input.mp4 -vf "subtitles=th.srt:fontsdir=./fonts:force_style='FontName=Kanit,FontSize=20,PrimaryColour=&H00FFFFFF,OutlineColour=&H00000000,BorderStyle=1,Outline=2,Shadow=0,MarginV=40'" -c:a copy output.mp4- ซับไทยมีสระบน/วรรณยุกต์สูง ให้
MarginVอย่างน้อย 30 ไม่งั้นบรรทัดบนจะโดนตัด - คลิปแนวตั้ง:
FontSize=14–16,MarginV=120–200(หลบ UI ของ TikTok/Reels) - ถ้าผู้ใช้ต้องการซับแยกไฟล์ (soft-sub) ใส่ใน mp4:
ffmpeg -i input.mp4 -i th.srt -c copy -c:s mov_text -metadata:s:s:0 language=tha output.mp4
6. ส่งงาน
บอกผู้ใช้: ไฟล์ที่ได้, ความยาว, จุดที่ไม่แน่ใจการถอดเสียง (ระบุเวลา) ให้เขาตรวจเอง
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

