Skip to main content

Agent Framework plugin for Speechmatics

Project description

Speechmatics STT plugin for LiveKit Agents

Support for Speechmatics STT.

See https://docs.livekit.io/agents/integrations/stt/speechmatics/ for more information.

Installation

pip install livekit-plugins-speechmatics

Diarization

Speechmatics STT engine can be configured to emit information about individual speakers in a conversation. This needs to be enabled using enable_diarization=True. The text output of the transcription can be configured to include this information using the macros speaker_id and text, as shown in the examples below.

  • <{speaker_id}>{text}</{speaker_id}> -> <S1>Hello</S1>
  • [Speaker {speaker_id}] {text} -> [Speaker S1] Hello

You should adjust your system instructions to inform the LLM of this format for speaker identification.

Usage (Speechmatics end of utterance detection and speaker ID)

To use the Speechmatics end of utterance detection and speaker ID, you can use the following configuration.

Note: The turn_detection_mode parameter tells the plugin to control the end of turn detection. The default mode is ADAPTIVE, which means that the plugin will control the end of turn detection using the plugin's own VAD detection and the pace of speech. In the example below, we use the default ADAPTIVE mode. The turn_detection="stt" parameter tells the plugin to use the STT engine's end of turn detection.

from livekit.agents import AgentSession
from livekit.plugins import speechmatics

agent = AgentSession(
    stt=speechmatics.STT(
        speaker_active_format="[Speaker {speaker_id}] {text}",
        speaker_passive_format="[Speaker {speaker_id} *PASSIVE*] {text}",
        additional_vocab=[
            speechmatics.AdditionalVocabEntry(
                content="LiveKit",
                sounds_like=["live kit"],
            ),
        ],
    ),
    turn_detection="stt",
    ...
)

Usage (LiveKit Turn Detection)

To use the LiveKit end of turn detection, the format for the output text needs to be adjusted to not include any extra content at the end of the utterance. Using [Speaker S1] ... as the speaker_active_format should work well. You may need to adjust your system instructions to inform the LLM of this format for speaker identification. You must also include the listener for when the VAD has detected the end of speech.

The end_of_utterance_silence_trigger parameter controls the amount of silence before the end of turn detection is triggered. The default is 0.5 seconds.

Usage:

from livekit.agents import AgentSession
from livekit.plugins.turn_detector.multilingual import MultilingualModel
from livekit.plugins import speechmatics, silero

agent = AgentSession(
    stt=speechmatics.STT(
        end_of_utterance_silence_trigger=0.2,
        speaker_active_format="[Speaker {speaker_id}] {text}",
        speaker_passive_format="[Speaker {speaker_id} *PASSIVE*] {text}",
    ),
    vad=silero.VAD.load(),
    turn_detection=MultilingualModel(),
    min_endpointing_delay=0.3,
    max_endpointing_delay=5.0,
    ...
)

Pre-requisites

You'll need to specify a Speechmatics API Key. It can be set as environment variable SPEECHMATICS_API_KEY or .env.local file.

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

livekit_plugins_speechmatics-1.5.4.tar.gz (14.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

livekit_plugins_speechmatics-1.5.4-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

Details for the file livekit_plugins_speechmatics-1.5.4.tar.gz.

File metadata

File hashes

Hashes for livekit_plugins_speechmatics-1.5.4.tar.gz
Algorithm Hash digest
SHA256 42765603cee5c605692f40370916e3bf57dbf05146dd6d743fc53f96d31e7233
MD5 4723a2dc297d8db8c1c06645fac6232f
BLAKE2b-256 4f7834b68cc5c5e82a0a7ec5f01369f79b1d0c8a772da4c946b95544609cb2e1

See more details on using hashes here.

Provenance

The following attestation bundles were made for livekit_plugins_speechmatics-1.5.4.tar.gz:

Publisher: publish.yml on livekit/agents

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file livekit_plugins_speechmatics-1.5.4-py3-none-any.whl.

File metadata

File hashes

Hashes for livekit_plugins_speechmatics-1.5.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a633d0a1feed8c087ab911a535f962e19497a94a0ac53f7fb5dc449a5bf06cda
MD5 128ddcd4c817d408b7ea63cce80411ca
BLAKE2b-256 cdc3ef80fd3bf1c12e9cd8c8d6cfb6a4b6b1797b5bd68ca57b854b6f1e21add4

See more details on using hashes here.

Provenance

The following attestation bundles were made for livekit_plugins_speechmatics-1.5.4-py3-none-any.whl:

Publisher: publish.yml on livekit/agents

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page