@mastra/mcp-docs-server 0.0.0-commonjs-20250414101718
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/organized/changelogs/%40mastra%2Fastra.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fchroma.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +161 -0
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +110 -0
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Ffirecrawl.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fgithub.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Floggers.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +26 -0
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fmem0.md +196 -0
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Frag.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fragie.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-azure.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-deepgram.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-elevenlabs.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-google.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-ibm.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-murf.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-openai.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-playai.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-replicate.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-speechify.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +250 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +250 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +302 -0
- package/.docs/organized/changelogs/create-mastra.md +302 -0
- package/.docs/organized/changelogs/mastra.md +302 -0
- package/.docs/organized/code-examples/agent-network.md +282 -0
- package/.docs/organized/code-examples/agent.md +388 -0
- package/.docs/organized/code-examples/ai-sdk-useChat.md +378 -0
- package/.docs/organized/code-examples/assistant-ui.md +37 -0
- package/.docs/organized/code-examples/bird-checker-with-express.md +235 -0
- package/.docs/organized/code-examples/bird-checker-with-nextjs-and-eval.md +360 -0
- package/.docs/organized/code-examples/bird-checker-with-nextjs.md +250 -0
- package/.docs/organized/code-examples/client-side-tools.md +69 -0
- package/.docs/organized/code-examples/crypto-chatbot.md +96 -0
- package/.docs/organized/code-examples/fireworks-r1.md +159 -0
- package/.docs/organized/code-examples/mcp-registry-registry.md +63 -0
- package/.docs/organized/code-examples/memory-todo-agent.md +164 -0
- package/.docs/organized/code-examples/memory-with-context.md +167 -0
- package/.docs/organized/code-examples/memory-with-libsql.md +204 -0
- package/.docs/organized/code-examples/memory-with-mem0.md +121 -0
- package/.docs/organized/code-examples/memory-with-pg.md +224 -0
- package/.docs/organized/code-examples/memory-with-upstash.md +268 -0
- package/.docs/organized/code-examples/quick-start.md +129 -0
- package/.docs/organized/code-examples/stock-price-tool.md +124 -0
- package/.docs/organized/code-examples/weather-agent.md +353 -0
- package/.docs/organized/code-examples/workflow-ai-recruiter.md +159 -0
- package/.docs/organized/code-examples/workflow-with-inline-steps.md +111 -0
- package/.docs/organized/code-examples/workflow-with-memory.md +393 -0
- package/.docs/organized/code-examples/workflow-with-separate-steps.md +131 -0
- package/.docs/raw/agents/adding-tools.mdx +317 -0
- package/.docs/raw/agents/adding-voice.mdx +175 -0
- package/.docs/raw/agents/agent-memory.mdx +62 -0
- package/.docs/raw/agents/mcp-guide.mdx +215 -0
- package/.docs/raw/agents/overview.mdx +303 -0
- package/.docs/raw/community/discord.mdx +12 -0
- package/.docs/raw/community/licensing.mdx +63 -0
- package/.docs/raw/deployment/client.mdx +120 -0
- package/.docs/raw/deployment/deployment.mdx +127 -0
- package/.docs/raw/deployment/server.mdx +282 -0
- package/.docs/raw/evals/custom-eval.mdx +22 -0
- package/.docs/raw/evals/overview.mdx +95 -0
- package/.docs/raw/evals/running-in-ci.mdx +81 -0
- package/.docs/raw/evals/textual-evals.mdx +54 -0
- package/.docs/raw/faq/index.mdx +63 -0
- package/.docs/raw/frameworks/ai-sdk.mdx +296 -0
- package/.docs/raw/frameworks/next-js.mdx +238 -0
- package/.docs/raw/getting-started/installation.mdx +442 -0
- package/.docs/raw/getting-started/mcp-docs-server.mdx +141 -0
- package/.docs/raw/getting-started/project-structure.mdx +80 -0
- package/.docs/raw/index.mdx +22 -0
- package/.docs/raw/integrations/index.mdx +213 -0
- package/.docs/raw/local-dev/add-to-existing-project.mdx +48 -0
- package/.docs/raw/local-dev/creating-a-new-project.mdx +54 -0
- package/.docs/raw/local-dev/mastra-dev.mdx +108 -0
- package/.docs/raw/memory/memory-processors.mdx +131 -0
- package/.docs/raw/memory/overview.mdx +119 -0
- package/.docs/raw/memory/semantic-recall.mdx +122 -0
- package/.docs/raw/memory/working-memory.mdx +87 -0
- package/.docs/raw/observability/logging.mdx +38 -0
- package/.docs/raw/observability/nextjs-tracing.mdx +108 -0
- package/.docs/raw/observability/tracing.mdx +115 -0
- package/.docs/raw/rag/chunking-and-embedding.mdx +156 -0
- package/.docs/raw/rag/overview.mdx +85 -0
- package/.docs/raw/rag/retrieval.mdx +365 -0
- package/.docs/raw/rag/vector-databases.mdx +340 -0
- package/.docs/raw/reference/agents/createTool.mdx +229 -0
- package/.docs/raw/reference/agents/generate.mdx +334 -0
- package/.docs/raw/reference/agents/getAgent.mdx +54 -0
- package/.docs/raw/reference/agents/stream.mdx +369 -0
- package/.docs/raw/reference/cli/build.mdx +55 -0
- package/.docs/raw/reference/cli/dev.mdx +134 -0
- package/.docs/raw/reference/cli/init.mdx +43 -0
- package/.docs/raw/reference/client-js/agents.mdx +107 -0
- package/.docs/raw/reference/client-js/error-handling.mdx +38 -0
- package/.docs/raw/reference/client-js/logs.mdx +24 -0
- package/.docs/raw/reference/client-js/memory.mdx +97 -0
- package/.docs/raw/reference/client-js/telemetry.mdx +20 -0
- package/.docs/raw/reference/client-js/tools.mdx +44 -0
- package/.docs/raw/reference/client-js/vectors.mdx +79 -0
- package/.docs/raw/reference/client-js/workflows.mdx +136 -0
- package/.docs/raw/reference/core/mastra-class.mdx +232 -0
- package/.docs/raw/reference/deployer/cloudflare.mdx +207 -0
- package/.docs/raw/reference/deployer/deployer.mdx +159 -0
- package/.docs/raw/reference/deployer/netlify.mdx +109 -0
- package/.docs/raw/reference/deployer/vercel.mdx +117 -0
- package/.docs/raw/reference/evals/answer-relevancy.mdx +186 -0
- package/.docs/raw/reference/evals/bias.mdx +186 -0
- package/.docs/raw/reference/evals/completeness.mdx +174 -0
- package/.docs/raw/reference/evals/content-similarity.mdx +183 -0
- package/.docs/raw/reference/evals/context-position.mdx +190 -0
- package/.docs/raw/reference/evals/context-precision.mdx +189 -0
- package/.docs/raw/reference/evals/context-relevancy.mdx +188 -0
- package/.docs/raw/reference/evals/contextual-recall.mdx +191 -0
- package/.docs/raw/reference/evals/faithfulness.mdx +193 -0
- package/.docs/raw/reference/evals/hallucination.mdx +219 -0
- package/.docs/raw/reference/evals/keyword-coverage.mdx +176 -0
- package/.docs/raw/reference/evals/prompt-alignment.mdx +238 -0
- package/.docs/raw/reference/evals/summarization.mdx +205 -0
- package/.docs/raw/reference/evals/textual-difference.mdx +161 -0
- package/.docs/raw/reference/evals/tone-consistency.mdx +181 -0
- package/.docs/raw/reference/evals/toxicity.mdx +165 -0
- package/.docs/raw/reference/index.mdx +12 -0
- package/.docs/raw/reference/memory/Memory.mdx +212 -0
- package/.docs/raw/reference/memory/createThread.mdx +95 -0
- package/.docs/raw/reference/memory/getThreadById.mdx +46 -0
- package/.docs/raw/reference/memory/getThreadsByResourceId.mdx +48 -0
- package/.docs/raw/reference/memory/query.mdx +167 -0
- package/.docs/raw/reference/networks/agent-network.mdx +159 -0
- package/.docs/raw/reference/observability/create-logger.mdx +106 -0
- package/.docs/raw/reference/observability/logger.mdx +55 -0
- package/.docs/raw/reference/observability/otel-config.mdx +120 -0
- package/.docs/raw/reference/observability/providers/braintrust.mdx +40 -0
- package/.docs/raw/reference/observability/providers/dash0.mdx +40 -0
- package/.docs/raw/reference/observability/providers/index.mdx +16 -0
- package/.docs/raw/reference/observability/providers/laminar.mdx +41 -0
- package/.docs/raw/reference/observability/providers/langfuse.mdx +51 -0
- package/.docs/raw/reference/observability/providers/langsmith.mdx +48 -0
- package/.docs/raw/reference/observability/providers/langwatch.mdx +45 -0
- package/.docs/raw/reference/observability/providers/new-relic.mdx +40 -0
- package/.docs/raw/reference/observability/providers/signoz.mdx +40 -0
- package/.docs/raw/reference/observability/providers/traceloop.mdx +40 -0
- package/.docs/raw/reference/rag/astra.mdx +258 -0
- package/.docs/raw/reference/rag/chroma.mdx +281 -0
- package/.docs/raw/reference/rag/chunk.mdx +235 -0
- package/.docs/raw/reference/rag/document.mdx +127 -0
- package/.docs/raw/reference/rag/embeddings.mdx +160 -0
- package/.docs/raw/reference/rag/extract-params.mdx +226 -0
- package/.docs/raw/reference/rag/graph-rag.mdx +182 -0
- package/.docs/raw/reference/rag/libsql.mdx +357 -0
- package/.docs/raw/reference/rag/metadata-filters.mdx +298 -0
- package/.docs/raw/reference/rag/pg.mdx +477 -0
- package/.docs/raw/reference/rag/pinecone.mdx +281 -0
- package/.docs/raw/reference/rag/qdrant.mdx +236 -0
- package/.docs/raw/reference/rag/rerank.mdx +212 -0
- package/.docs/raw/reference/rag/turbopuffer.mdx +249 -0
- package/.docs/raw/reference/rag/upstash.mdx +247 -0
- package/.docs/raw/reference/rag/vectorize.mdx +298 -0
- package/.docs/raw/reference/storage/libsql.mdx +74 -0
- package/.docs/raw/reference/storage/postgresql.mdx +48 -0
- package/.docs/raw/reference/storage/upstash.mdx +86 -0
- package/.docs/raw/reference/tools/client.mdx +207 -0
- package/.docs/raw/reference/tools/document-chunker-tool.mdx +141 -0
- package/.docs/raw/reference/tools/graph-rag-tool.mdx +154 -0
- package/.docs/raw/reference/tools/mcp-configuration.mdx +206 -0
- package/.docs/raw/reference/tools/vector-query-tool.mdx +212 -0
- package/.docs/raw/reference/voice/composite-voice.mdx +140 -0
- package/.docs/raw/reference/voice/deepgram.mdx +164 -0
- package/.docs/raw/reference/voice/elevenlabs.mdx +216 -0
- package/.docs/raw/reference/voice/google.mdx +198 -0
- package/.docs/raw/reference/voice/mastra-voice.mdx +394 -0
- package/.docs/raw/reference/voice/murf.mdx +251 -0
- package/.docs/raw/reference/voice/openai-realtime.mdx +431 -0
- package/.docs/raw/reference/voice/openai.mdx +168 -0
- package/.docs/raw/reference/voice/playai.mdx +159 -0
- package/.docs/raw/reference/voice/sarvam.mdx +260 -0
- package/.docs/raw/reference/voice/speechify.mdx +145 -0
- package/.docs/raw/reference/voice/voice.answer.mdx +122 -0
- package/.docs/raw/reference/voice/voice.connect.mdx +124 -0
- package/.docs/raw/reference/voice/voice.listen.mdx +195 -0
- package/.docs/raw/reference/voice/voice.on.mdx +189 -0
- package/.docs/raw/reference/voice/voice.send.mdx +118 -0
- package/.docs/raw/reference/voice/voice.speak.mdx +203 -0
- package/.docs/raw/reference/workflows/after.mdx +88 -0
- package/.docs/raw/reference/workflows/afterEvent.mdx +76 -0
- package/.docs/raw/reference/workflows/commit.mdx +37 -0
- package/.docs/raw/reference/workflows/createRun.mdx +77 -0
- package/.docs/raw/reference/workflows/else.mdx +72 -0
- package/.docs/raw/reference/workflows/events.mdx +305 -0
- package/.docs/raw/reference/workflows/execute.mdx +110 -0
- package/.docs/raw/reference/workflows/if.mdx +107 -0
- package/.docs/raw/reference/workflows/resume.mdx +155 -0
- package/.docs/raw/reference/workflows/resumeWithEvent.mdx +133 -0
- package/.docs/raw/reference/workflows/snapshots.mdx +207 -0
- package/.docs/raw/reference/workflows/start.mdx +84 -0
- package/.docs/raw/reference/workflows/step-class.mdx +100 -0
- package/.docs/raw/reference/workflows/step-condition.mdx +134 -0
- package/.docs/raw/reference/workflows/step-function.mdx +92 -0
- package/.docs/raw/reference/workflows/step-options.mdx +69 -0
- package/.docs/raw/reference/workflows/step-retries.mdx +203 -0
- package/.docs/raw/reference/workflows/suspend.mdx +70 -0
- package/.docs/raw/reference/workflows/then.mdx +74 -0
- package/.docs/raw/reference/workflows/until.mdx +165 -0
- package/.docs/raw/reference/workflows/watch.mdx +118 -0
- package/.docs/raw/reference/workflows/while.mdx +168 -0
- package/.docs/raw/reference/workflows/workflow.mdx +233 -0
- package/.docs/raw/storage/overview.mdx +378 -0
- package/.docs/raw/voice/overview.mdx +135 -0
- package/.docs/raw/voice/speech-to-text.mdx +45 -0
- package/.docs/raw/voice/text-to-speech.mdx +52 -0
- package/.docs/raw/voice/voice-to-voice.mdx +310 -0
- package/.docs/raw/workflows/control-flow.mdx +778 -0
- package/.docs/raw/workflows/dynamic-workflows.mdx +236 -0
- package/.docs/raw/workflows/error-handling.mdx +183 -0
- package/.docs/raw/workflows/nested-workflows.mdx +352 -0
- package/.docs/raw/workflows/overview.mdx +203 -0
- package/.docs/raw/workflows/steps.mdx +108 -0
- package/.docs/raw/workflows/suspend-and-resume.mdx +404 -0
- package/.docs/raw/workflows/variables.mdx +313 -0
- package/LICENSE.md +46 -0
- package/README.md +129 -0
- package/dist/_tsup-dts-rollup.d.ts +149 -0
- package/dist/chunk-QWYMT5LP.js +194 -0
- package/dist/prepare-docs/prepare.d.ts +1 -0
- package/dist/prepare-docs/prepare.js +1 -0
- package/dist/stdio.d.ts +1 -0
- package/dist/stdio.js +518 -0
- package/package.json +60 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: PlayAI Voice | Voice Providers | Mastra Docs"
|
|
3
|
+
description: "Documentation for the PlayAI voice implementation, providing text-to-speech capabilities."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# PlayAI
|
|
7
|
+
|
|
8
|
+
The PlayAI voice implementation in Mastra provides text-to-speech capabilities using PlayAI's API.
|
|
9
|
+
|
|
10
|
+
## Usage Example
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
import { PlayAIVoice } from "@mastra/voice-playai";
|
|
14
|
+
|
|
15
|
+
// Initialize with default configuration (uses PLAYAI_API_KEY environment variable and PLAYAI_USER_ID environment variable)
|
|
16
|
+
const voice = new PlayAIVoice();
|
|
17
|
+
|
|
18
|
+
// Initialize with default configuration
|
|
19
|
+
const voice = new PlayAIVoice({
|
|
20
|
+
speechModel: {
|
|
21
|
+
name: 'PlayDialog',
|
|
22
|
+
apiKey: process.env.PLAYAI_API_KEY,
|
|
23
|
+
userId: process.env.PLAYAI_USER_ID
|
|
24
|
+
},
|
|
25
|
+
speaker: 'Angelo' // Default voice
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Convert text to speech with a specific voice
|
|
29
|
+
const audioStream = await voice.speak("Hello, world!", {
|
|
30
|
+
speaker: 's3://voice-cloning-zero-shot/b27bc13e-996f-4841-b584-4d35801aea98/original/manifest.json' // Dexter voice
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Constructor Parameters
|
|
35
|
+
|
|
36
|
+
<PropertiesTable
|
|
37
|
+
content={[
|
|
38
|
+
{
|
|
39
|
+
name: "speechModel",
|
|
40
|
+
type: "PlayAIConfig",
|
|
41
|
+
description: "Configuration for text-to-speech functionality",
|
|
42
|
+
isOptional: true,
|
|
43
|
+
defaultValue: "{ name: 'PlayDialog' }",
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: "speaker",
|
|
47
|
+
type: "string",
|
|
48
|
+
description: "Default voice ID to use for speech synthesis",
|
|
49
|
+
isOptional: true,
|
|
50
|
+
defaultValue: "First available voice ID",
|
|
51
|
+
},
|
|
52
|
+
]}
|
|
53
|
+
/>
|
|
54
|
+
|
|
55
|
+
### PlayAIConfig
|
|
56
|
+
|
|
57
|
+
<PropertiesTable
|
|
58
|
+
content={[
|
|
59
|
+
{
|
|
60
|
+
name: "name",
|
|
61
|
+
type: "'PlayDialog' | 'Play3.0-mini'",
|
|
62
|
+
description: "The PlayAI model to use",
|
|
63
|
+
isOptional: true,
|
|
64
|
+
defaultValue: "'PlayDialog'",
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: "apiKey",
|
|
68
|
+
type: "string",
|
|
69
|
+
description: "PlayAI API key. Falls back to PLAYAI_API_KEY environment variable",
|
|
70
|
+
isOptional: true,
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: "userId",
|
|
74
|
+
type: "string",
|
|
75
|
+
description: "PlayAI user ID. Falls back to PLAYAI_USER_ID environment variable",
|
|
76
|
+
isOptional: true,
|
|
77
|
+
},
|
|
78
|
+
]}
|
|
79
|
+
/>
|
|
80
|
+
|
|
81
|
+
## Methods
|
|
82
|
+
|
|
83
|
+
### speak()
|
|
84
|
+
|
|
85
|
+
Converts text to speech using the configured speech model and voice.
|
|
86
|
+
|
|
87
|
+
<PropertiesTable
|
|
88
|
+
content={[
|
|
89
|
+
{
|
|
90
|
+
name: "input",
|
|
91
|
+
type: "string | NodeJS.ReadableStream",
|
|
92
|
+
description: "Text to convert to speech. If a stream is provided, it will be converted to text first.",
|
|
93
|
+
isOptional: false,
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: "options.speaker",
|
|
97
|
+
type: "string",
|
|
98
|
+
description: "Override the default speaker for this request",
|
|
99
|
+
isOptional: true,
|
|
100
|
+
defaultValue: "Constructor's speaker value",
|
|
101
|
+
},
|
|
102
|
+
]}
|
|
103
|
+
/>
|
|
104
|
+
|
|
105
|
+
Returns: `Promise<NodeJS.ReadableStream>`.
|
|
106
|
+
|
|
107
|
+
### getSpeakers()
|
|
108
|
+
|
|
109
|
+
Returns an array of available voice options, where each node contains:
|
|
110
|
+
|
|
111
|
+
<PropertiesTable
|
|
112
|
+
content={[
|
|
113
|
+
{
|
|
114
|
+
name: "name",
|
|
115
|
+
type: "string",
|
|
116
|
+
description: "Name of the voice",
|
|
117
|
+
isOptional: false,
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: "accent",
|
|
121
|
+
type: "string",
|
|
122
|
+
description: "Accent of the voice (e.g., 'US', 'British', 'Australian')",
|
|
123
|
+
isOptional: false,
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
name: "gender",
|
|
127
|
+
type: "'M' | 'F'",
|
|
128
|
+
description: "Gender of the voice",
|
|
129
|
+
isOptional: false,
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
name: "age",
|
|
133
|
+
type: "'Young' | 'Middle' | 'Old'",
|
|
134
|
+
description: "Age category of the voice",
|
|
135
|
+
isOptional: false,
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
name: "style",
|
|
139
|
+
type: "'Conversational' | 'Narrative'",
|
|
140
|
+
description: "Speaking style of the voice",
|
|
141
|
+
isOptional: false,
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
name: "voiceId",
|
|
145
|
+
type: "string",
|
|
146
|
+
description: "Unique identifier for the voice",
|
|
147
|
+
isOptional: false,
|
|
148
|
+
},
|
|
149
|
+
]}
|
|
150
|
+
/>
|
|
151
|
+
### listen()
|
|
152
|
+
|
|
153
|
+
This method is not supported by PlayAI and will throw an error. PlayAI does not provide speech-to-text functionality.
|
|
154
|
+
|
|
155
|
+
## Notes
|
|
156
|
+
|
|
157
|
+
- PlayAI requires both an API key and a user ID for authentication
|
|
158
|
+
- The service offers two models: 'PlayDialog' and 'Play3.0-mini'
|
|
159
|
+
- Each voice has a unique S3 manifest ID that must be used when making API calls
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: Sarvam Voice | Voice Providers | Mastra Docs"
|
|
3
|
+
description: "Documentation for the Sarvam class, providing text-to-speech and speech-to-text capabilities."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Sarvam
|
|
7
|
+
|
|
8
|
+
The SarvamVoice class in Mastra provides text-to-speech and speech-to-text capabilities using Sarvam AI models.
|
|
9
|
+
|
|
10
|
+
## Usage Example
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
import { SarvamVoice } from "@mastra/voice-sarvam";
|
|
14
|
+
|
|
15
|
+
// Initialize with default configuration using environment variables
|
|
16
|
+
const voice = new SarvamVoice();
|
|
17
|
+
|
|
18
|
+
// Or initialize with specific configuration
|
|
19
|
+
const voiceWithConfig = new SarvamVoice({
|
|
20
|
+
speechModel: {
|
|
21
|
+
model: "bulbul:v1",
|
|
22
|
+
apiKey: process.env.SARVAM_API_KEY!,
|
|
23
|
+
language: "en-IN",
|
|
24
|
+
properties: {
|
|
25
|
+
pitch: 0,
|
|
26
|
+
pace: 1.65,
|
|
27
|
+
loudness: 1.5,
|
|
28
|
+
speech_sample_rate: 8000,
|
|
29
|
+
enable_preprocessing: false,
|
|
30
|
+
eng_interpolation_wt: 123,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
listeningModel: {
|
|
34
|
+
model: "saarika:v2",
|
|
35
|
+
apiKey: process.env.SARVAM_API_KEY!,
|
|
36
|
+
languageCode: "en-IN",
|
|
37
|
+
filetype?: 'wav';
|
|
38
|
+
},
|
|
39
|
+
speaker: "meera", // Default voice
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
// Convert text to speech
|
|
44
|
+
const audioStream = await voice.speak("Hello, how can I help you?");
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
// Convert speech to text
|
|
48
|
+
const text = await voice.listen(audioStream, {
|
|
49
|
+
filetype: "wav",
|
|
50
|
+
});
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Sarvam API Docs -
|
|
54
|
+
|
|
55
|
+
https://docs.sarvam.ai/api-reference-docs/endpoints/text-to-speech
|
|
56
|
+
|
|
57
|
+
## Configuration
|
|
58
|
+
|
|
59
|
+
### Constructor Options
|
|
60
|
+
|
|
61
|
+
<PropertiesTable
|
|
62
|
+
content={[
|
|
63
|
+
{
|
|
64
|
+
name: "speechModel",
|
|
65
|
+
type: "SarvamVoiceConfig",
|
|
66
|
+
description: "Configuration for text-to-speech synthesis.",
|
|
67
|
+
isOptional: true,
|
|
68
|
+
defaultValue: "{ model: 'bulbul:v1', language: 'en-IN' }",
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: "speaker",
|
|
72
|
+
type: "SarvamVoiceId",
|
|
73
|
+
description:
|
|
74
|
+
"The speaker to be used for the output audio. If not provided, Meera will be used as default. AvailableOptions - meera, pavithra, maitreyi, arvind, amol, amartya, diya, neel, misha, vian, arjun, maya",
|
|
75
|
+
isOptional: true,
|
|
76
|
+
defaultValue: "'meera'",
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: "listeningModel",
|
|
80
|
+
type: "SarvamListenOptions",
|
|
81
|
+
description: "Configuration for speech-to-text recognition.",
|
|
82
|
+
isOptional: true,
|
|
83
|
+
defaultValue: "{ model: 'saarika:v2', language_code: 'unknown' }",
|
|
84
|
+
},
|
|
85
|
+
]}
|
|
86
|
+
/>
|
|
87
|
+
|
|
88
|
+
### SarvamVoiceConfig
|
|
89
|
+
|
|
90
|
+
<PropertiesTable
|
|
91
|
+
content={[
|
|
92
|
+
{
|
|
93
|
+
name: "apiKey",
|
|
94
|
+
type: "string",
|
|
95
|
+
description:
|
|
96
|
+
"Sarvam API key. Falls back to SARVAM_API_KEY environment variable.",
|
|
97
|
+
isOptional: true,
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: "model",
|
|
101
|
+
type: "SarvamTTSModel",
|
|
102
|
+
description: "Specifies the model to use for text-to-speech conversion.",
|
|
103
|
+
isOptional: true,
|
|
104
|
+
defaultValue: "'bulbul:v1'",
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: "language",
|
|
108
|
+
type: "SarvamTTSLanguage",
|
|
109
|
+
description:
|
|
110
|
+
"Target language for speech synthesis. Available options: hi-IN, bn-IN, kn-IN, ml-IN, mr-IN, od-IN, pa-IN, ta-IN, te-IN, en-IN, gu-IN",
|
|
111
|
+
isOptional: false,
|
|
112
|
+
defaultValue: "'en-IN'",
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: "properties",
|
|
116
|
+
type: "object",
|
|
117
|
+
description: "Additional voice properties for customization.",
|
|
118
|
+
isOptional: true,
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: "properties.pitch",
|
|
122
|
+
type: "number",
|
|
123
|
+
description:
|
|
124
|
+
"Controls the pitch of the audio. Lower values result in a deeper voice, while higher values make it sharper. The suitable range is between -0.75 and 0.75.",
|
|
125
|
+
isOptional: true,
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
name: "properties.pace",
|
|
129
|
+
type: "number",
|
|
130
|
+
description:
|
|
131
|
+
"Controls the speed of the audio. Lower values result in slower speech, while higher values make it faster. The suitable range is between 0.5 and 2.0. Default is 1.0. Required range: 0.3 <= x <= 3",
|
|
132
|
+
isOptional: true,
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
name: "properties.loudness",
|
|
136
|
+
type: "number",
|
|
137
|
+
description:
|
|
138
|
+
"Controls the loudness of the audio. Lower values result in quieter audio, while higher values make it louder. The suitable range is between 0.3 and 3.0. Required range: 0 <= x <= 3",
|
|
139
|
+
isOptional: true,
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
name: "properties.speech_sample_rate",
|
|
143
|
+
type: "8000 | 16000 | 22050",
|
|
144
|
+
description: "Audio sample rate in Hz.",
|
|
145
|
+
isOptional: true,
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
name: "properties.enable_preprocessing",
|
|
149
|
+
type: "boolean",
|
|
150
|
+
description:
|
|
151
|
+
"Controls whether normalization of English words and numeric entities (e.g., numbers, dates) is performed. Set to true for better handling of mixed-language text. Default is false.",
|
|
152
|
+
isOptional: true,
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
name: "properties.eng_interpolation_wt",
|
|
156
|
+
type: "number",
|
|
157
|
+
description: "Weight for interpolating with English speaker at encoder.",
|
|
158
|
+
isOptional: true,
|
|
159
|
+
},
|
|
160
|
+
]}
|
|
161
|
+
/>
|
|
162
|
+
|
|
163
|
+
### SarvamListenOptions
|
|
164
|
+
|
|
165
|
+
<PropertiesTable
|
|
166
|
+
content={[
|
|
167
|
+
{
|
|
168
|
+
name: "apiKey",
|
|
169
|
+
type: "string",
|
|
170
|
+
description:
|
|
171
|
+
"Sarvam API key. Falls back to SARVAM_API_KEY environment variable.",
|
|
172
|
+
isOptional: true,
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
name: "model",
|
|
176
|
+
type: "SarvamSTTModel",
|
|
177
|
+
description:
|
|
178
|
+
"Specifies the model to use for speech-to-text conversion. Note:- Default model is saarika:v2 . Available options: saarika:v1, saarika:v2, saarika:flash ",
|
|
179
|
+
isOptional: true,
|
|
180
|
+
defaultValue: "'saarika:v2'",
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
name: "languageCode",
|
|
184
|
+
type: "SarvamSTTLanguage",
|
|
185
|
+
description:
|
|
186
|
+
"Specifies the language of the input audio. This parameter is required to ensure accurate transcription. For the saarika:v1 model, this parameter is mandatory. For the saarika:v2 model, it is optional. unknown: Use this when the language is not known; the API will detect it automatically. Note:- that the saarika:v1 model does not support unknown language code. Available options: unknown, hi-IN, bn-IN, kn-IN, ml-IN, mr-IN, od-IN, pa-IN, ta-IN, te-IN, en-IN, gu-IN ",
|
|
187
|
+
isOptional: true,
|
|
188
|
+
defaultValue: "'unknown'",
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
name: "filetype",
|
|
192
|
+
type: "'mp3' | 'wav'",
|
|
193
|
+
description: "Audio format of the input stream.",
|
|
194
|
+
isOptional: true,
|
|
195
|
+
},
|
|
196
|
+
]}
|
|
197
|
+
/>
|
|
198
|
+
|
|
199
|
+
## Methods
|
|
200
|
+
|
|
201
|
+
### speak()
|
|
202
|
+
|
|
203
|
+
Converts text to speech using Sarvam's text-to-speech models.
|
|
204
|
+
|
|
205
|
+
<PropertiesTable
|
|
206
|
+
content={[
|
|
207
|
+
{
|
|
208
|
+
name: "input",
|
|
209
|
+
type: "string | NodeJS.ReadableStream",
|
|
210
|
+
description: "Text or text stream to convert to speech.",
|
|
211
|
+
isOptional: false,
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
name: "options.speaker",
|
|
215
|
+
type: "SarvamVoiceId",
|
|
216
|
+
description: "Voice ID to use for speech synthesis.",
|
|
217
|
+
isOptional: true,
|
|
218
|
+
defaultValue: "Constructor's speaker value",
|
|
219
|
+
},
|
|
220
|
+
]}
|
|
221
|
+
/>
|
|
222
|
+
|
|
223
|
+
Returns: `Promise<NodeJS.ReadableStream>`
|
|
224
|
+
|
|
225
|
+
### listen()
|
|
226
|
+
|
|
227
|
+
Transcribes audio using Sarvam's speech recognition models.
|
|
228
|
+
|
|
229
|
+
<PropertiesTable
|
|
230
|
+
content={[
|
|
231
|
+
{
|
|
232
|
+
name: "input",
|
|
233
|
+
type: "NodeJS.ReadableStream",
|
|
234
|
+
description: "Audio stream to transcribe.",
|
|
235
|
+
isOptional: false,
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
name: "options",
|
|
239
|
+
type: "SarvamListenOptions",
|
|
240
|
+
description: "Configuration options for speech recognition.",
|
|
241
|
+
isOptional: true,
|
|
242
|
+
},
|
|
243
|
+
]}
|
|
244
|
+
/>
|
|
245
|
+
|
|
246
|
+
Returns: `Promise<string>`
|
|
247
|
+
|
|
248
|
+
### getSpeakers()
|
|
249
|
+
|
|
250
|
+
Returns an array of available voice options.
|
|
251
|
+
|
|
252
|
+
Returns: `Promise<Array<{voiceId: SarvamVoiceId}>>`
|
|
253
|
+
|
|
254
|
+
## Notes
|
|
255
|
+
|
|
256
|
+
- API key can be provided via constructor options or the `SARVAM_API_KEY` environment variable
|
|
257
|
+
- If no API key is provided, the constructor will throw an error
|
|
258
|
+
- The service communicates with the Sarvam AI API at `https://api.sarvam.ai`
|
|
259
|
+
- Audio is returned as a stream containing binary audio data
|
|
260
|
+
- Speech recognition supports mp3 and wav audio formats
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: Speechify Voice | Voice Providers | Mastra Docs"
|
|
3
|
+
description: "Documentation for the Speechify voice implementation, providing text-to-speech capabilities."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Speechify
|
|
7
|
+
|
|
8
|
+
The Speechify voice implementation in Mastra provides text-to-speech capabilities using Speechify's API.
|
|
9
|
+
|
|
10
|
+
## Usage Example
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
import { SpeechifyVoice } from "@mastra/voice-speechify";
|
|
14
|
+
|
|
15
|
+
// Initialize with default configuration (uses SPEECHIFY_API_KEY environment variable)
|
|
16
|
+
const voice = new SpeechifyVoice();
|
|
17
|
+
|
|
18
|
+
// Initialize with custom configuration
|
|
19
|
+
const voice = new SpeechifyVoice({
|
|
20
|
+
speechModel: {
|
|
21
|
+
name: 'simba-english',
|
|
22
|
+
apiKey: 'your-api-key'
|
|
23
|
+
},
|
|
24
|
+
speaker: 'george' // Default voice
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// Convert text to speech
|
|
28
|
+
const audioStream = await voice.speak("Hello, world!", {
|
|
29
|
+
speaker: 'henry', // Override default voice
|
|
30
|
+
});
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Constructor Parameters
|
|
34
|
+
|
|
35
|
+
<PropertiesTable
|
|
36
|
+
content={[
|
|
37
|
+
{
|
|
38
|
+
name: "speechModel",
|
|
39
|
+
type: "SpeechifyConfig",
|
|
40
|
+
description: "Configuration for text-to-speech functionality",
|
|
41
|
+
isOptional: true,
|
|
42
|
+
defaultValue: "{ name: 'simba-english' }",
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: "speaker",
|
|
46
|
+
type: "SpeechifyVoiceId",
|
|
47
|
+
description: "Default voice ID to use for speech synthesis",
|
|
48
|
+
isOptional: true,
|
|
49
|
+
defaultValue: "'george'",
|
|
50
|
+
},
|
|
51
|
+
]}
|
|
52
|
+
/>
|
|
53
|
+
|
|
54
|
+
### SpeechifyConfig
|
|
55
|
+
|
|
56
|
+
<PropertiesTable
|
|
57
|
+
content={[
|
|
58
|
+
{
|
|
59
|
+
name: "name",
|
|
60
|
+
type: "VoiceModelName",
|
|
61
|
+
description: "The Speechify model to use",
|
|
62
|
+
isOptional: true,
|
|
63
|
+
defaultValue: "'simba-english'",
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: "apiKey",
|
|
67
|
+
type: "string",
|
|
68
|
+
description: "Speechify API key. Falls back to SPEECHIFY_API_KEY environment variable",
|
|
69
|
+
isOptional: true,
|
|
70
|
+
},
|
|
71
|
+
]}
|
|
72
|
+
/>
|
|
73
|
+
|
|
74
|
+
## Methods
|
|
75
|
+
|
|
76
|
+
### speak()
|
|
77
|
+
|
|
78
|
+
Converts text to speech using the configured speech model and voice.
|
|
79
|
+
|
|
80
|
+
<PropertiesTable
|
|
81
|
+
content={[
|
|
82
|
+
{
|
|
83
|
+
name: "input",
|
|
84
|
+
type: "string | NodeJS.ReadableStream",
|
|
85
|
+
description: "Text to convert to speech. If a stream is provided, it will be converted to text first.",
|
|
86
|
+
isOptional: false,
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: "options.speaker",
|
|
90
|
+
type: "string",
|
|
91
|
+
description: "Override the default speaker for this request",
|
|
92
|
+
isOptional: true,
|
|
93
|
+
defaultValue: "Constructor's speaker value",
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: "options.model",
|
|
97
|
+
type: "VoiceModelName",
|
|
98
|
+
description: "Override the default model for this request",
|
|
99
|
+
isOptional: true,
|
|
100
|
+
defaultValue: "Constructor's model value",
|
|
101
|
+
},
|
|
102
|
+
]}
|
|
103
|
+
/>
|
|
104
|
+
|
|
105
|
+
Returns: `Promise<NodeJS.ReadableStream>`
|
|
106
|
+
|
|
107
|
+
### getSpeakers()
|
|
108
|
+
|
|
109
|
+
Returns an array of available voice options, where each node contains:
|
|
110
|
+
|
|
111
|
+
<PropertiesTable
|
|
112
|
+
content={[
|
|
113
|
+
{
|
|
114
|
+
name: "voiceId",
|
|
115
|
+
type: "string",
|
|
116
|
+
description: "Unique identifier for the voice",
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: "name",
|
|
120
|
+
type: "string",
|
|
121
|
+
description: "Display name of the voice",
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
name: "language",
|
|
125
|
+
type: "string",
|
|
126
|
+
description: "Language code for the voice",
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
name: "gender",
|
|
130
|
+
type: "string",
|
|
131
|
+
description: "Gender of the voice",
|
|
132
|
+
},
|
|
133
|
+
]}
|
|
134
|
+
/>
|
|
135
|
+
|
|
136
|
+
### listen()
|
|
137
|
+
|
|
138
|
+
This method is not supported by Speechify and will throw an error. Speechify does not provide speech-to-text functionality.
|
|
139
|
+
|
|
140
|
+
## Notes
|
|
141
|
+
|
|
142
|
+
- Speechify requires an API key for authentication
|
|
143
|
+
- The default model is 'simba-english'
|
|
144
|
+
- Speech-to-text functionality is not supported
|
|
145
|
+
- Additional audio stream options can be passed through the speak() method's options parameter
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: voice.answer() | Voice Providers | Mastra Docs"
|
|
3
|
+
description: "Documentation for the answer() method available in real-time voice providers, which triggers the voice provider to generate a response."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# voice.answer()
|
|
7
|
+
|
|
8
|
+
The `answer()` method is used in real-time voice providers to trigger the AI to generate a response. This method is particularly useful in speech-to-speech conversations where you need to explicitly signal the AI to respond after receiving user input.
|
|
9
|
+
|
|
10
|
+
## Usage Example
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
import { OpenAIRealtimeVoice } from "@mastra/voice-openai-realtime";
|
|
14
|
+
import Speaker from "@mastra/node-speaker";
|
|
15
|
+
|
|
16
|
+
const speaker = new Speaker({
|
|
17
|
+
sampleRate: 24100, // Audio sample rate in Hz - standard for high-quality audio on MacBook Pro
|
|
18
|
+
channels: 1, // Mono audio output (as opposed to stereo which would be 2)
|
|
19
|
+
bitDepth: 16, // Bit depth for audio quality - CD quality standard (16-bit resolution)
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// Initialize a real-time voice provider
|
|
23
|
+
const voice = new OpenAIRealtimeVoice({
|
|
24
|
+
realtimeConfig: {
|
|
25
|
+
model: "gpt-4o",
|
|
26
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
27
|
+
},
|
|
28
|
+
speaker: "alloy", // Default voice
|
|
29
|
+
});
|
|
30
|
+
// Connect to the real-time service
|
|
31
|
+
await voice.connect();
|
|
32
|
+
// Register event listener for responses
|
|
33
|
+
voice.on("speaker", (stream) => {
|
|
34
|
+
// Handle audio response
|
|
35
|
+
stream.pipe(speaker);
|
|
36
|
+
});
|
|
37
|
+
// Send user audio input
|
|
38
|
+
const microphoneStream = getMicrophoneStream();
|
|
39
|
+
await voice.send(microphoneStream);
|
|
40
|
+
// Trigger the AI to respond
|
|
41
|
+
await voice.answer();
|
|
42
|
+
// With custom options (provider-specific)
|
|
43
|
+
await voice.answer({
|
|
44
|
+
options: {
|
|
45
|
+
content: "Hello, how can I help you today?",
|
|
46
|
+
voice: "nova",
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
## Parameters
|
|
53
|
+
|
|
54
|
+
<PropertiesTable
|
|
55
|
+
content={[
|
|
56
|
+
{
|
|
57
|
+
name: "options",
|
|
58
|
+
type: "Record<string, unknown>",
|
|
59
|
+
description: "Provider-specific options for the response",
|
|
60
|
+
isOptional: true,
|
|
61
|
+
}
|
|
62
|
+
]}
|
|
63
|
+
/>
|
|
64
|
+
|
|
65
|
+
## Return Value
|
|
66
|
+
|
|
67
|
+
Returns a `Promise<void>` that resolves when the response has been triggered.
|
|
68
|
+
|
|
69
|
+
## Provider-Specific Options
|
|
70
|
+
|
|
71
|
+
Each real-time voice provider may support different options for the `answer()` method:
|
|
72
|
+
|
|
73
|
+
### OpenAI Realtime
|
|
74
|
+
|
|
75
|
+
<PropertiesTable
|
|
76
|
+
content={[
|
|
77
|
+
{
|
|
78
|
+
name: "options.content",
|
|
79
|
+
type: "string",
|
|
80
|
+
description: "Text content to use for the response instead of generating one",
|
|
81
|
+
isOptional: true,
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: "options.voice",
|
|
85
|
+
type: "string",
|
|
86
|
+
description: "Voice ID to use for this specific response",
|
|
87
|
+
isOptional: true,
|
|
88
|
+
}
|
|
89
|
+
]}
|
|
90
|
+
/>
|
|
91
|
+
|
|
92
|
+
## Using with CompositeVoice
|
|
93
|
+
|
|
94
|
+
When using `CompositeVoice`, the `answer()` method delegates to the configured real-time provider:
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
import { CompositeVoice } from "@mastra/core/voice";
|
|
98
|
+
import { OpenAIRealtimeVoice } from "@mastra/voice-openai-realtime";
|
|
99
|
+
const realtimeVoice = new OpenAIRealtimeVoice();
|
|
100
|
+
const voice = new CompositeVoice({
|
|
101
|
+
realtimeProvider: realtimeVoice,
|
|
102
|
+
});
|
|
103
|
+
// Connect to the real-time service
|
|
104
|
+
await voice.connect();
|
|
105
|
+
// This will use the OpenAIRealtimeVoice provider
|
|
106
|
+
await voice.answer();
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Notes
|
|
110
|
+
|
|
111
|
+
- This method is only implemented by real-time voice providers that support speech-to-speech capabilities
|
|
112
|
+
- If called on a voice provider that doesn't support this functionality, it will log a warning and resolve immediately
|
|
113
|
+
- The response audio will typically be emitted through the 'speaking' event rather than returned directly
|
|
114
|
+
- For providers that support it, you can use this method to send a specific response instead of having the AI generate one
|
|
115
|
+
- This method is commonly used in conjunction with `send()` to create a conversational flow
|
|
116
|
+
|
|
117
|
+
## Related Methods
|
|
118
|
+
|
|
119
|
+
- [voice.connect()](./voice.connect) - Establishes a connection to the real-time service
|
|
120
|
+
- [voice.send()](./voice.send) - Sends audio data to the voice provider
|
|
121
|
+
- [voice.speak()](./voice.speak) - Converts text to speech
|
|
122
|
+
- [voice.listen()](./voice.listen) - Converts speech to text
|