npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

douyin-translate

v0.1.2

Published

Docker-powered Douyin video translation pipeline — Next.js + FastAPI

Readme

Auto-Translade-video

Tự động lồng tiếng video (YouTube / TikTok / Douyin / file local) sang tiếng Việt hoặc tiếng Nhật, giữ nguyên nhạc nền và hiệu ứng âm thanh gốc.

Pipeline

URL/file → Download → Extract audio → (Demucs tách BGM)
        → ASR (Azure Speech) → Dịch sang VI/JP (skill hoặc web AI)
        → TTS (LucyLab cho VI, Azure cho JP)
        → Khớp timeline → Mix với BGM → Ghép vào video

Yêu cầu

  • Python 3.10+
  • ffmpeg trong PATH
  • Tài khoản Azure Speech (ASR + JP TTS)
  • Tài khoản LucyLab (chỉ cần nếu lồng VI) – https://lucylab.io
  • (Tuỳ chọn) Google Gemini API key (để tự sinh metadata YouTube + thumbnail)
pip install -r requirements.txt
playwright install chromium      # cần cho download Douyin
cp .env.example .env             # rồi điền key vào

Hai cách dịch — chọn 1

Bước dịch transcript là bước duy nhất cần can thiệp tay. Sau khi ASR xong, pipeline tự dừng và tạo file TRANSLATE_PENDING.txt trong work dir, chứa hướng dẫn cụ thể cho cả 2 cách dưới.

Cách A — Người dùng Claude Code (full auto)

Mở repo trong Claude Code và bảo:

Translate the transcript at output/VN/2026xxxx_vi to Vietnamese.

Hoặc gọi skill trực tiếp:

/translate-video-segments

Skill đọc transcript_original.json, dịch theo style rules (xem .claude/skills/translate-video-segments/), ghi transcript_vi.json. Pipeline tự resume.

Toàn bộ workflow từ link đến video xuất ra chạy 1 lần — không cần can thiệp vì Claude Code tự chạy pipeline_vi.py phase 1, gọi skill, rồi chạy --resume.

Cách B — Không có Claude Code, không cần API key (ChatGPT / Gemini web)

Khi pipeline dừng, mở <work_dir>/TRANSLATE_PENDING.txt. File này chứa sẵn một prompt chuẩn + hướng dẫn từng bước:

  1. Mở transcript_original.json trong work dir

  2. Mở ChatGPT hoặc Gemini (web). Bắt đầu chat mới

  3. Copy đoạn ----- PROMPT TO COPY ----- từ TRANSLATE_PENDING.txt, dán vào chat, dán tiếp nội dung transcript_original.json rồi gửi

  4. AI trả về một JSON array. Copy lại

  5. Lưu thành transcript_vi.json (UTF-8) cùng folder với transcript_original.json

  6. Chạy resume:

    python pipeline_vi.py --resume "<work_dir>" --file <video_gốc.mp4>

Pipeline phát hiện file dịch, skip bước dịch, tiếp tục TTS → mix → xuất video.

Lưu ý: prompt trong TRANSLATE_PENDING.txt đã bao gồm rules giọng văn YouTube (bạn/mình/các bạn, drop tiếng đệm 啊/呢/嘛, pinyin tên Trung, romanization tên Hàn), rules length-aware theo duration mỗi segment, và format JSON output strict.

Sử dụng

Lồng tiếng Việt

# YouTube/Douyin URL
python pipeline_vi.py --url "https://v.douyin.com/..." --source-lang zh --voice male

# File local
python pipeline_vi.py --file input/video.mp4 --source-lang zh --voice male

# Tham số BGM
python pipeline_vi.py --url ... --bg-mode demucs          # mặc định, chất lượng
python pipeline_vi.py --url ... --bg-mode duck            # nhanh, giảm -12 dB
python pipeline_vi.py --url ... --bg-mode duck --bg-duck-db -15
python pipeline_vi.py --url ... --bg-mode none            # bỏ BGM

Lồng tiếng Nhật

python pipeline.py --url ... --source-lang en --voice ja-JP-KeitaNeural

Resume sau khi dịch tay

python pipeline_vi.py --resume "output/VN/20260601120000_vi" --file input/video.mp4
python pipeline.py --resume "output/20260601120000" --file input/video.mp4

Batch nhiều video

Mở web UI, vào trang Batch, dán nhiều URL, mỗi dòng một URL. Backend sẽ tạo một job riêng cho từng URL và chạy qua hàng đợi web.

Source Layout

auto_translate_video/
├── pipeline/        # VI/JP pipeline orchestration
├── cli/             # utility command implementations
├── downloader*.py   # YouTube/TikTok/Douyin acquisition
├── transcriber.py   # Azure Speech ASR
├── synthesizer*.py  # JP/VI TTS
└── *_merger.py      # audio/video composition

backend/             # FastAPI web API
frontend/            # Next.js UI
tests/               # Python regression tests

Root scripts such as pipeline_vi.py and download_video.py are compatibility wrappers around the packaged code. Batch processing is handled by the web API.

Cấu trúc output

output/VN/20260601120000_vi/
├── <video_id>.mp4                  # video gốc đã download
├── original_audio.wav              # audio gốc 16kHz mono
├── no_vocals.wav                   # BGM tách (chỉ khi --bg-mode demucs)
├── vocals.wav                      # giọng tách (chỉ khi --bg-mode demucs)
├── transcript_original.json        # ASR output
├── transcript_original.srt
├── TRANSLATE_PENDING.txt           # hướng dẫn dịch (xoá sau khi dịch xong)
├── transcript_vi.json              # bản dịch (Path A hoặc B tạo)
├── transcript_vi.srt
├── segments/seg_xxx.wav            # TTS từng segment
├── dubbed_audio.wav                # audio cuối (VI + BGM)
└── dubbed_video.mp4                # video cuối

Tính năng

  • Download Douyin (Playwright), TikTok, YouTube, 1000+ site qua yt-dlp
  • ASR Azure Speech (zh-CN, en, ja, vi, …)
  • 3 chế độ BGM:
    • demucs — tách giọng/nhạc bằng Demucs (htdemucs), chất lượng cao
    • duck — giảm volume audio gốc theo --bg-duck-db rồi đè TTS lên
    • none — base silent, không giữ BGM
  • TTS:
    • VI — LucyLab (giọng male / female)
    • JP — Azure Neural Voice (mặc định ja-JP-KeitaNeural)
  • Timeline fit: tự atempo (max 1.4x) khi TTS dài hơn segment gốc
  • Resume từ work dir (--resume)
  • Batch nhiều URL trực tiếp trên web UI
  • Sinh SRT (original + dịch)
  • Sinh metadata YouTube (title/description/tags) + thumbnail prompts qua Gemini (nếu có google_api_key)

License

MIT.