Skip to main content
Mastra v1 is coming in January 2026. Get ahead by starting new projects with the beta or upgrade your existing project today.

Agent.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 exampleDirect link to Usage example

await agent.getVoice();

ParametersDirect link to Parameters

options?:

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

ReturnsDirect link to 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.

Extended usage exampleDirect link to Extended usage example

await agent.getVoice({
runtimeContext: new RuntimeContext(),
});

Options parametersDirect link to Options parameters

runtimeContext?:

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

On this page