Synthesize line by line → remove silence → 48 kHz WAV → durations.json. Subsequent subtitles and shot durations are all aligned to the actual voice-over duration, so there is no more "audio and video not matching".
Part of ecommerce-video-skills · Script:
scripts/tts_edge.py(only depends onedge-tts+ ffmpeg)
Inputs
- Voice-over script (one sentence per line, or the
storyboard.jsonfield ofline) - Language / voice preference (male/female, lively/steady), speaking rate
- Environment:
pip install edge-tts, ffmpeg, network access to Microsoft TTS service
Steps
- Rewrite into an easy-to-read voice-over script(see rules), 8–20 characters per sentence.
- Choose a voice(
python scripts/tts_edge.py --list zh-CNto view all):
| Scenario | Recommended voice |
|---|---|
| Energetic product recommendation (male) | zh-CN-YunxiNeural |
| Friendly product recommendation (female) | zh-CN-XiaoxiaoNeural / zh-CN-XiaoyiNeural |
| Passionate promotion | zh-CN-YunjianNeural |
| Professional explanation | zh-CN-YunyangNeural |
| Taiwan / Hong Kong | zh-TW-HsiaoChenNeural / zh-HK-HiuMaanNeural |
| English | en-US-AndrewNeural · en-US-AvaNeural · en-US-EmmaNeural |
-
Synthesize:
pip install edge-tts # 单句试听 python scripts/tts_edge.py "夏天带冰水出门,不到中午就变温了?" --voice zh-CN-YunxiNeural --rate "+10%" -o out/hook.wav # 整个分镜(每镜一句 → build/tts/l00.wav … + durations.json) python scripts/tts_edge.py --storyboard storyboard.json --outdir build/tts -
Preview 2 sentences before batch processing: speaking rate
+5%~+15%sounds most like a sales voice-over; exceeding+20%feels rushed. -
Hand it to
ffmpeg-auto-assemble(it will automatically call this script) or your own editing software.
Voice-over script rewriting rules Script rules
- Write numbers as they are read:
2核8G→两核八G;24h→二十四小时; add spaces between model lettersA I. Subtitles can keep the original spelling (thesubfield). - Say only one thing per sentence; commas are breathing points, and use periods/question marks at the end of sentences to let the intonation fall.
- Remove written-language words: "This product has…" → "This cup…".
- If an English brand name is mispronounced, write it into
line,subusing spelling or homophones while keeping the correct spelling.
Prompt template
把下面的带货文案改写成适合 TTS 朗读的口播稿:每句 8–20 字、一句一件事、口语化;
数字和字母写成读法;另外输出一列「字幕版」保留原始写法并用 **加粗** 标 1 个关键词。
不要添加原文没有的卖点或数据。原文:{…}
Checklist
- Preview 2 sentences first to confirm voice/speaking rate
- Numbers, English, and brand names are pronounced correctly
-
durations.jsonhas been generated, and the total duration meets the target - Before commercial use, confirm the labeling requirements for AI voice-over on your platform and in your region (e.g., if "AI-generated" must be labeled)
Common issues and fixes Failure fixes
| Issue | Fix |
|---|---|
edge-tts failed / timeout |
Network issue; the script has already retried 3 times; switch networks or try again later; when offline, use assemble.py --tts none to preview the visuals first |
| Incorrect pronunciation | In line write homophones/spelling, andsub keep the original text |
| Pauses between sentences are too long | Leading and trailing silence has been automatically removed; adjust the storyboard's pad(default 0.25s) |
| The voice is too flat | Switch YunjianNeural/XiaoyiNeural;--pitch "+5Hz"; use question marks/exclamation marks at the end of sentences |
| Need a human feel | edge-tts is synthetic audio; for high-requirement scenarios, switch to real-person recording, and the pipeline can still be used (put the recording into build/tts/lXX.wav) |
edge-tts is community-maintained (rany2/edge-tts, LGPL-3.0), and calls Microsoft's online service; this repository only installs it as a dependency and does not include its code.