Skip to content

Commit 67cfede

Browse files
committed
Enhance speaker recognition service with transcription and diarization features
- Updated `.env.template` to include configuration options for transcription providers (Deepgram and Parakeet) and diarization modes. - Modified `docker-compose.yml` and `docker-compose-test.yml` to support new environment variables for transcription services. - Refactored `Dockerfile` to use JSON form for CMD to allow environment variable expansion. - Added a new `laptop_client.py` script for command-line interactions with the speaker recognition service. - Introduced a transcription orchestrator to manage transcription and diarization processes. - Updated dependencies in `pyproject.toml` to use the latest version of `pyannote.audio`. - Implemented new service structure for transcription and diarization, including base classes and specific providers for Deepgram and Parakeet. - Enhanced logging and error handling for better service reliability and debugging.
1 parent c75e9eb commit 67cfede

23 files changed

Lines changed: 4429 additions & 4194 deletions

‎extras/speaker-recognition/.env.template‎

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,35 @@ REACT_UI_HOST=0.0.0.0
3939
REACT_UI_PORT=5174
4040
REACT_UI_HTTPS=false
4141

42-
# Optional: External Services
42+
# ===================================================================
43+
# Transcription Provider Configuration
44+
# ===================================================================
45+
46+
# Choose transcription provider: 'deepgram' or 'parakeet'
47+
# If not set, auto-detects based on available credentials
48+
TRANSCRIPTION_PROVIDER=deepgram
49+
50+
# Option 1: Deepgram (cloud-based, requires API key)
4351
DEEPGRAM_API_KEY=your_deepgram_api_key_here
52+
53+
# Option 2: Parakeet ASR (local/offline transcription)
54+
# Point to Parakeet service from extras/asr-services or backends/advanced
55+
# PARAKEET_ASR_URL=http://parakeet-asr:8767
56+
57+
# ===================================================================
58+
# Diarization Configuration
59+
# ===================================================================
60+
61+
# Speaker diarization mode: auto, native, pyannote, or none
62+
# - auto: Use provider's native diarization if available, otherwise Pyannote (default)
63+
# - native: Use only provider's native diarization (Deepgram has native, Parakeet doesn't)
64+
# - pyannote: Always use standalone Pyannote diarization
65+
# - none: Skip diarization entirely (transcription only)
66+
DIARIZATION_MODE=auto
67+
68+
# ===================================================================
69+
# Other External Services
70+
# ===================================================================
4471
GROQ_API_KEY=your_groq_api_key_here
4572

4673
# Test Configuration (for docker-compose-test.yml)

‎extras/speaker-recognition/Dockerfile‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@ ENV PYTHONPATH=/app
4141
EXPOSE 8085
4242

4343
# Run the service
44-
# Use shell form to allow environment variable expansion
45-
CMD uv run --extra ${PYTORCH_CUDA_VERSION} --no-dev simple-speaker-service
44+
# Use JSON form with shell wrapper for environment variable expansion
45+
CMD ["sh", "-c", "uv run --extra ${PYTORCH_CUDA_VERSION} --no-dev simple-speaker-service"]

‎extras/speaker-recognition/README.md‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ cp .env.template .env
1515
# Edit .env and add your Hugging Face token
1616
```
1717
Get your HF token from https://huggingface.co/settings/tokens
18-
Accept the terms and conditions for
19-
https://huggingface.co/pyannote/speaker-diarization-3.1
18+
Accept the terms and conditions for
19+
https://huggingface.co/pyannote/speaker-diarization-community-1
2020
https://huggingface.co/pyannote/segmentation-3.0
2121

2222

@@ -829,7 +829,7 @@ The advanced backend communicates with this service through the `client.py` modu
829829

830830
## Laptop Client
831831

832-
A command-line client (`laptop_client.py`) that can record from your microphone and interact with the speaker recognition service.
832+
A command-line client (`scripts/laptop_client.py`) that can record from your microphone and interact with the speaker recognition service.
833833

834834
### Setup for Laptop Client
835835

@@ -854,22 +854,22 @@ pip install pyaudio
854854
docker compose --profile cpu up -d
855855

856856
# Enroll a new speaker (records 10 seconds)
857-
python laptop_client.py enroll --speaker-id "john" --speaker-name "John Doe" --duration 10
857+
python scripts/laptop_client.py enroll --speaker-id "john" --speaker-name "John Doe" --duration 10
858858

859859
# Identify a speaker (records 5 seconds)
860-
python laptop_client.py identify --duration 5
860+
python scripts/laptop_client.py identify --duration 5
861861

862862
# Verify against a specific speaker (records 3 seconds)
863-
python laptop_client.py verify --speaker-id "john" --duration 3
863+
python scripts/laptop_client.py verify --speaker-id "john" --duration 3
864864

865865
# List all enrolled speakers
866-
python laptop_client.py list
866+
python scripts/laptop_client.py list
867867

868868
# Remove a speaker
869-
python laptop_client.py remove --speaker-id "john"
869+
python scripts/laptop_client.py remove --speaker-id "john"
870870

871871
# Use different service URL
872-
python laptop_client.py --service-url "http://192.168.1.100:8001" identify
872+
python scripts/laptop_client.py --service-url "http://192.168.1.100:8001" identify
873873
```
874874

875875
### Laptop Client Features

‎extras/speaker-recognition/docker-compose-test.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ services:
55
context: .
66
dockerfile: Dockerfile
77
args:
8-
PYTORCH_CUDA_VERSION: ${COMPUTE_MODE:-cpu}
8+
PYTORCH_CUDA_VERSION: ${PYTORCH_CUDA_VERSION:-cpu}
99
image: speaker-recognition:test
1010
ports:
1111
# Map host test port (default 8086) to container port 8085

‎extras/speaker-recognition/docker-compose.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ services:
2626
- SIMILARITY_THRESHOLD=${SIMILARITY_THRESHOLD:-0.15}
2727
- SPEAKER_SERVICE_HOST=${SPEAKER_SERVICE_HOST:-0.0.0.0}
2828
- SPEAKER_SERVICE_PORT=${SPEAKER_SERVICE_PORT:-8085}
29+
# Transcription provider configuration
30+
- TRANSCRIPTION_PROVIDER=${TRANSCRIPTION_PROVIDER:-deepgram}
2931
- DEEPGRAM_API_KEY=${DEEPGRAM_API_KEY}
32+
- PARAKEET_ASR_URL=${PARAKEET_ASR_URL:-http://parakeet-asr:8767}
3033
restart: unless-stopped
3134
healthcheck:
3235
test: ["CMD", "curl", "-f", "http://localhost:8085/health"]

‎extras/speaker-recognition/phone-hangout-1-response.json‎

Whitespace-only changes.

‎extras/speaker-recognition/pyproject.toml‎

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ dependencies = [
88
"fastapi>=0.115.12",
99
"uvicorn>=0.34.2",
1010
"scipy>=1.10.0",
11-
"pyannote.audio>=3.3.2",
11+
"pyannote.audio>=4.0.0",
1212
"aiohttp>=3.8.0",
1313
"python-multipart>=0.0.6",
1414
"pydantic>=2.0.0",
@@ -43,26 +43,20 @@ cpu = [
4343
"torchaudio>=2.0.0",
4444
]
4545

46-
cu121 = [
47-
"torch>=2.0.0",
48-
"torchaudio>=2.0.0",
49-
]
50-
5146
cu126 = [
52-
"torch>=2.0.0",
53-
"torchaudio>=2.0.0",
47+
"torch>=2.8.0",
48+
"torchaudio>=2.8.0",
5449
]
5550

5651
cu128 = [
57-
"torch>=2.0.0",
58-
"torchaudio>=2.0.0",
52+
"torch>=2.8.0",
53+
"torchaudio>=2.8.0",
5954
]
6055

6156
[tool.uv]
6257
conflicts = [
6358
[
6459
{ extra = "cpu" },
65-
{ extra = "cu121" },
6660
{ extra = "cu126" },
6761
{ extra = "cu128" },
6862
],
@@ -71,13 +65,11 @@ conflicts = [
7165
[tool.uv.sources]
7266
torch = [
7367
{ index = "pytorch-cpu", extra = "cpu" },
74-
{ index = "pytorch-cu121", extra = "cu121" },
7568
{ index = "pytorch-cu126", extra = "cu126" },
7669
{ index = "pytorch-cu128", extra = "cu128" },
7770
]
7871
torchaudio = [
7972
{ index = "pytorch-cpu", extra = "cpu" },
80-
{ index = "pytorch-cu121", extra = "cu121" },
8173
{ index = "pytorch-cu126", extra = "cu126" },
8274
{ index = "pytorch-cu128", extra = "cu128" },
8375
]
@@ -87,11 +79,6 @@ name = "pytorch-cpu"
8779
url = "https://download.pytorch.org/whl/cpu"
8880
explicit = true
8981

90-
[[tool.uv.index]]
91-
name = "pytorch-cu121"
92-
url = "https://download.pytorch.org/whl/cu121"
93-
explicit = true
94-
9582
[[tool.uv.index]]
9683
name = "pytorch-cu126"
9784
url = "https://download.pytorch.org/whl/cu126"

‎extras/speaker-recognition/run-test.sh‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,14 @@ fi
5555

5656
print_info "Speaker Recognition Integration Test Runner"
5757
print_info "=========================================="
58-
print_info "HF_TOKEN length: ${#HF_TOKEN}"
59-
print_info "DEEPGRAM_API_KEY length: ${#DEEPGRAM_API_KEY}"
60-
print_info ".env file exists: $([ -f .env ] && echo 'yes' || echo 'no')"
6158

62-
# Load environment variables (CI or local)
63-
if [ -f ".env" ] && [ -z "$HF_TOKEN" ]; then
59+
# Load environment variables (CI or local) - BEFORE checking them
60+
if [ -f ".env" ]; then
6461
print_info "Loading environment variables from .env..."
6562
set -a
6663
source .env
6764
set +a
68-
elif [ -n "$HF_TOKEN" ]; then
65+
elif [ -n "${HF_TOKEN:-}" ]; then
6966
print_info "Using environment variables from CI..."
7067
# Set up CI-specific environment variables that would normally be in .env
7168
export SIMILARITY_THRESHOLD=0.15
@@ -111,8 +108,10 @@ if [ -z "$DEEPGRAM_API_KEY" ]; then
111108
exit 1
112109
fi
113110

114-
print_info "HF_TOKEN length: ${#HF_TOKEN}"
115-
print_info "DEEPGRAM_API_KEY length: ${#DEEPGRAM_API_KEY}"
111+
# Now we can safely check the variables
112+
print_info "Environment configuration:"
113+
print_info " HF_TOKEN length: ${#HF_TOKEN}"
114+
print_info " DEEPGRAM_API_KEY length: ${#DEEPGRAM_API_KEY}"
116115

117116
# Install dependencies with uv
118117
print_info "Installing dependencies with uv..."
File renamed without changes.

0 commit comments

Comments
 (0)