How szluk133/csdl_dpt works
Project type and purpose
• This is a small full-stack Python web application for speech processing.
• It provides a web UI (in templates/index.html + static/css/style.css) served by FastAPI (web.py), accepts or triggers audio embedding extraction (ex_ebd.py using SpeechBrain and Torch), and persists or queries data in MySQL.
Analysis of the file structure
• Top-level scripts:
• ex_ebd.py – the audio embedding extraction module (SpeechBrain + PyTorch + SciPy).
• web.py – the FastAPI HTTP server exposing routes for the UI and for upload/processing endpoints.
• Static assets (static/css/style.css) and a Jinja-style template (templates/index.html).
• No separate “backend” or “frontend” folders, but responsibilities are clearly divided:
• Templates + static → frontend
• web.py + ex_ebd.py → backend
• Configuration is minimal; dependencies are managed via virtualenv and pip.
Key insights from the README
• Tech stack: Python, FastAPI, Uvicorn, SpeechBrain, PyTorch, MySQL.
• Run flow:
1. Activate venv
2. pip install dependencies
3. python ex_ebd.py (can be used standalone or imported)
4. python web.py (starts the HTTP server)
Main components
a. Frontend
• Browser UI (templates/index.html + CSS)
• HTTP(S) client
b. API Server (Backend)
• FastAPI app (web.py)
• Uvicorn ASGI server
• Routes:
• GET / → serves index.html
• POST /upload or /embed → accepts audio files (python-multipart)
c. Audio Processing Module
• ex_ebd.py logic
• Libraries: SpeechBrain, NumPy, SciPy, PyTorch, torchaudio, PySoundFile
d. Database
• MySQL instance
• Connector: mysql-connector-python
e. (Optional) External integrations
• flack (Slack?) if used for notifications
Relationships and data flows
• Browser → HTTP POST to FastAPI → uploads audio
• FastAPI route handler → calls audio processing functions in ex_ebd.py
• ex_ebd.py → loads model weights (SpeechBrain/Torch), computes embeddings → returns arrays
• API handler → uses mysql-connector to INSERT or SELECT embeddings in MySQL
• API handler → returns JSON result → Browser renders response
Architectural patterns/design principles
• Separation of concerns:
• Static + template = presentation layer
• FastAPI = application layer (HTTP, request validation)
• ex_ebd.py = domain layer (audio processing business logic)
• MySQL = persistence layer
• Single-process, monolithic architecture (no microservices); but clear module boundaries
• Dependency injection via import of ex_ebd in web.py
• Async or sync endpoints (can be extended to async for I/O)