Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions examples/voice/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,6 @@ async def main() -> None:
# Set chunk size
config.chunk_size = args.chunk_size

# Set common items
config.enable_diarization = True

# Handle config display
if args.show_compact:
print(config.to_json(indent=2, exclude_unset=True, exclude_none=True))
Expand Down
9 changes: 4 additions & 5 deletions sdk/voice/speechmatics/voice/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ def __init__(
# -------------------------------------

# Default to EXTERNAL if no config or preset string provided
if config is None and not preset:
if config is None and preset is None:
config = VoiceAgentConfigPreset.EXTERNAL()

# Check for preset
elif preset:
elif preset is not None:
preset_config = VoiceAgentConfigPreset.load(preset)
config = VoiceAgentConfigPreset._merge_configs(preset_config, config)

Expand Down Expand Up @@ -1085,7 +1085,7 @@ async def _add_speech_fragments(self, message: dict[str, Any], is_final: bool =
is_final=is_final,
attaches_to=result.get("attaches_to", ""),
content=alt.get("content", ""),
speaker=alt.get("speaker", None),
speaker=alt.get("speaker", "UU"),
confidence=alt.get("confidence", 1.0),
volume=result.get("volume", None),
result={"final": is_final, **result},
Expand Down Expand Up @@ -1382,8 +1382,7 @@ async def _emit_segments(self, finalize: bool = False) -> None:
self._turn_start_time = self._current_view.start_time

# Send updated speaker metrics
if self._dz_enabled:
self._calculate_speaker_metrics(partial_segments, final_segments)
self._calculate_speaker_metrics(partial_segments, final_segments)

# Emit end of turn
if finalize:
Expand Down
2 changes: 1 addition & 1 deletion tests/tts/async_http_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


@pytest.mark.asyncio
@pytest.mark.skipif(os.getenv("SPEECHMATICS_API_KEY") is None, reason="Skipping test if API key is not set")
@pytest.mark.skipif(os.getenv("SPEECHMATICS_API_KEY") is None, reason="Skipping test if API key is not set")
async def test_async_http():
async with AsyncClient() as client:
async with await client.generate(text="Hello world") as response:
Expand Down
47 changes: 47 additions & 0 deletions tests/voice/test_15_esl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import asyncio
import os

import pytest
from _utils import get_client
from _utils import log_client_messages
from _utils import send_audio_file

from speechmatics.voice._presets import VoiceAgentConfigPreset

# Skip for CI testing
pytestmark = pytest.mark.skipif(os.getenv("CI") == "true", reason="Skipping transcription tests in CI")

# Skip if ESL tests is not enabled
pytestmark = pytest.mark.skipif(os.getenv("TEST_ESL", "0").lower() not in ["1", "true"], reason="Skipping ESL tests")

# Constants
API_KEY = os.getenv("SPEECHMATICS_API_KEY")
URL = os.getenv("TEST_ESL_URL", "ws://localhost:8080/v2")
SHOW_LOG = os.getenv("SPEECHMATICS_SHOW_LOG", "0").lower() in ["1", "true"]


@pytest.mark.asyncio
async def test_esl():
"""Local ESL inference."""

# Client
client = await get_client(api_key=API_KEY, url=URL, connect=False, config=VoiceAgentConfigPreset.FAST())

# Add listeners
log_client_messages(client)

# Connect
await client.connect()

# Check we are connected
assert client._is_connected

# Load the audio file `./assets/audio_01_16kHz.wav`
await send_audio_file(client, "./assets/audio_01_16kHz.wav")

# Wait 5 seconds
await asyncio.sleep(5)

# Close session
await client.disconnect()
assert not client._is_connected
Loading