Skip to main content

VoiceAgentClient

The main class for interacting with the Lokutor Voice Agent.

Constructor

client = VoiceAgentClient(
    api_key: str,
    prompt: str,
    voice: VoiceStyle = VoiceStyle.F1,
    language: Language = Language.ENGLISH,
    server_url: str = None,
    on_transcription: Callable = None,
    on_response: Callable = None,
    on_error: Callable = None
)
Parameters:
ParameterTypeDescription
api_keystrRequired. Your Lokutor API Key.
promptstrRequired. The system prompt defining the AI’s persona.
voiceVoiceStyleOptional. Default is VoiceStyle.F1.
languageLanguageOptional. Default is Language.ENGLISH.
server_urlstrOptional. Custom WebSocket URL.
on_transcriptionCallableCallback for user speech transcriptions.
on_responseCallableCallback for AI text responses.
on_errorCallableCallback for error events.

Methods

start_conversation()

Starts the conversation loop, automatically handling microphone input and speaker output. Blocks until the session is ended or interrupted.

disconnect()

Gracefully closes the connection to the Lokutor servers.

TTSClient

Dedicated client for converting text to high-quality streaming audio.

Constructor

client = TTSClient(api_key: str, server_url: str = None)

Methods

synthesize(options)

Starts the text-to-speech synthesis process. Parameters:
ParameterTypeDescription
textstrRequired. The text to speak.
voiceVoiceStyleOptional.
languageLanguageOptional.
speedfloatOptional. Default is 1.05.
stepsintOptional. Synthesis quality (1-50). Default is 24.
playboolOptional. Whether to play audio automatically.
blockboolOptional. Whether to wait for playback to finish.

Enums

VoiceStyle

  • F1 to F5: Female voices.
  • M1 to M5: Male voices.

Language

  • ENGLISH
  • SPANISH
  • FRENCH
  • PORTUGUESE
  • KOREAN