Multilingual Speaker Encoder with Multi-branch Architecture for Few-shot Voice Synthesis
Project description
Speaker Encoder Pipeline
A multilingual speaker encoder with multi-branch architecture for few-shot voice synthesis. This package provides a robust speaker encoding system that captures timbre, cadence, and self-supervised learning features.
Features
- Multi-branch Architecture: Combines timbre, cadence, and SSL features
- Multilingual Support: English and Tamil language support
- Few-shot Learning: Efficient speaker encoding with minimal audio samples
- Modular Design: Easy to extend and customize
- CI/CD Ready: Fully configured with GitHub Actions
Installation
From PyPI (when published)
pip install speaker-encoder-pipeline
From Source
git clone https://github.com/yourusername/Zero_shotVoiceClone.git
cd speaker_encoder_pipeline
# Install in development mode
pip install -e ".[dev]"
Quick Start
Basic Usage
from model.encoder import MultilingualSpeakerEncoder
from config import SAMPLE_RATE
import torch
# Initialize model
encoder = MultilingualSpeakerEncoder(config)
# Prepare audio (mono, 16kHz)
audio = torch.randn(batch_size, SAMPLE_RATE * duration)
# Get speaker embedding
embedding = encoder(audio)
print(embedding.shape) # (batch_size, embedding_dim)
Command-line Interface
# Prepare data
speaker-encoder-prepare --data-dir ./data
# Train model
speaker-encoder-train --epochs 100 --batch-size 32
# Validate speakers
speaker-encoder-validate --model-path ./models/best_model.pt
# Evaluate performance
speaker-encoder-evaluate --test-dir ./test_data
Development Setup
Installation with Dev Dependencies
pip install -e ".[dev]"
Running Tests
# Run all tests
pytest
# Run with verbose output
pytest -v
# Run specific test file
pytest tests/test_model.py
# Run specific test
pytest tests/test_model.py::TestMultilingualSpeakerEncoder::test_forward_pass
# Run with coverage report
pytest --cov=model --cov=data --cov=train --cov=utils --cov-report=html
# Run only unit tests
pytest -m unit
# Run without slow tests
pytest -m "not slow"
# Run in parallel (faster)
pytest -n auto
Code Quality
# Format code with black
black model/ data/ train/ utils/
# Check imports with isort
isort model/ data/ train/ utils/
# Lint with flake8
flake8 model/ data/ train/ utils/
# Type checking with mypy
mypy model/ data/ train/ utils/
Package Structure
speaker_encoder_pipeline/
├── model/
│ ├── encoder.py # Main encoder architecture
│ ├── timbre_branch.py # Timbre extraction
│ ├── cadence_branch.py # Cadence extraction
│ ├── ssl_branch.py # SSL features
│ ├── fusion.py # Feature fusion
│ └── loss.py # Loss functions
├── data/
│ ├── dataset.py # Dataset classes
│ ├── preprocessor.py # Audio preprocessing
│ ├── augmentations.py # Data augmentation
│ ├── sampler.py # Sampling strategies
│ └── __init__.py
├── train/
│ ├── dataloader.py # Data loading
│ └── __init__.py
├── utils/
│ ├── audio_utils.py # Audio utilities
│ └── __init__.py
├── tests/
│ ├── test_model.py # Model tests
│ ├── test_data.py # Data tests
│ ├── test_train.py # Training tests
│ ├── test_package.py # Package structure tests
│ └── conftest.py # Pytest configuration
├── config.py # Configuration
├── setup.py # Package setup
├── pyproject.toml # Modern Python packaging
├── pytest.ini # Pytest configuration
├── requirements.txt # Core dependencies
├── requirements-dev.txt # Development dependencies
└── README.md # This file
Configuration
Edit config.py to customize:
- Audio parameters (sample rate, channels, format)
- Dataset paths and sources
- Model architecture parameters
- Training hyperparameters
Publishing to PyPI
1. Update Version
# Update version in version.txt
echo "0.2.0" > version.txt
# Commit changes
git add version.txt
git commit -m "Bump version to 0.2.0"
2. Create a Git Tag
git tag -a v0.2.0 -m "Release version 0.2.0"
git push origin v0.2.0
3. GitHub Actions will automatically:
- Run all tests on multiple Python versions and OSes
- Build distribution packages (wheel and sdist)
- Publish to PyPI (requires
PYPI_API_TOKENsecret in GitHub) - Create a GitHub Release
4. Configure PyPI Token (one-time setup)
In your GitHub repository:
- Go to Settings → Secrets and variables → Actions
- Add a new secret:
PYPI_API_TOKEN - Generate token at https://pypi.org/manage/account/token/
Testing
The project uses pytest with the following markers:
@pytest.mark.unit- Unit tests@pytest.mark.integration- Integration tests@pytest.mark.slow- Slow tests@pytest.mark.gpu- GPU-required tests@pytest.mark.model- Model-specific tests@pytest.mark.data- Data processing tests@pytest.mark.train- Training tests
CI/CD Workflow
The GitHub Actions workflow (python-package.yml):
-
Test Job: Runs on every push and pull request
- Tests on Ubuntu, Windows, and macOS
- Python 3.9, 3.10, 3.11
- Linting with flake8
- Code formatting with black
- Import sorting with isort
- Coverage reports to Codecov
-
Build and Publish Job: Runs on version tags
- Builds distribution packages
- Validates with twine
- Publishes to PyPI
- Creates GitHub Release
Contributing
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature - Make changes and write tests
- Ensure all tests pass:
pytest - Format code:
blackandisort - Commit and push to your fork
- Create a Pull Request
License
MIT License - see LICENSE file for details
Citation
If you use this package in your research, please cite:
@software{speaker_encoder_2025,
title={Speaker Encoder Pipeline},
author={Your Name},
year={2025},
url={https://github.com/yourusername/Zero_shotVoiceClone}
}
Support
For issues and questions:
- Open an issue on GitHub
- Check existing documentation
- Review test cases for usage examples
Changelog
Version 0.1.0 (Initial Release)
- Multi-branch speaker encoder
- Multilingual support (English, Tamil)
- Complete training pipeline
- CI/CD with GitHub Actions
- PyPI packaging support
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file speaker_encoder_pipeline-0.1.1.tar.gz.
File metadata
- Download URL: speaker_encoder_pipeline-0.1.1.tar.gz
- Upload date:
- Size: 29.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c0bd088932f110ec287be656cd714873b39d8e618f4cb88c85806f1193501b3
|
|
| MD5 |
02e2512b8d69734f6bccc567bacdb377
|
|
| BLAKE2b-256 |
7c792cf2ccbd001bea7bfcce4f33759564a918828b22ed8f0766a8eab3f2d381
|
File details
Details for the file speaker_encoder_pipeline-0.1.1-py3-none-any.whl.
File metadata
- Download URL: speaker_encoder_pipeline-0.1.1-py3-none-any.whl
- Upload date:
- Size: 24.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a174fe4b0c579483c8bb9649ff9daf61b2cb6fb1860b687e5cc8dc8245b03c9a
|
|
| MD5 |
f04972c3b77b62d369861e42a208f066
|
|
| BLAKE2b-256 |
325a8852e2b7fce43c07ca30b776bbfaffb559a5009f1f979549b342a237e456
|