Skip to content

API Reference parrot.bots.voice

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.bots.voice

View source

VoiceBot - Bot implementation with voice interaction capabilities.

Extends BaseBot to support voice input/output using native speech-to-speech models like Gemini Live API.

Alias A2AEnabledMixin

Re-exported from parrot.a2a.server.A2AEnabledMixin.

Alias AbstractClient

Re-exported from parrot.clients.base.AbstractClient.

Alias AbstractTool

Re-exported from parrot.tools.AbstractTool.

Attribute BASIC_VOICE_PROMPT_TEMPLATE

Alias BaseBot

Re-exported from parrot.bots.base.BaseBot.

Alias ConversationTurn

Re-exported from parrot.memory.ConversationTurn.

Alias LayerPriority

Re-exported from parrot.bots.prompts.layers.LayerPriority.

Alias LiveCompletionUsage

Re-exported from parrot.models.voice.LiveCompletionUsage.

Alias LiveVoiceResponse

Re-exported from parrot.models.voice.LiveVoiceResponse.

Alias MCPServerConfig

Re-exported from parrot.mcp.MCPServerConfig.

Alias PromptBuilder

Re-exported from parrot.bots.prompts.builder.PromptBuilder.

Alias PromptLayer

Re-exported from parrot.bots.prompts.layers.PromptLayer.

Alias RenderPhase

Re-exported from parrot.bots.prompts.layers.RenderPhase.

Alias ToolDefinition

Re-exported from parrot.tools.manager.ToolDefinition.

Class VoiceBot

Bot with native voice interaction capabilities.

Uses GeminiLiveClient internally for:

  • Bidirectional audio processing
  • Tool execution during conversation
  • Usage tracking (tokens, timing, etc.)
Parameter Type Default Description
name str 'Voice Assistant' Bot name
system_prompt str None System instructions
llm Union[str, Type[AbstractClient], AbstractClient, Callable, str] None LLM identifier (for text fallback)
tools List[Union[str, AbstractTool, ToolDefinition]] None List of AbstractTool to use
voice_config Optional[VoiceConfig] None Voice configuration
**kwargs {} Additional arguments for BaseBot

Method VoiceBot.create_system_prompt

Render voice instructions even when async configure() was skipped.

create_system_prompt(user_context: str = '', vector_context: str = '', kb_context: str = '', pageindex_context: str = '', metadata: Optional[Dict[str, Any]] = None, memory_context: Optional[str] = None, **kwargs: Any) -> Union[str, List]

Parameter Type Default Description
user_context str ''
vector_context str ''
kb_context str ''
pageindex_context str ''
metadata Optional[Dict[str, Any]] None
memory_context Optional[str] None
**kwargs Any {}

Returns: Union[str, List]

Method VoiceBot.configure

Configure the bot.

configure(app=None) -> None

Parameter Type Default Description
app None

Method VoiceBot.ask_text

Text-based ask using GoogleGenAIClient (for non-voice operations).

This is used by components like QuestionGenerator that need a standard text-based LLM with the ask(prompt=...) signature.

ask_text(prompt: str, **kwargs) -> str

Parameter Type Default Description
prompt str Text prompt to send
**kwargs {} Additional parameters for the LLM

Returns: str — Text response from the LLM

Method VoiceBot.get_tool_definitions

Get tool definitions in API format.

get_tool_definitions() -> List[Dict[str, Any]]

Returns: List[Dict[str, Any]] — List of function definitions

Method VoiceBot.execute_tool

Execute a tool by name.

execute_tool(tool_name: str, arguments: Dict[str, Any]) -> Any

Parameter Type Default Description
tool_name str Name of the tool
arguments Dict[str, Any] Tool arguments

Returns: Any — Execution result

Method VoiceBot.setup_mcp_servers

Setup multiple MCP servers during initialization.

This is useful for configuring a VoiceBot with multiple MCP servers at once, typically during bot creation or from configuration files.

setup_mcp_servers(configurations: Optional[List[MCPServerConfig]] = None) -> None

Parameter Type Default Description
configurations Optional[List[MCPServerConfig]] None List of MCPServerConfig objects

Method VoiceBot.ask_stream

Voice interaction stream.

This is the main entry point for voice interactions. Accepts audio (complete buffer or streaming chunks) and returns multimodal responses with text and audio.

ask_stream(audio_input: Union[bytes, AsyncIterator[bytes]], session_id: Optional[str] = None, user_id: Optional[str] = None, stt_only: bool = False, **kwargs) -> AsyncIterator[LiveVoiceResponse]

Parameter Type Default Description
audio_input Union[bytes, AsyncIterator[bytes]] Audio data - complete bytes or async iterator
session_id Optional[str] None Session identifier
user_id Optional[str] None User identifier
stt_only bool False When True, run in STT-only mode (transcription only, no model response/audio output). Passed through to the underlying client's stream_voice(); currently supported by GeminiLiveClient only — Nova Sonic has no documented STT-only mode (FEAT-416 spec §7 Known Risks; that guard is the client's own responsibility, not VoiceBot's).
**kwargs {} Additional options. Explicit values here override the VoiceConfig-derived temperature/max_tokens/ top_p/parallel_tool_execution defaults threaded to stream_voice() (FEAT-416 spec §3 Module 7).

Returns: AsyncIterator[LiveVoiceResponse]

Method VoiceBot.ask_voice

Process voice input and return complete response.

Non-streaming version that waits for the complete response.

ask_voice(audio_input: bytes, session_id: Optional[str] = None, user_id: Optional[str] = None, **kwargs) -> LiveVoiceResponse

Parameter Type Default Description
audio_input bytes Complete audio buffer (PCM 16-bit, 16kHz, mono)
session_id Optional[str] None Session identifier
user_id Optional[str] None User identifier
**kwargs {} Additional options

Returns: LiveVoiceResponse — Complete LiveVoiceResponse with text and audio

Method VoiceBot.ask

Send text and receive voice response.

Useful for testing or text-to-speech scenarios.

ask(question: str, session_id: Optional[str] = None, user_id: Optional[str] = None, **kwargs) -> AsyncIterator[LiveVoiceResponse]

Parameter Type Default Description
question str Input text
session_id Optional[str] None Session identifier
user_id Optional[str] None User identifier
**kwargs {} Additional configuration

Returns: AsyncIterator[LiveVoiceResponse]

Method VoiceBot.close

Close any resources if needed.

close()

Alias VoiceCapable

Re-exported from parrot.clients.protocols.VoiceCapable.

Alias VoiceConfig

Re-exported from parrot.models.voice.VoiceConfig.

Alias VoiceStreamOptions

Re-exported from parrot.models.voice.VoiceStreamOptions.

Function create_voice_bot

Factory to create a configured VoiceBot.

create_voice_bot(name: str = 'Voice Assistant', system_prompt: Optional[str] = None, voice_name: str = 'Puck', language: str = 'en-US', tools: Optional[List[Any]] = None, **kwargs) -> VoiceBot

Parameter Type Default Description
name str 'Voice Assistant' Bot name
system_prompt Optional[str] None System instructions
voice_name str 'Puck' Voice to use (Puck, Charon, Kore, etc.)
language str 'en-US' Language code
tools Optional[List[Any]] None List of tools
**kwargs {} Additional configuration

Returns: VoiceBot — Configured VoiceBot

Alias current_memory_key_id

Re-exported from parrot.observability.context.current_memory_key_id.

Alias current_session_id

Re-exported from parrot.observability.context.current_session_id.

Alias current_user_id

Re-exported from parrot.observability.context.current_user_id.

Function example

Example usage of the refactored VoiceBot.

example()

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally