Skip to main content

Speaker Recognition for Home Assistant

Python Version License Home Assistant

Identify speakers by their voice using machine learning. This project provides a complete speaker recognition solution for Home Assistant, including a REST API service, Python client library, custom integration, and Home Assistant addon.

✨ Features

  • 🎤 Voice-based speaker identification using neural embeddings
  • 🏠 Native Home Assistant integration with STT and conversation agents
  • 🐳 Easy deployment via Home Assistant addon or standalone Docker
  • 🔌 REST API for flexible integration with any platform
  • 📦 Python client library for programmatic access
  • 🎯 High accuracy powered by Resemblyzer voice embeddings
  • ⚡ Fast recognition with cached embeddings
  • 🔧 Configurable via UI or YAML

📋 Table of Contents

🚀 Installation

Home Assistant Addon

The easiest way to use speaker recognition in Home Assistant:

  1. Add this repository to your Home Assistant addon store
  2. Install the Speaker Recognition addon
  3. Configure the addon settings:
    • Host: 0.0.0.0 (default)
    • Port: 8099 (default)
    • Embeddings Directory: /share/speaker_recognition/embeddings
    • Log Level: info
  4. Start the addon
  5. Install the Speaker Recognition integration via the UI

Python Package

Install the client-only package (no ML dependencies):

pip install speaker-recognition

Install with server capabilities (requires Python <3.10):

pip install speaker-recognition[server]

Docker

Run the standalone service:

docker run -d \
  -p 8099:8099 \
  -v ./embeddings:/app/embeddings \
  ghcr.io/eulemitkeule/speaker-recognition:latest

📖 Usage

Training

Train the system with voice samples for each speaker:

Using Python Client

from speaker_recognition import SpeakerRecognitionClient
from speaker_recognition.models import TrainingRequest, VoiceSample, AudioInput

async with SpeakerRecognitionClient("http://localhost:8099") as client:
    training = await client.train(
        TrainingRequest(
            voice_samples=[
                VoiceSample(
                    user="Alice",
                    audio_input=AudioInput(
                        audio_data="<base64-encoded-audio>",
                        sample_rate=16000
                    )
                ),
                VoiceSample(
                    user="Bob",
                    audio_input=AudioInput(
                        audio_data="<base64-encoded-audio>",
                        sample_rate=16000
                    )
                )
            ]
        )
    )
    print(f"Trained {training.speakers_count} speakers")

Using REST API

curl -X POST http://localhost:8099/train \
  -H "Content-Type: application/json" \
  -d '{
    "voice_samples": [
      {
        "user": "Alice",
        "audio_input": {
          "audio_data": "<base64-audio>",
          "sample_rate": 16000
        }
      }
    ]
  }'

Recognition

Identify a speaker from audio:

Using Python Client

from speaker_recognition import SpeakerRecognitionClient
from speaker_recognition.models import RecognitionRequest, AudioInput

async with SpeakerRecognitionClient("http://localhost:8099") as client:
    result = await client.recognize(
        RecognitionRequest(
            audio_input=AudioInput(
                audio_data="<base64-encoded-audio>",
                sample_rate=16000
            )
        )
    )
    print(f"Speaker: {result.speaker} (confidence: {result.confidence:.2%})")

Home Assistant Integration

Once the integration is configured:

  1. Configure the backend in the main integration entry
  2. Map voices to users in the integration settings
  3. Add STT entity as a sub-entry for speech-to-text with speaker ID
  4. Add Conversation Agent as a sub-entry for voice commands with speaker context

The integration will automatically identify speakers and make the information available to your automations.

🔌 API Documentation

Endpoints

GET /health

Health check endpoint.

Response:

{
  "status": "healthy"
}

POST /train

Train the model with voice samples.

Request:

{
  "voice_samples": [
    {
      "user": "string",
      "audio_input": {
        "audio_data": "base64-string",
        "sample_rate": 16000
      }
    }
  ]
}

Response:

{
  "speakers_count": 2,
  "message": "Training completed successfully"
}

POST /recognize

Recognize a speaker from audio.

Request:

{
  "audio_input": {
    "audio_data": "base64-string",
    "sample_rate": 16000
  }
}

Response:

{
  "speaker": "Alice",
  "confidence": 0.95
}

⚙️ Configuration

Addon Configuration

host: "0.0.0.0"
port: 8099
log_level: "info"
access_log: true
embeddings_dir: "/share/speaker_recognition/embeddings"

Environment Variables

  • HOST: Server host (default: 0.0.0.0)
  • PORT: Server port (default: 8099)
  • LOG_LEVEL: Logging level (default: info)
  • ACCESS_LOG: Enable access logs (default: true)
  • EMBEDDINGS_DIR: Directory for storing embeddings (default: ./embeddings)

🛠️ Development

Prerequisites

  • Python 3.9 (for server development)
  • Python 3.8+ (for client-only development)
  • uv package manager

Setup

# Clone the repository
git clone https://github.com/eulemitkeule/speaker-recognition.git
cd speaker-recognition

# Install dependencies
uv sync --all-groups

# Run tests
uv run pytest tests/ -v

# Run linting
uv run ruff check .

# Run type checking
uv run mypy --strict speaker_recognition

Running Locally

# Start the server
uv run python -m speaker_recognition

# Or with custom options
uv run python -m speaker_recognition --host 0.0.0.0 --port 8099

Project Structure

speaker-recognition/
├── speaker_recognition/          # Main package
│   ├── api.py                   # FastAPI application
│   ├── client.py                # HTTP client
│   ├── models.py                # Pydantic models
│   └── recognizer.py            # Recognition logic
├── custom_components/           # Home Assistant integration
│   └── speaker_recognition/
├── speaker_recognition_addon/   # Home Assistant addon
├── tests/                       # Test suite
└── example_data/               # Example audio files

🤝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Run tests and linting
  5. Commit your changes (git commit -m 'Add amazing feature')
  6. Push to the branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

Code Quality

  • Follow PEP 8 style guidelines
  • Use descriptive variable and function names
  • Add type annotations
  • Write tests for new features
  • Keep methods focused and concise

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

📞 Support


Made with ❤️ for the Home Assistant community

Metadata

Release files for hass-speaker-recognition 1.0.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hass-speaker-recognition 1.0.12
File Size Uploaded
hass_speaker_recognition-1.0.12.tar.gz 12.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hass-speaker-recognition 1.0.12
File Interpreter ABI Platform
hass_speaker_recognition-1.0.12-py3-none-any.whl Python 3 none any Details

Total release size: 25.0 kB

Release files / hass_speaker_recognition-1.0.12.tar.gz

Download URL hass_speaker_recognition-1.0.12.tar.gz
Size 12.0 kB
Tags Source
SHA-256 checksum
How to use checksums
5ae390f573b1c00816166bb323ebfaffe5a9dfe4439d3e3a6c6864ff03b45a89
BLAKE2b-256 checksum
How to use checksums
76c3f39fab9aeb06ebd43236d42da13977fb0dbfa9a81890fb27321a988f1ae3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 30, 2025.

Transparency log

Release files / hass_speaker_recognition-1.0.12-py3-none-any.whl

Download URL hass_speaker_recognition-1.0.12-py3-none-any.whl
Size 13.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2d4bbd7f11e0a9350a61988c4e6b468d3987f9ff44ecccb54d919ea557228fbc
BLAKE2b-256 checksum
How to use checksums
cdb2c75e4808e2eb9354d1032d228562e19f3a5231d0148c5d7970e47788ca6a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 30, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.12 This release

2 release files

1.0.11

2 release files

1.0.10

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page