A comprehensive video processing tool that automatically translates YouTube videos into Chinese with dubbed voice-over.
- YouTube Video Download: Download any YouTube video with high quality
- Speech-to-Text: Convert video audio to text subtitles
- Translation: Translate English subtitles to Chinese
- Text-to-Speech: Convert Chinese subtitles to natural-sounding speech
- Audio Mixing: Merge translated speech with original video
- Ad Removal: Automatically detect and remove advertisement segments
- Python 3.8+
- FFmpeg
- Internet connection for API services
-
Clone the repository:
git clone [repository-url] cd magic_video -
Set up environment variables: Create a
.envfile in the project root with the following API keys:ASSEMBLYAI_API_KEY=your_assemblyai_key OPENAI_API_KEY=your_openai_key FISH_API_KEY=your_fish_audio_sdk_key
Run the main script with a YouTube URL:
python main.py https://www.youtube.com/watch?v=VIDEO_ID
The processing pipeline includes:
- Downloading the video and audio from YouTube
- Converting audio to subtitles
- Translating subtitles to Chinese
- Converting Chinese subtitles to speech
- Merging the translated speech with the original video
- Removing advertisement segments
main.py: Main processing pipelinedownload_youtube.py: YouTube video downloaderaudio_to_subtitle.py: Audio to text conversiontranslate_subtitles.py: Subtitle translationsubtitle_to_speech.py: Text to speech conversionmerge_audio.py: Audio-video mergingdetect_ads.py: Advertisement detectionresources/: Directory for all processed filesvideos/: Downloaded videosaudios/: Audio filestranscripts/: Subtitle filesresults/: Final processed videos
Main dependencies include:
- yt-dlp
- assemblyai
- openai
- ffmpeg-python
- fish-audio-sdk
- demucs
- pydub
GNU GPL
- AssemblyAI for speech-to-text services
- OpenAI for translation services
- Fish Audio SDK for text-to-speech services