Development#

Project Structure#

audio2face/
โ”œโ”€โ”€ apis/                    # Streaming API implementations
โ”œโ”€โ”€ data_structures/         # Core data models and Protocol Buffers
โ”œโ”€โ”€ infer/                   # Inference engines (ONNX and PyTorch)
โ”œโ”€โ”€ postprocess/             # Postprocessing modules and pipelines
โ”œโ”€โ”€ service/                 # FastAPI server and error handling
โ”œโ”€โ”€ split/                   # Audio splitting and segmentation
โ”œโ”€โ”€ utils/                   # Utility functions and base classes
โ””โ”€โ”€ tests/                   # Comprehensive test suite

Testing#

The project includes comprehensive tests with pytest and async testing support. Before running tests, you need to prepare the test input data.

Test Data Preparation#

Download the required test files and organize them in the correct directory structure:

  1. Create test input directory:

    mkdir -p input
    
  2. Download test files:

  3. Ensure weights directory exists:

    mkdir -p weights
    

    Make sure you have the ONNX model file weights/unitalker_v0.4.0_base.onnx (see Data Preparation section).

  4. Final directory structure should be:

    โ”œโ”€audio2face
    โ”œโ”€configs
    โ”œโ”€docs
    โ”œโ”€input
    โ”‚  โ”œโ”€test_audio.wav
    โ”‚  โ””โ”€test_feature.npy
    โ””โ”€weights
       โ””โ”€unitalker_v0.4.0_base.onnx
    

Running Tests#

# Run all tests
pytest tests --log-cli-level=ERROR

# Run specific test categories
pytest tests/apis/           # API functionality tests
pytest tests/infer/          # Inference engine tests
pytest tests/postprocess/    # Postprocessing module tests
pytest tests/data_structures/ # Data structure tests

Test Coverage#

  • API Tests: Streaming API functionality

  • Inference Tests: ONNX Unitalker and PyTorch feature extractor validation

  • Postprocessing Tests: All postprocessing modules with various configurations

  • Data Structure Tests: FaceClip class functionality and format conversions

Code Quality#

The project maintains high code quality with:

  • Linting: Ruff for code style and quality checks

  • Type Hints: Full type annotation support

  • CI/CD: Automated testing and deployment pipelines