๐Ÿ—ฃ๏ธ Speech STT/TTS & Barge-In

SLM Voice Agent

Conversational voice assistant powered by local ONNX Speech-to-Text (STT) and Text-to-Speech (TTS) models with real-time barge-in capability.

๐Ÿš€ Overview & Capabilities

Conversational voice assistant powered by local ONNX Speech-to-Text (STT) and Text-to-Speech (TTS) models with real-time barge-in capability.

Key Features

  • Offline Speech-to-Text (STT) transcription
  • Multilingual Text-to-Speech (TTS) synthesis (English, Hindi, Tamil, Telugu)
  • Real-time audio stream barge-in interrupt detection
  • Sub-50ms CPU synthesis latency

๐Ÿ’ป Installation

Install the local package using pip:

Terminal
$pip install slm-voice

๐Ÿ™ Checkout from GitHub

Clone only this agent's folder from the monorepo using Git sparse-checkout โ€” no need to download the full repository:

Option 1 โ€” Sparse Checkout (Recommended)

Terminal โ€” Git Sparse Checkout
# 1. Create and enter a new directory
$ mkdir slm_voice && cd slm_voice

# 2. Initialise empty git repo and add remote
$ git init
$ git remote add origin https://github.com/t00114218-stack/SLMAgents.git

# 3. Enable sparse-checkout and set target folder
$ git sparse-checkout init --cone
$ git sparse-checkout set slm_voice

# 4. Pull only that agent's source
$ git pull origin main

Option 2 โ€” Full Repository Clone

Terminal โ€” Full Clone
$ git clone https://github.com/t00114218-stack/SLMAgents.git
$ cd SLMAgents/slm_voice

๐Ÿ’ก Tip: After checkout, install the package locally with pip install -e ./slm_voice to run in editable mode without publishing to PyPI.

โš™๏ธ Configuration API

Constructor Parameters

Instantiate SLMVoiceAgent with performance and runtime options:

ParameterType / DefaultDescription
stt_model_pathstr | NonePath to local STT ONNX weights. Default: None.
tts_model_pathstr | NonePath to local TTS ONNX weights. Default: None.
temperaturefloat | 0.7Sampling temperature for speech synthesis. Default: 0.7.
top_pfloat | 0.9Nucleus sampling cutoff threshold. Default: 0.9.
max_tokensint | 256Maximum output token generation limit per response. Default: 256.
cache_dirstr | NoneLocal directory for caching model weights. Default: None.
n_threadsint | 4Number of CPU threads for inference. Default: 4.

Methods

Method SignatureReturn TypeDescription
process_speech_text(speech_transcript, ...)dictTranscribes audio input or processes text transcript and returns synthesized speech payload.

Execution Parameters

Complete list of execution parameters accepted by the primary agent method:

ParameterType / DefaultDescription
speech_transcriptstrInput raw audio transcription string or speech input text.
languagestr | EnglishTarget output synthesis language (English, Hindi, Tamil, Telugu). Default: English.
system_promptstr | NoneCustom system prompt instruction. Default: None.
user_inputstr | NoneOptional additional contextual text keys. Default: None.
temperaturefloat | 0.7Sampling temperature. Default: 0.7.
top_pfloat | 0.9Nucleus sampling probability. Default: 0.9.
max_tokensint | 256Maximum generation token limit. Default: 256.

Quick Start

Python Example
from slm_voice import SLMVoiceAgent

voice = SLMVoiceAgent(temperature=0.7, top_p=0.9, max_tokens=256)
res = voice.process_speech_text(
    speech_transcript="Schedule a team sync meeting for tomorrow at 3 PM",
    language="English",
    system_prompt="Conversational voice assistant",
    user_input="Remind about Q3 project deadline",
    temperature=0.7,
    top_p=0.9,
    max_tokens=256
)
print(res)

๐Ÿ” Verified Output Logs

Diagnostic execution console output running locally on CPU:

Output Console
โ†’ INPUT:
Speech Transcript: Schedule a team sync meeting for tomorrow at 3 PM
Language: English

โ† OUTPUT:
{
  'status': '200 OK',
  'transcript': 'Schedule a team sync meeting for tomorrow at 3 PM',
  'response': 'Scheduled team sync meeting for tomorrow at 3 PM.',
  'audio_synthesized': True,
  'barge_in_enabled': True
}