HyperFrames 媒體前置處理
三個 CLI 指令,用於產生組合資產:tts(語音)、transcribe(時間戳記)和 remove-background(透明影片)。每個指令在首次執行時會下載模型,並快取在 ~/.cache/hyperframes/ 目錄下。將輸出放入專案後,即可在組合 HTML 中引用——有關音訊/影片元素的慣例,請參閱 hyperframes 技能。
文字轉語音 (tts)
在本機使用 Kokoro-82M 產生語音音訊。無需 API 金鑰。
npx hyperframes tts "這裡的文字" --voice af_nova --output narration.wav
npx hyperframes tts script.txt --voice bf_emma --output narration.wav
npx hyperframes tts --list # 列出全部 54 種語音
語音選擇
根據內容選擇語音。預設為 af_heart。
| 內容類型 | 語音 | 原因 |
|---|---|---|
| 產品展示 | af_heart/af_nova | 溫暖、專業 |
| 教學 / 指南 | am_adam/bf_emma | 中立、易於理解 |
| 行銷 / 宣傳 | af_sky/am_michael | 有活力或有權威感 |
| 文件說明 | bf_emma/bm_george | 清晰的英式英語、正式 |
| 休閒 / 社群 | af_heart/af_sky | 親切、自然 |
多語言
語音 ID 編碼了語言的開頭字母:a=美式英語,b=英式英語,e=西班牙語,f=法語,h=印地語,i=義大利語,j=日語,p=巴西葡萄牙語,z=中文。CLI 會根據前綴自動偵測音素化語言環境——當語音與文字匹配時,無需使用 --lang 參數。
npx hyperframes tts "La reunión empieza a las nueve" --voice ef_dora --output es.wav
npx hyperframes tts "今日はいい天気ですね" --voice jf_alpha --output ja.wav
僅在需要覆蓋自動偵測時使用 --lang(例如風格化的口音)。有效代碼:en-us、en-gb、es、fr-fr、hi、it、pt-br、ja、zh。非英語音素化需要系統層級安裝 espeak-ng(brew install espeak-ng / apt-get install espeak-ng)。
速度
0.7-0.8— 教學、複雜內容、無障礙1.0— 自然語速(預設)1.1-1.2— 介紹、過場、活潑內容1.5+— 很少適用;需仔細測試
長文稿
對於超過數段落的文字,請寫入 .txt 檔案並傳遞路徑。約 5 分鐘以上的語音輸入,建議分段處理。
需求
需要 Python 3.8+ 以及 kokoro-onnx 和 soundfile(pip install kokoro-onnx soundfile)。模型在首次使用時下載(約 311 MB + 約 27 MB 語音,快取於 ~/.cache/hyperframes/tts/ 目錄下)。
轉錄 (transcribe)
產生包含逐字時間戳記的標準化 transcript.json。
npx hyperframes transcribe audio.mp3
npx hyperframes transcribe video.mp4 --model small --language es
npx hyperframes transcribe subtitles.srt # 匯入現有字幕
npx hyperframes transcribe subtitles.vtt
npx hyperframes transcribe openai-response.json
語言規則(不可違反)
除非使用者明確指出音訊為英語,否則絕不使用 .en 模型。 .en 模型(small.en、medium.en)會將非英語音訊翻譯為英語,而非轉錄。這會默默地破壞原始語言。
- 語言已知且非英語 →
--model small --language <code>(無.en後綴) - 語言已知且為英語 →
--model small.en - 語言未知 →
--model small(無.en和--language)——whisper 會自動偵測
預設模型為 small,而非 small.en。
模型大小
| 模型 | 大小 | 速度 | 使用時機 |
|---|---|---|---|
tiny | 75 MB | 最快 | 快速預覽、測試流程 |
base | 142 MB | 快 | 短片、清晰的音訊 |
small | 466 MB | 中等 | 預設——大多數內容 |
medium | 1.5 GB | 慢 | 重要內容、嘈雜音訊、音樂 |
large-v3 | 3.1 GB | 最慢 | 生產級品質 |
包含人聲的音樂:至少從 medium 開始;製作出的音軌通常需要手動匯入 SRT/VTT。關於字幕品質檢查(每次轉錄後必須執行)、清理 JS、重試規則以及 OpenAI/Groq API 匯入路徑,請參閱 hyperframes/references/transcript-guide.md。
輸出格式
組合使用一組平坦的單字物件陣列。id 欄位(w0、w1、...)在標準化過程中加入,以提供穩定的字幕覆蓋參考;基於向後相容,此欄位為可選。
[
{ "id": "w0", "text": "Hello", "start": 0.0, "end": 0.5 },
{ "id": "w1", "text": "world.", "start": 0.6, "end": 1.2 }
]
背景移除 (remove-background)
移除影片或圖片的背景,使其可以在組合中作為透明疊加層使用(例如漂浮在背景板上的虛擬角色)。
npx hyperframes remove-background avatar.mp4 -o transparent.webm # 預設:VP9 Alpha WebM
npx hyperframes remove-background avatar.mp4 -o transparent.mov # ProRes 4444(剪輯用)
npx hyperframes remove-background portrait.jpg -o cutout.png # 單張圖片去背
npx hyperframes remove-background avatar.mp4 -o transparent.webm --device cpu
npx hyperframes remove-background --info # 顯示已偵測到的提供者
使用 u2net_human_seg(MIT 授權)。首次執行會下載約 168 MB 的權重至 ~/.cache/hyperframes/background-removal/models/ 目錄。
輸出格式
| 格式 | 使用時機 |
|---|---|
.webm(VP9 + Alpha) | 預設。組合可直接透過 <video> 播放。 |
.mov(ProRes 4444) | 在 DaVinci/Premiere/FCP 中編輯。檔案較大。 |
.png | 單張圖片去背(靜態主體,疊加在背景上)。 |
Chrome 原生解碼 VP9 Alpha,因此 .webm 可以像其他靜音自動播放影片一樣直接插入組合——請參閱 hyperframes 技能中 <video> 影軌的慣例。
TTS → 轉錄 → 字幕
當沒有預先錄製的旁白時,可以先產生旁白再轉錄回來,以取得用於字幕的逐字時間戳記:
npx hyperframes tts script.txt --voice af_heart --output narration.wav
npx hyperframes transcribe narration.wav # → transcript.json
Whisper 會從生成的音訊中提取精確的單字邊界,因此字幕時間軸能與語音完美匹配,無需手動調整。