Built for scale, trusted by developers
234,857
Registered developers supported on our portal
4,851
Tickets successfully solved by our support team
234,857
Registered developers supported on our portal
4,851
Tickets successfully solved by our support team
Wall of fame
Amazing projects built by our community using Speechmatics API

AI Agent Builder
How to build a conversational agent in less time than Cupid’s arrow takes to strike
What happens when you set out to build a fully functioning AI love guru with very little turnaround time? Let's find out...
Farah GoudaData Engineer
![[alt: Livekit and Speechmatics partnership]](/_next/image?url=https%3A%2F%2Fimages.ctfassets.net%2Fyze1aysi0225%2F55uo621nIAzecVIcDsrrGX%2Fa81809b4dcf9acd1883ce628f8a10552%2FLiveKit-blog_assets-V1_-_Header_16-9.webp&w=3840&q=75)
Voice Agents
Introducing real-time, speaker-aware Voice Agents with LiveKit + Speechmatics
Speechmatics brings speaker diarization to LiveKit agents - enabling them to understand not just what was said, but who said it.
Anthony PereraProduct Marketing Manager
![[alt: Vapi integration launch blog social asset]](/_next/image?url=https%3A%2F%2Fimages.ctfassets.net%2Fyze1aysi0225%2F5rvEvjLDjyosWx3mVI7L76%2Fbacc01b541e87a90558373ca7b16d539%2FVapi-blog-assets-V1-Social-sharing.png&w=3840&q=75)
Voice Agents
Vapi and Speechmatics: Build agents that understand every voice
Ship Voice AI agents that stay readable in real time, even in noisy, multi-speaker calls.
SpeechmaticsEditorial Team
Stream audio and receive real-time transcripts using the real-time API. Start by generating your API key.
1# Install the speechmatics package using the command "pip install speechmatics-rt"
2
3#!/usr/bin/env python3
4"""Real-time transcription with microphone."""
5
6import asyncio
7import os
8from dotenv import load_dotenv
9from speechmatics.rt import (
10 AsyncClient,
11 ServerMessageType,
12 TranscriptionConfig,
13 TranscriptResult,
14 OperatingPoint,
15 AudioFormat,
16 AudioEncoding,
17 Microphone,
18 AuthenticationError,
19)
20
21load_dotenv()
22
23
24async def main():
25 api_key = os.getenv("SPEECHMATICS_API_KEY")
26
27 transcript_parts = []
28
29 audio_format = AudioFormat(
30 encoding=AudioEncoding.PCM_S16LE,
31 chunk_size=4096,
32 sample_rate=16000,
33 )
34
35 transcription_config = TranscriptionConfig(
36 language="en",
37 enable_partials=True,
38 operating_point=OperatingPoint.ENHANCED,
39 )
40
41 mic = Microphone(
42 sample_rate=audio_format.sample_rate,
43 chunk_size=audio_format.chunk_size,
44 )
45
46 if not mic.start():
47 print("PyAudio not installed. Install: pip install pyaudio")
48 return
49
50 try:
51 async with AsyncClient(api_key=api_key) as client:
52 @client.on(ServerMessageType.ADD_TRANSCRIPT)
53 def handle_final_transcript(message):
54 result = TranscriptResult.from_message(message)
55 transcript = result.metadata.transcript
56 if transcript:
57 print(f"[final]: {transcript}")
58 transcript_parts.append(transcript)
59
60 @client.on(ServerMessageType.ADD_PARTIAL_TRANSCRIPT)
61 def handle_partial_transcript(message):
62 result = TranscriptResult.from_message(message)
63 transcript = result.metadata.transcript
64 if transcript:
65 print(f"[partial]: {transcript}")
66
67 try:
68 print("Connected! Start speaking (Ctrl+C to stop)...\n")
69
70 await client.start_session(
71 transcription_config=transcription_config,
72 audio_format=audio_format,
73 )
74
75 while True:
76 frame = await mic.read(audio_format.chunk_size)
77 await client.send_audio(frame)
78
79 except KeyboardInterrupt:
80 pass
81 finally:
82 mic.stop()
83 print(f"\n\nFull transcript: {' '.join(transcript_parts)}")
84
85 except (AuthenticationError, ValueError) as e:
86 print(f"\nAuthentication Error: {e}")
87
88
89if __name__ == "__main__":
90 asyncio.run(main())
91 Connect with us
Join the conversation where developers already hang outConnect with us
Ask questions, share ideas, and discuss best practices with the community.
