This project provides a complete pipeline for localizing English videos into Arabic, using the Fanar API. It performs:
- Audio extraction from video
- Music/vocals separation (Demucs)
- Speech-to-text transcription (with smart model selection)
- Grammar improvement of English transcript (LLM)
- Translation to Arabic
- Arabic reformulation for TTS (LLM, concise and natural)
- Extraction of quoted/target speech for TTS
- Text-to-speech synthesis (Arabic)
- Duration matching (pad/trim TTS to match original)
- Music re-mixing (combine separated music with Arabic TTS)
- Recombination of dubbed audio and video
- Download videos from YouTube or upload your own
- Extracts and separates music from any video file
- Transcribes speech using Fanar STT model (auto or manual model selection)
- Enhances and grammatically corrects transcripts using Fanar Chat
- Translates English to Arabic using Fanar MT
- Reformulates Arabic for smooth, natural TTS (shorter, simpler sentences)
- Extracts only quoted/target speech for dubbing
- Generates natural-sounding Arabic audio using Fanar TTS
- Matches TTS audio duration to original for lip sync
- Mixes separated music back with dubbed speech
- Merges audio with the original video (with removed audio)
- Automatic filename generation with original title + "arabic dub" suffix
- Automatic cleanup of temporary files (optional)
FanarVideoLocalization/
├── dubbing_ui.py # Main Streamlit application
├── dubbing_utils.py # Core processing functions and API client
├── cleanup.py # Cleanup script for temporary files
├── requirements.txt # Python dependencies
├── README.md # This file
└── .gitignore # Git ignore rules
- Install dependencies:
pip install -r requirements.txt - Create a
.envfile in the project root and add your Fanar API key:FANAR_API_KEY=your_fanar_api_key_here - Run the app:
streamlit run dubbing_ui.py
The project generates temporary files during processing. To clean up:
python cleanup.pyThis removes:
- Temporary audio/video files
- Transcription and translation files
- Demucs output directories
- Python cache files
- Upload a video file or paste a YouTube URL
- The app will automatically:
- Extract audio and separate music/vocals
- Transcribe speech and improve grammar
- Translate and reformulate Arabic for TTS
- Extract quoted/target speech for dubbing
- Synthesize Arabic speech, match duration, and mix with music
- Generate final video with Arabic dub
- Download the final video with descriptive filename