How marouane53/transcribe works
Project type and purpose
• This is an open-source, single-script CLI tool for transcribing audio/video files (local or YouTube) via the Wit.ai API.
• It’s not a web or full-stack app but a standalone Python-based pipeline that orchestrates downloads, media conversion, API calls, and file output.
Main components
A. CLI / Entry Point (transcribe.py)
• Parses user input (YouTube URL vs. local file, language choice).
• Loads configuration (.env via python-dotenv).
B. Configuration Manager
• Reads environment variables (WIT_API_KEY_*).
• Feeds API keys into the transcription module.
C. Download Manager (yt-dlp)
• If a YouTube URL is provided, invokes yt-dlp to fetch audio/video.
• Stores downloaded media under downloads/.
D. Media Processor (ffmpeg, ffmpeg-python, pydub)
• Converts MP3→WAV, extracts audio from video containers (MP4/MKV/AVI).
• Ensures input to transcription is always WAV.
E. Transcription Core (tafrigh[wit] wrapper)
• Sends audio chunks to Wit.ai using the appropriate API key.
• Receives JSON/text responses.
F. Output Generator
• Transforms transcription results into .TXT and .SRT files.
• Writes them next to the source media.
G. External Services
• Wit.ai for speech-to-text.
• YouTube as an optional download source.
Relationships and data flow
1. User invokes transcribe.py via CLI.
2. Config Manager loads API keys.
3. CLI hands off to Download Manager (if needed) or directly to Media Processor.
4. Media Processor normalizes to WAV.
5. Normalized audio → Transcription Core → Wit.ai.
6. API returns text → Output Generator → TXT/SRT.
CLI → Config Manager
↓
Download Manager → Media Processor → Transcription Core → Output Generator
Architectural patterns & design principles
• Pipeline/Chain of Responsibility: each module performs one step and passes results downstream.
• Single-process, modular separation: each concern (download, convert, transcribe, output) is encapsulated.
• External-service integration: clearly delineate boundaries between local processing and remote API calls.