How weifeng2333/asrtools works
Project type and purpose
• AsrTools is a desktop GUI application (no separate backend server or database) for batch-processing audio/video files into subtitle formats (.srt, .txt, .ass).
• Built with Python, it uses PyQt5/qfluentwidgets for the UI, a strategy of pluggable ASR engine implementations in bk_asr/, and the requests library to call external ASR services.
File structure
• Top‐level files:
• asr_gui.py – entry point, PyQt5 UI setup and event loop
• example.py – demonstration or CLI usage
• requirements.txt – dependencies (requests; optional PyQt5, qfluentwidgets)
• Directory bk_asr/: ASR engine abstraction (BaseASR.py), data structures (ASRData.py), and concrete engine subclasses (JianYingASR.py, KuaiShouASR.py, WhisperASR.py, BcutASR.py).
• resources/: sample media files and screenshots.
• No database or service mesh; multi‐threaded file I/O and HTTP calls to third‐party ASR APIs.
README
• Describes user workflow: select ASR engine, add files/folders, click “Start,” then subtitle files appear alongside source.
• Highlights multi‐threaded batch processing, no GPU needed, support for video→audio conversion.
a. Main components
• Presentation/UI Layer – asr_gui.py with PyQt5 windows, controls, drag-drop area, progress indicators
• Application/Controller Layer – task manager or job dispatcher that spins up threads, schedules ASR tasks
• ASR Engine Layer – BaseASR abstraction (strategy pattern) plus concrete classes (Whisper, JianYing, etc.)
• Media Preprocessor – optional ffmpeg subprocess for video→audio conversion
• Subtitle Formatter – logic to build .srt/.txt/.ass from ASRData
• File System – input file picker, output directory writer
• External ASR Service APIs – HTTP endpoints invoked via requests library
b. Relationships and data flows
1. User interacts with UI → sends “start job” event to Controller
2. Controller enqueues jobs → passes file path to Media Preprocessor (if video)
3. Preprocessor outputs audio → hands off to selected ASR Engine
4. ASR Engine (concrete) calls external API or local model → returns ASRData
5. Controller forwards ASRData to Subtitle Formatter → writes subtitle file to disk
6. UI listens for progress/status signals from Controller → updates progress bars/log
c. Architectural patterns/design principles
• Strategy pattern for interchangeable ASREngine implementations
• MVC–like separation: UI (View), Controller (job scheduling, multi-threading), Model (ASRData)
• Single responsibility: each bk_asr/*.py focuses on one engine’s API integration
• Observer pattern (Qt signals/slots) for UI updates on asynchronous tasks
d. Key technologies and libraries
• PyQt5 & qfluentwidgets (UI toolkit)
• Python threading or QThreadPool (concurrency)
• requests (HTTP client for ASR service calls)
• ffmpeg (external binary invoked for video→audio)
• Standard library modules: pathlib/argparse/subprocess/threading