- Project Name: Scrible Wise
- Project Type: Audio transcription tool with WebM video conversion
- Primary Language: Python
- Package Manager: uv
- Version: Python 3.13+
- Package Management Tool:
uv(preferred) - Virtual Environment: Managed by
uv
torch>=2.7.1torchaudio>=2.7.1transformers>=4.53.3soundfile>=0.12.1librosa>=0.10.0ffmpeg-python>=0.2.0- FFmpeg integration for video conversionopenai>=1.97.1- OpenAI API client for cloud transcriptionopenai-whisper>=20250625- Local OpenAI Whisper modelsnumpy
ruff>=0.8.0- Fast Python linterblack>=24.0.0- Code formatterisort>=5.13.0- Import sortermypy>=1.13.0- Type checkerpytest>=8.0.0- Testing frameworkpytest-mock>=3.12.0- Mock support for pytestpytest-asyncio>=0.25.0- Async test supportpre-commit>=4.0.0- Pre-commit hooks
- Recommended: Apple Silicon (MPS)
- Fallback: CPU
- Not Supported: CUDA (auto-switching configured)
- FFmpeg: Required for WebM to MP3 conversion
- macOS:
brew install ffmpeg - Ubuntu/Debian:
sudo apt install ffmpeg - Windows: Download from https://ffmpeg.org
- macOS:
- System: Local TodoWrite tool
- Status Tracking: Using Claude Code built-in todo functionality
- Task Sync: No external integration needed
# Install dependencies
uv sync
# Install with dev dependencies
uv sync --extra dev
# Run new CLI interface (recommended)
uv run python -m cli.main input.webm
# Run with custom output
uv run python -m cli.main input.webm output.txt
# Use specific model
uv run python -m cli.main input.webm --model local_whisper_base
# List available models
uv run python -m cli.main --list-models
# Get model information
uv run python -m cli.main --model-info local_breeze
# Show help and options
uv run python -m cli.main --help
# Run legacy interface
uv run python main.py
# Check Python version
uv run python --version
# Add new dependencies
uv add <package_name># Run linter
uv run ruff check main.py
# Auto-fix linting issues
uv run ruff check --fix main.py
# Format code
uv run black main.py
# Sort imports
uv run isort main.py
# Type checking
uv run mypy main.py# Install pre-commit hooks (one-time setup)
uv run pre-commit install
# Run hooks manually on all files
uv run pre-commit run --all-files
# Run hooks on specific files
uv run pre-commit run --files main.py- Testing Framework: pytest with asyncio and mocking support
- Test Coverage: 115+ test cases covering all modules, services, and integration scenarios
- Test Execution:
uv run pytest -v - Model Testing: Comprehensive testing for all 6 transcription models
- CLI Testing: Complete CLI interface and model selection testing
- Manual Testing: Use
meeting.mp3for legacy testing, any supported format for CLI testing - Output Validation: Check
transcription.txtcompleteness and CLI status messages
- Style: Clean, self-documenting code
- Comments: English comments, minimal but meaningful
- Naming: Consistent formatting and naming conventions
- Linting: Ruff for fast Python linting
- Formatting: Black for consistent code formatting
- Import Sorting: isort with Black profile
- Type Checking: MyPy for static type analysis (optional)
- Pre-commit Hooks: Automatic code quality checks before commits
scrible-wise/
├── main.py # Legacy transcription program
├── meeting.mp3 # Test audio file
├── transcription.txt # Output results
├── cli/ # CLI interface modules
│ ├── __init__.py
│ ├── main.py # Main CLI entry point
│ └── integration.py # CLI integration layer
├── transcription/ # Core workflow modules
│ ├── __init__.py
│ └── workflow.py # Complete transcription workflow
├── converters/ # Media conversion modules
│ ├── __init__.py
│ └── media_converter.py # WebM to MP3 converter
├── validators/ # Audio validation modules
│ ├── __init__.py
│ └── audio_validator.py # Audio file validator
├── utils/ # Utility modules
│ ├── __init__.py
│ ├── ffmpeg_checker.py # FFmpeg dependency checker
│ ├── file_detector.py # File type detection
│ └── error_recovery.py # Error handling and retry logic
├── config/ # Configuration management
│ ├── __init__.py
│ └── model_config.py # Model configuration and management
├── services/ # Transcription service abstraction
│ ├── __init__.py
│ ├── base.py # Base transcription service interface
│ ├── local_breeze.py # MediaTek Breeze service
│ ├── local_whisper.py # Local Whisper service
│ └── openai_service.py # OpenAI API service
├── exceptions/ # Custom exception hierarchy
│ ├── __init__.py
│ ├── base.py # Base exception classes
│ ├── conversion.py # Conversion-related exceptions
│ ├── validation.py # Validation-related exceptions
│ └── transcription.py # Transcription-related exceptions
├── tests/ # Comprehensive test suites
│ ├── __init__.py
│ ├── test_*.py # Unit tests for all modules (115+ total)
│ ├── test_workflow_error_integration.py # Integration tests
│ ├── test_workflow_model_integration.py # Model integration tests
│ └── test_cli_model_selection.py # CLI model selection tests
├── PRD/ # Product Requirements Documents
│ └── webm-to-mp3-transcription.md
├── pyproject.toml # Project configuration
├── uv.lock # Dependency lock
├── .pre-commit-config.yaml # Pre-commit configuration
├── .gitignore # Git ignore rules
├── README.md # Project documentation
└── CLAUDE.md # This configuration file
- Audio Loading:
torchaudio.load()supports MP3 and other formats - Audio Preprocessing: Mono conversion, resampling to 16kHz
- Multi-Model Support: 6 different transcription models (local & cloud)
- MediaTek Breeze-ASR-25 (默認中文模型)
- OpenAI Whisper Base/Small/Medium/Large (本地模型)
- OpenAI Whisper API (雲端服務)
- Service Architecture: Unified interface with dynamic model loading
- Chunked Processing: 30-second segment processing for long audio
- Result Merging: Concatenates all segment transcription results
- FFmpeg Integration: Cross-platform video conversion support
- File Type Detection: Automatic format recognition (WebM, MP4, MP3, etc.)
- Media Conversion: Async WebM to MP3 conversion with quality control
- Audio Validation: Comprehensive audio file validation and reporting
- Quality Levels: Configurable bitrate (128k/160k/256k)
- Timeout Handling: Configurable conversion timeouts
- Simple Command:
uv run python -m cli.main input.webm - Model Selection:
--modelparameter for choosing transcription models - Model Management:
--list-modelsand--model-infocommands - Automatic Output: Auto-generates output filenames if not specified
- Format Support: Handles all supported audio/video formats
- User-friendly Messages: Clear success/error reporting with emojis
- Help System: Built-in help, version, format, and diagnostics information
- Custom Exception Hierarchy: ScribbleWiseError, ConversionError, ValidationError, TranscriptionError
- Retry Mechanisms: Configurable exponential backoff with jitter
- Recovery Suggestions: Context-aware error messages with solution guidance
- Temporary File Management: Automatic cleanup on errors and completion
- Graceful Degradation: Fallback strategies for common failure scenarios
- Auto-detects MPS availability
- Graceful fallback to CPU
- Model loading to corresponding device
cli/: Advanced command-line interface with model selection capabilitiestranscription/: Complete workflow orchestration with multi-model supportconfig/: Model configuration management and service abstractionservices/: Transcription service implementations (local & cloud)utils/: Core utility functions (FFmpeg, file detection, error recovery)converters/: Media conversion logic with retry mechanismsvalidators/: Audio file validation with detailed reportingexceptions/: Custom exception hierarchy for precise error handlingtests/: Comprehensive test coverage with TDD methodology (115+ test cases)
- Issue:
torchaudiocannot load MP3 - Solution: Install
soundfileandlibrosa
- Issue: macOS doesn't support CUDA
- Solution: Auto-switch to MPS or CPU
- Issue: Whisper defaults to processing only first 30 seconds
- Solution: Implemented chunked processing functionality
- Chunk Length: 30 seconds
- Model Parameters:
max_length=448,num_beams=1 - Memory Management: Using
torch.no_grad()
- Processing Speed: Approximately 1:1 real-time ratio (Apple Silicon)
- Memory Usage: ~2-3GB after model loading
- Accuracy: Good Chinese speech recognition performance
- Dependency Updates: Regularly check
transformers,torch, andopenaiversions - Model Cache: First run downloads models, requires internet connection
- Disk Space: Local models require ~1-2GB each, plan accordingly
- API Keys: Store OpenAI API key securely in environment variables
- Compatibility: Primarily optimized for macOS Apple Silicon
- Model Selection: Different models have varying memory requirements and accuracy
Run pre-commit before create a git commit
Using conventional commits format:
feat: new featurefix: bug fixdocs: documentation updaterefactor: code refactoringperf: performance optimization
Example: feat: implement long audio chunking for complete transcription