⚠️ IMPORTANT DISCLAIMER This is an independent, community-developed plugin and is NOT officially affiliated with or endorsed by LiveKit or Yandex.This project is NOT part of either the official LiveKit or Yandex ecosystems.
For issues, support, or contributions related to this plugin, please use this project's repository directly.
Do not use LiveKit's or Yandex's official support channels for plugin-specific matters.
This document provides detailed development information for the Yandex SpeechKit STT plugin for LiveKit Agents.
- Development Setup
- Project Structure
- Development Workflow
- Testing Strategy
- Code Quality
- Utilities and Tools
- Debugging
- Contributing
- External API Documentation
Required Tools:
- Python 3.9+
- Official Yandex Cloud SDK - automatically installed as a dependency
- Make (Optional): While not strictly required for development (as Hatch handles build and environment management),
a
Makefileis provided for convenience with common commands.- Windows users: If you wish to use the
Makefile,makecan be installed via Chocolatey:choco install make. - Other OS:
makeis typically available through system package managers (e.g.,apt-get install makeon Debian/Ubuntu,brew install makeon macOS).
- Windows users: If you wish to use the
- FFmpeg (Optional - for test fixture generation): Needed if you plan to use or modify the
utils/fixture_generator.pyscript to create/convert audio test files. If you only intend to run existing tests with provided fixtures, or not work with fixtures at all, FFmpeg is not strictly necessary for core plugin development or usage.- Windows: Install via Chocolatey:
choco install ffmpeg - macOS: Install via Homebrew:
brew install ffmpeg - Linux: Install via package manager:
sudo apt-get install ffmpeg(Ubuntu/Debian)
- Windows: Install via Chocolatey:
-
Clone the repository:
git clone git@github.com:sergerdn/livekit-plugins-yandex.git cd livekit-plugins-yandex -
Install development dependencies using Hatch:
Option 1: Using Makefile (recommended):
make install
Option 2: Using Hatch directly:
# Create the default Hatch environment and install dependencies hatch env create # Install the plugin in editable mode with dev dependencies hatch run pip install -e ".[dev]" # Optional: Install with fixtures support (Windows TTS for test audio generation) hatch run pip install -e ".[dev,fixtures]" # Activate the environment for the current session hatch shell
-
Set up environment variables:
# Copy the example environment file cp .env.example .env # Edit .env with your Yandex Cloud credentials # YANDEX_API_KEY=your_api_key_here # YANDEX_FOLDER_ID=your_folder_id_here
-
Verify installation:
# Test that the plugin can be imported hatch run python -c "from livekit.plugins import yandex; print('Plugin installed successfully')"
The fixtures optional dependency category includes Windows-specific tools for generating test audio files:
What's included:
pywin32==310- Windows COM interface for accessing Windows TTS (SAPI)
When to install:
- You're developing on Windows
- You need to regenerate speech test fixtures
- You're working with the
utils/fixture_generator.pyscript
Installation:
# Install with fixtures support
hatch run pip install -e ".[dev,fixtures]"
# Or just fixtures without dev dependencies
hatch run pip install -e ".[fixtures]"Note: This is only available on Windows (sys_platform == 'win32') and is completely optional. The plugin works
without it, and existing test fixtures are provided via Git LFS.
Important: After cloning the repository, if developers want to run tests with fixtures (functional and e2e tests), they need to check out Git LFS files:
# Install Git LFS if not already installed
git lfs install
# Pull LFS files (audio test fixtures)
git lfs pullWhat's included:
- Sample audio files in multiple languages (Russian, English)
- Various audio formats and sample rates for testing
- Test fixtures for functional and end-to-end tests
livekit-plugins-yandex/
├── livekit/plugins/yandex/ # Main plugin code
│ ├── __init__.py # Public API exports
│ ├── stt.py # Main STT implementation
│ ├── _utils.py # Internal utilities
│ ├── models.py # Type definitions
│ ├── log.py # Logging configuration
│ ├── version.py # Version information
│ └── yandex_api.py # Yandex Cloud API helpers (uses official SDK)
├── tests/ # Test suite
│ ├── conftest.py # Shared test configuration
│ ├── unit/ # Unit tests (no external deps)
│ │ ├── conftest.py
│ │ └── test_stt.py
│ ├── integration/ # Integration tests (requires credentials)
│ │ ├── conftest.py
│ │ └── test_stt.py
│ ├── functional/ # Functional tests (requires audio)
│ │ ├── conftest.py
│ │ └── test_stt.py
│ ├── e2e/ # End-to-end tests (full workflow)
│ │ ├── conftest.py
│ │ └── test_real_audio_processing.py
│ └── fixtures/ # Test audio files
│ └── *.wav # Generated audio fixtures
├── utils/ # Development utilities
│ ├── README.md
│ ├── fixture_generator.py # Audio fixture generator
│ └── __init__.py
├── docs/ # Documentation
├── pyproject.toml # Project configuration
├── Makefile # Development commands
├── README.md # Basic usage documentation
├── DEVELOPMENT.md # This file
└── .env.example # Environment template
-
Start development session:
# Activate environment hatch shell # Or see available commands make help
-
Run linters before coding:
make lint
-
Make changes and test:
# Run unit tests (fast, no credentials needed) make test_unit # Run integration tests (requires credentials) make test_integration # Run all tests make test
-
Fix code style issues:
make lint_fix
Code Changes:
- Follow existing code style and patterns
- Add type hints for all public APIs
- Update docstrings for any API changes
- Add tests for new functionality
Adding Features:
- Write unit tests first (TDD approach)
- Implement the feature
- Add integration tests if needed
- Update documentation
- Run full test suite
Bug Fixes:
- Write a test that reproduces the bug
- Fix the bug
- Ensure the test passes
- Run regression tests
Unit Tests (tests/unit/):
- No external dependencies
- Mock all external services
- Fast execution (< 1 second)
- Test individual components in isolation
Integration Tests (tests/integration/):
- Require real Yandex Cloud credentials
- Test component interactions
- Moderate execution time
- Test API integration without audio processing
Functional Tests (tests/functional/):
- Require credentials AND audio files
- Test end-to-end functionality
- Slower execution
- Test real audio processing
End-to-End Tests (tests/e2e/):
- Require credentials AND audio files
- Test complete workflows
- Comprehensive real-world scenarios
- Full integration testing
# Unit tests only (no credentials required)
make test_unit
# Integration tests (requires .env with credentials)
make test_integration
# Functional tests (no credentials required)
make test_functional
# All end-to-end tests (plugin + agent)
make test_e2e
# Plugin-level E2E tests (STT functionality, requires Yandex credentials)
make test_e2e_plugin
# Agent-level E2E tests (LiveKit integration, requires LiveKit + Yandex credentials)
make test_e2e_agent
# All tests
make test
# Fixture validation tests (checks test infrastructure)
make test_fixturesThe E2E tests are organized into two distinct categories:
- Purpose: Test STT plugin functionality with real Yandex Cloud API
- Requirements: Yandex credentials only (
YANDEX_API_KEY,YANDEX_FOLDER_ID) - Scope: Audio processing, transcription accuracy, STT streaming, error handling
- Run with:
make test_e2e_plugin
- Purpose: Test LiveKit room management and agent deployment (NOT STT functionality)
- Requirements: LiveKit credentials (Yandex credentials only for full pipeline tests)
- Scope: Room creation/deletion, participant connections, agent deployment, LiveKit infrastructure
- Run with:
make test_e2e_agent - Infrastructure: Dedicated infrastructure modules for room management
For debugging individual tests with dependencies:
When developing, you may want to run a specific test that depends on other tests without running the full dependency
chain. Use the --ignore-unknown-dependency flag:
# Run individual test ignoring missing dependencies (development only)
hatch run pytest tests/test_fixture_validation.py::TestFixtureValidation::test_audio_fixtures_available -v --ignore-unknown-dependency
# Run specific functional test without running fixture validation first
hatch run pytest tests/functional/test_stt.py::TestYandexSTTAudioProcessing::test_specific_method -v --ignore-unknown-dependency
# Run specific plugin E2E test
hatch run pytest tests/e2e/plugin_e2e/test_real_audio_processing.py::TestRealAudioProcessing::test_russian_audio_processing -v --ignore-unknown-dependency
# Run specific agent E2E test
hatch run pytest tests/e2e/agent_e2e/test_basic_livekit_integration.py::TestBasicLiveKitIntegration::test_basic_room_creation_and_cleanup -v --ignore-unknown-dependencyImportant Notes:
- This flag should only be used during development/debugging
- Do not use this flag in CI/CD or production test runs
- The flag allows tests to run even if their dependencies haven't been validated
- Use this when you want to quickly test a specific piece of functionality during development
Audio Fixtures: Generate test audio files using the fixture generator:
# Generate all fixtures (speech + basic audio)
make fixtures
# Generate only speech fixtures
make fixtures_speech
# Generate only basic fixtures (tones, noise)
make fixtures_basic
# List available TTS voices
make fixtures_voicesThe project uses multiple tools for code quality:
- Black: Code formatting
- isort: Import sorting
- flake8: Style guide enforcement
- pylint: Code analysis
- mypy: Type checking
- docformatter: Docstring formatting
# Check all linters
make lint
# Auto-fix issues
make lint_fixAll public APIs must have type hints:
from typing import Optional, Dict, Any
from livekit.agents import stt
def process_audio(
audio_data: bytes,
language: Optional[str] = None,
options: Optional[Dict[str, Any]] = None
) -> stt.SpeechEvent:
"""Process audio data and return speech events."""
...- All public classes and methods must have docstrings
- Use Google-style docstrings
- Include type information in docstrings
- Provide usage examples for complex APIs
Unified tool for generating test audio files:
Features:
- Cross-platform TTS support (Windows SAPI, macOS say, Linux espeak)
- Basic audio generation (tones, noise, silence)
- Proper file naming with content descriptions
- Validation and reporting
Requirements:
- For Windows TTS: Install with
hatch run pip install -e ".[fixtures]"(includes pywin32) - For other platforms: Basic installation is enough
Usage:
# Generate all fixtures
python utils/fixture_generator.py --type all
# Generate only speech
python utils/fixture_generator.py --type speech
# Generate only basic audio
python utils/fixture_generator.py --type basic
# List TTS voices
python utils/fixture_generator.py --list-voices
# Custom output directory
python utils/fixture_generator.py --output-dir custom/pathmake help # Show all available commands
make install # Install development dependencies
make lint # Check code quality
make lint_fix # Auto-fix code issues
make test # Run all tests
make test_unit # Run unit tests only
make test_integration # Run integration tests
make test_functional # Run functional tests
make fixtures # Generate test fixtures
make build # Build the package
make clean # Clean build artifactsImport Errors:
# Ensure package is installed in development mode
pip install -e .gRPC Issues:
# Check if Yandex Cloud SDK is properly installed
hatch run python -c "from yandex.cloud.ai.stt.v3 import stt_pb2; print('Yandex Cloud SDK working')"Test Failures:
# Check credentials
echo $YANDEX_API_KEY
echo $YANDEX_FOLDER_ID
# Generate test fixtures
make fixturesRun specific tests:
# Single test file
pytest tests/unit/test_stt.py -v
# Single test class
pytest tests/unit/test_stt.py::TestYandexCredentials -v
# Single test method
pytest tests/unit/test_stt.py::TestYandexCredentials::test_credentials_creation -vDebug with verbose output:
pytest tests/ -v -s --tb=longEnable debug logging:
import logging
logging.basicConfig(level=logging.DEBUG)
# Or for specific logger
logger = logging.getLogger("livekit.plugins.yandex")
logger.setLevel(logging.DEBUG)To test the plugin with LiveKit Agents in a real cloud environment:
-
Set up LiveKit Cloud credentials
Add the following to your
.envfile:# LiveKit Cloud credentials LIVEKIT_API_KEY=your_livekit_api_key LIVEKIT_API_SECRET=your_livekit_api_secret LIVEKIT_WS_URL=wss://your-project.livekit.cloud -
Run agent integration tests
make test_agent
-
Interpreting results
The tests validate:
- Successful connection to LiveKit Cloud
- Agent session creation with Yandex STT
- Real-time audio processing
- Transcription delivery
- Session cleanup
-
Troubleshooting
- Ensure both Yandex and LiveKit credentials are valid
- Check Yandex Cloud account balance - E2E tests will fail if account balance is negative
- Check network connectivity to both services
This plugin includes comprehensive REAL LiveKit Cloud integration tests that provide complete end-to-end validation of the LiveKit pipeline.
All tests create rooms in LiveKit Cloud that can be monitored at: https://cloud.livekit.io/projects/*/sessions
Tests use descriptive room names that indicate the test type and expected participant counts for easy debugging:
test-simple-expect-0p-room-XXXXXXXX- Simple infrastructure tests with 0 participants expectedtest-simple-expect-1p-room-XXXXXXXX- Simple connection tests with 1 participant expectedtest-agent-expect-2p-room-XXXXXXXX- Agent tests with 2 participants expected (agent and participant)
When running tests, check the LiveKit dashboard to verify:
- ✅ Participant count matches the number in the room name
- ✅ Room duration reflects test execution time
- ✅ Status shows "Closed" after test completion
- ✅ No resource leaks (all rooms properly cleaned up)
Dashboard Data Delay: LiveKit Cloud dashboard may have up to 30-minute delay for:
- Participant count updates
- Session detail synchronization
- Room status changes
Brief Connection Handling: Tests with very short durations (1–3 seconds) may:
- Not appear in dashboard sampling
- Show 0 participants even if participants connected briefly
- This is normal behavior for quick infrastructure tests
The LiveKit integration includes production-ready infrastructure components:
- Real LiveKit rooms - Actual room creation/deletion via LiveKit Cloud API
- Real participant simulation - WebSocket connections with threaded execution to avoid event loop conflicts
- Real agent deployment - Agents connect to rooms and process audio through a complete pipeline
- Resource management - Proper cleanup with session monitoring
- Type-safe implementation - Zero
Anytypes, no# type: ignorecomments
# Recommended: Use Makefile target (stable, fast)
make test_livekit_basic
# Or run individual tests manually:
# Test room creation/deletion (0 participants expected)
hatch run pytest tests/e2e_agent/test_basic_livekit_integration.py::TestBasicLiveKitIntegration::test_basic_room_creation_and_cleanup -v
# Test participant connection (1 participant expected)
hatch run pytest tests/e2e_agent/test_basic_livekit_integration.py::TestBasicLiveKitIntegration::test_participant_connection_to_room -v
# Note: Full test suite includes complex agent tests that may hang
# Use make test_livekit_basic for stable infrastructure testingAfter running tests, check the LiveKit Cloud dashboard:
- Go to: https://cloud.livekit.io/projects/*/sessions
- Look for rooms with descriptive names like
test-simple-expect-1p-room-abc12345 - Verify participant counts match the expected number in the room name
- Check duration reflects test execution time
- Confirm status shows "Closed" after completion
Issue: Room shows 0 participants but test passed
- Cause: Very brief connection (< 3 seconds) not captured by dashboard sampling
- Solution: This is normal for quick infrastructure tests
Issue: Room not visible in the dashboard
- Cause: Dashboard sync delay (up to 30 minutes)
- Solution: Wait or check test logs for room creation confirmation
Issue: Participant count mismatch
- Cause: Timing issues or cleanup order
- Solution: Check test logs for connection/disconnection events
Issue: Tests fail with connection errors
- Cause: LiveKit credentials or network issues
- Solution: Verify
.envfile has correct LiveKit Cloud credentials
Issue: E2E tests fail with Yandex API errors
- Cause: Negative Yandex Cloud account balance
- Solution: Top up your Yandex Cloud account balance before running E2E tests
- Yandex Account Balance Verification: Implement automatic balance checks before running E2E tests
- Balance-dependent Test Skipping: Skip E2E tests automatically when account balance is insufficient
- Balance Monitoring: Add balance monitoring and warnings in test output
TRUE end-to-end validation of the complete LiveKit pipeline: Participant → Room → Agent → STT → Transcription
This infrastructure provides the foundation for comprehensive agent testing with Russian STT processing in real LiveKit environments.
- Verify audio fixtures are available
- Enable DEBUG logging for detailed information
-
Run full test suite:
make test -
Check code quality:
make lint
-
Update documentation:
- Update README.md for user-facing changes
- Update DEVELOPMENT.md for development changes
- Add docstrings for new APIs
-
Clean up:
make clean
- Use clear, descriptive commit messages
- Reference issue numbers when applicable
- Keep commits focused and atomic
- Test before committing
- Fork the repository on GitHub
- Create feature branch from main
- Make changes with tests
- Update documentation
- Run full test suite
- Submit pull request with description to this repository
Important: Submit issues and pull requests to this project's repository at: https://github.com/sergerdn/livekit-plugins-yandex
Required for Integration/Functional Tests:
YANDEX_API_KEY: Your Yandex Cloud API keyYANDEX_FOLDER_ID: Your Yandex Cloud folder ID
Optional:
YANDEX_STT_ENDPOINT: Custom STT endpoint (defaults to Yandex Cloud)LOG_LEVEL: Logging level (DEBUG, INFO, WARNING, ERROR)
- STT initialization is lightweight (< 100ms)
- Streaming sessions have minimal overhead
- Audio processing is done by Yandex Cloud
- Network latency affects real-time performance
- Consider connection pooling for high-volume usage
- Never commit credentials to version control
- Use environment variables for sensitive data
- Rotate API keys regularly
- Monitor API usage and costs
- Use least-privilege access for Yandex Cloud resources
For developers looking to understand the underlying Yandex SpeechKit API in more detail, especially for advanced scenarios not directly covered by this plugin's abstractions, the following resources may be helpful:
- Streaming audio from a microphone (Official Yandex Cloud Docs - Russian): https://github.com/yandex-cloud/docs/blob/master/ru/speechkit/stt/api/microphone-streaming.md This document provides insights into direct microphone input with the SpeechKit API, which can be useful for debugging or extending plugin capabilities.