ffmpeg to be installed on your system. - Install
ffmpeg: Use a package manager appropriate for your operating system (e.g., Homebrew on macOS,apton Ubuntu/Debian, Chocolatey on Windows). - Install the Whisper Python package: Use
pipto install the package from the official OpenAI GitHub repository.
whisper command to transcribe audio files locally. - Transcribe an audio file:This will automatically detect the language and transcribe the audio, saving the output as text files in the same directory.
- Specify a different model:Models vary in size and accuracy (tiny, base, small, medium, large).
- Translate a non-English file to English:This translates the source speech into English text.
- View all options:
faster-whisper-cli: A Python package utilizing CTranslate2 for faster inference, especially on specific hardware.whisper.cpp-cli: A C/C++ port (whisper.cpp) focused on efficient, high-performance, and cross-platform on-device inference, often using CPU/GPU acceleration features like Core ML or cuBLAS. These are standalone executables and do not require Python
----------
260121
whisper apv2.mp4 --language zh --task transcribe --output_format srt
260122
whisper a.mp4 --language zh --task transcribe --output_format srt
whisper cli.mp4 --language zh --task transcribe --output_format srt
260123.
whisper apv40.mov --language zh --task transcribe --output_format srt
260204 array AG FQDN
whisper ag.mp4 --language zh --task transcribe --output_format srt
whisper m.mp4 --language zh --task transcribe --output_format srt
260211
whisper stm.mp4 --language zh --task transcribe --output_format srt
whisper cc.mp4 --language zh --task transcribe --output_format srt
260226 Array AG FQDN_CIFS
whisper cifs.mp4 --language zh --task transcribe --output_format srt
260305 ty
whisper ty.m4a --language zh --task transcribe --output_format srt
whisper max.mov --language zh --task transcribe --output_format srt
輸出的 .srt 會放在 你當前的工作目錄
以上為簡體中文
簡體中文->繁體中文
brew install opencc
opencc -i a2.srt -o a2_traditional.srt -c s2t.json
opencc -i 0122.srt -o a2_traditional.srt -c s2t.json
260123
opencc -i apv40.srt -o apv40_traditional.srt -c s2t.json
260226. CIFS Array AG
如何去掉贅詞(後處理方式)
方法 1:用文字處理工具清理
Whisper 生成
a.srt。使用正則表達式或文字編輯器批次刪除常見贅詞。 例如在
sed或grep中:bashsed -E 's/(嗯|啊|就是|那個)//g' a.srt > a_clean.srt👉 這樣會生成一個去掉贅詞的字幕檔。
方法 2:用 OpenCC + 自訂詞表
OpenCC 本來是繁簡轉換工具,但它也能套用自訂詞表。
你可以建立一個「贅詞刪除詞表」,讓它在轉換時自動去掉。
方法 3:用 NLP 後處理
如果要更智慧化,可以用 Python NLP 套件(spaCy、jieba)來過濾停用詞,保留主要語意。 範例:
import re
with open("a.srt", "r", encoding="utf-8") as f:
text = f.read()
clean_text = re.sub(r"(嗯|啊|就是|那個)", "", text)
with open("a_clean.srt", "w", encoding="utf-8") as f:
f.write(clean_text)
📌 彙整
Whisper CLI → 沒有內建去贅詞功能。
解法 → 後處理(正則表達式 / 自訂詞表 / NLP)。
最快方式 → 用
sed或 Python 腳本批次清理。
沒有留言:
張貼留言