Skip to Content
ReferenceAgentsgetVoice()

getVoice()

The .getVoice() method retrieves the voice provider configured for an agent, resolving it if it’s a function. This method is used to access the agent’s speech capabilities for text-to-speech and speech-to-text functionality.

Usage example

const voice = await agent.getVoice();

Parameters

options?:

{ runtimeContext?: RuntimeContext }
= {}
Optional configuration object containing runtime context.

Extended usage example

const voice = await agent.getVoice({ runtimeContext: new RuntimeContext() });

Options parameters

runtimeContext?:

RuntimeContext
= new RuntimeContext()
Runtime context for dependency injection and contextual information.

Returns

voice:

Promise<MastraVoice>
A promise that resolves to the voice provider configured for the agent, or a default voice provider if none was configured.