@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,203 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: voice.speak() | Voice Providers | Mastra Docs"
|
|
3
|
+
description: "Documentation for the speak() method available in all Mastra voice providers, which converts text to speech."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# voice.speak()
|
|
7
|
+
|
|
8
|
+
The `speak()` method is a core function available in all Mastra voice providers that converts text to speech. It takes text input and returns an audio stream that can be played or saved.
|
|
9
|
+
|
|
10
|
+
## Usage Example
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
import { OpenAIVoice } from "@mastra/voice-openai";
|
|
14
|
+
// Initialize a voice provider
|
|
15
|
+
const voice = new OpenAIVoice({
|
|
16
|
+
speaker: "alloy", // Default voice
|
|
17
|
+
});
|
|
18
|
+
// Basic usage with default settings
|
|
19
|
+
const audioStream = await voice.speak("Hello, world!");
|
|
20
|
+
// Using a different voice for this specific request
|
|
21
|
+
const audioStreamWithDifferentVoice = await voice.speak("Hello again!", {
|
|
22
|
+
speaker: "nova",
|
|
23
|
+
});
|
|
24
|
+
// Using provider-specific options
|
|
25
|
+
const audioStreamWithOptions = await voice.speak("Hello with options!", {
|
|
26
|
+
speaker: "echo",
|
|
27
|
+
speed: 1.2, // OpenAI-specific option
|
|
28
|
+
});
|
|
29
|
+
// Using a text stream as input
|
|
30
|
+
import { Readable } from "stream";
|
|
31
|
+
const textStream = Readable.from(["Hello", " from", " a", " stream!"]);
|
|
32
|
+
const audioStreamFromTextStream = await voice.speak(textStream);
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
## Parameters
|
|
37
|
+
|
|
38
|
+
<PropertiesTable
|
|
39
|
+
content={[
|
|
40
|
+
{
|
|
41
|
+
name: "input",
|
|
42
|
+
type: "string | NodeJS.ReadableStream",
|
|
43
|
+
description: "Text to convert to speech. Can be a string or a readable stream of text.",
|
|
44
|
+
isOptional: false,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: "options",
|
|
48
|
+
type: "object",
|
|
49
|
+
description: "Options for speech synthesis",
|
|
50
|
+
isOptional: true,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: "options.speaker",
|
|
54
|
+
type: "string",
|
|
55
|
+
description: "Voice ID to use for this specific request. Overrides the default speaker set in the constructor.",
|
|
56
|
+
isOptional: true,
|
|
57
|
+
},
|
|
58
|
+
]}
|
|
59
|
+
/>
|
|
60
|
+
|
|
61
|
+
## Return Value
|
|
62
|
+
|
|
63
|
+
Returns a `Promise<NodeJS.ReadableStream | void>` where:
|
|
64
|
+
|
|
65
|
+
- `NodeJS.ReadableStream`: A stream of audio data that can be played or saved
|
|
66
|
+
- `void`: When using a realtime voice provider that emits audio through events instead of returning it directly
|
|
67
|
+
|
|
68
|
+
## Provider-Specific Options
|
|
69
|
+
|
|
70
|
+
Each voice provider may support additional options specific to their implementation. Here are some examples:
|
|
71
|
+
|
|
72
|
+
### OpenAI
|
|
73
|
+
|
|
74
|
+
<PropertiesTable
|
|
75
|
+
content={[
|
|
76
|
+
{
|
|
77
|
+
name: "options.speed",
|
|
78
|
+
type: "number",
|
|
79
|
+
description: "Speech speed multiplier. Values between 0.25 and 4.0 are supported.",
|
|
80
|
+
isOptional: true,
|
|
81
|
+
defaultValue: "1.0",
|
|
82
|
+
}
|
|
83
|
+
]}
|
|
84
|
+
/>
|
|
85
|
+
|
|
86
|
+
### ElevenLabs
|
|
87
|
+
|
|
88
|
+
<PropertiesTable
|
|
89
|
+
content={[
|
|
90
|
+
{
|
|
91
|
+
name: "options.stability",
|
|
92
|
+
type: "number",
|
|
93
|
+
description: "Voice stability. Higher values result in more stable, less expressive speech.",
|
|
94
|
+
isOptional: true,
|
|
95
|
+
defaultValue: "0.5",
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: "options.similarity_boost",
|
|
99
|
+
type: "number",
|
|
100
|
+
description: "Voice clarity and similarity to the original voice.",
|
|
101
|
+
isOptional: true,
|
|
102
|
+
defaultValue: "0.75",
|
|
103
|
+
}
|
|
104
|
+
]}
|
|
105
|
+
/>
|
|
106
|
+
|
|
107
|
+
### Google
|
|
108
|
+
|
|
109
|
+
<PropertiesTable
|
|
110
|
+
content={[
|
|
111
|
+
{
|
|
112
|
+
name: "options.languageCode",
|
|
113
|
+
type: "string",
|
|
114
|
+
description: "Language code for the voice (e.g., 'en-US').",
|
|
115
|
+
isOptional: true,
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
name: "options.audioConfig",
|
|
119
|
+
type: "object",
|
|
120
|
+
description: "Audio configuration options from Google Cloud Text-to-Speech API.",
|
|
121
|
+
isOptional: true,
|
|
122
|
+
defaultValue: "{ audioEncoding: 'LINEAR16' }",
|
|
123
|
+
}
|
|
124
|
+
]}
|
|
125
|
+
/>
|
|
126
|
+
|
|
127
|
+
### Murf
|
|
128
|
+
|
|
129
|
+
<PropertiesTable
|
|
130
|
+
content={[
|
|
131
|
+
{
|
|
132
|
+
name: "options.properties.rate",
|
|
133
|
+
type: "number",
|
|
134
|
+
description: "Speech rate multiplier.",
|
|
135
|
+
isOptional: true,
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
name: "options.properties.pitch",
|
|
139
|
+
type: "number",
|
|
140
|
+
description: "Voice pitch adjustment.",
|
|
141
|
+
isOptional: true,
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
name: "options.properties.format",
|
|
145
|
+
type: "'MP3' | 'WAV' | 'FLAC' | 'ALAW' | 'ULAW'",
|
|
146
|
+
description: "Output audio format.",
|
|
147
|
+
isOptional: true,
|
|
148
|
+
}
|
|
149
|
+
]}
|
|
150
|
+
/>
|
|
151
|
+
|
|
152
|
+
## Realtime Voice Providers
|
|
153
|
+
|
|
154
|
+
When using realtime voice providers like `OpenAIRealtimeVoice`, the `speak()` method behaves differently:
|
|
155
|
+
|
|
156
|
+
- Instead of returning an audio stream, it emits a 'speaking' event with the audio data
|
|
157
|
+
- You need to register an event listener to receive the audio chunks
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
import { OpenAIRealtimeVoice } from "@mastra/voice-openai-realtime";
|
|
161
|
+
import Speaker from "@mastra/node-speaker";
|
|
162
|
+
|
|
163
|
+
const speaker = new Speaker({
|
|
164
|
+
sampleRate: 24100, // Audio sample rate in Hz - standard for high-quality audio on MacBook Pro
|
|
165
|
+
channels: 1, // Mono audio output (as opposed to stereo which would be 2)
|
|
166
|
+
bitDepth: 16, // Bit depth for audio quality - CD quality standard (16-bit resolution)
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
const voice = new OpenAIRealtimeVoice();
|
|
170
|
+
await voice.connect();
|
|
171
|
+
// Register event listener for audio chunks
|
|
172
|
+
voice.on("speaker", (stream) => {
|
|
173
|
+
// Handle audio chunk (e.g., play it or save it)
|
|
174
|
+
stream.pipe(speaker)
|
|
175
|
+
});
|
|
176
|
+
// This will emit 'speaking' events instead of returning a stream
|
|
177
|
+
await voice.speak("Hello, this is realtime speech!");
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
## Using with CompositeVoice
|
|
182
|
+
|
|
183
|
+
When using `CompositeVoice`, the `speak()` method delegates to the configured speaking provider:
|
|
184
|
+
|
|
185
|
+
```typescript
|
|
186
|
+
import { CompositeVoice } from "@mastra/core/voice";
|
|
187
|
+
import { OpenAIVoice } from "@mastra/voice-openai";
|
|
188
|
+
import { PlayAIVoice } from "@mastra/voice-playai";
|
|
189
|
+
const voice = new CompositeVoice({
|
|
190
|
+
speakProvider: new PlayAIVoice(),
|
|
191
|
+
listenProvider: new OpenAIVoice(),
|
|
192
|
+
});
|
|
193
|
+
// This will use the PlayAIVoice provider
|
|
194
|
+
const audioStream = await voice.speak("Hello, world!");
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## Notes
|
|
198
|
+
|
|
199
|
+
- The behavior of `speak()` may vary slightly between providers, but all implementations follow the same basic interface.
|
|
200
|
+
- When using a realtime voice provider, the method might not return an audio stream directly but instead emit a 'speaking' event.
|
|
201
|
+
- If a text stream is provided as input, the provider will typically convert it to a string before processing.
|
|
202
|
+
- The audio format of the returned stream depends on the provider. Common formats include MP3, WAV, and OGG.
|
|
203
|
+
- For best performance, consider closing or ending the audio stream when you're done with it.
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: .after() | Building Workflows | Mastra Docs"
|
|
3
|
+
description: Documentation for the `after()` method in workflows, enabling branching and merging paths.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# .after()
|
|
7
|
+
|
|
8
|
+
The `.after()` method defines explicit dependencies between workflow steps, enabling branching and merging paths in your workflow execution.
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
### Basic Branching
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
workflow
|
|
16
|
+
.step(stepA)
|
|
17
|
+
.then(stepB)
|
|
18
|
+
.after(stepA) // Create new branch after stepA completes
|
|
19
|
+
.step(stepC);
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Merging Multiple Branches
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
workflow
|
|
26
|
+
.step(stepA)
|
|
27
|
+
.then(stepB)
|
|
28
|
+
.step(stepC)
|
|
29
|
+
.then(stepD)
|
|
30
|
+
.after([stepB, stepD]) // Create a step that depends on multiple steps
|
|
31
|
+
.step(stepE);
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Parameters
|
|
35
|
+
|
|
36
|
+
<PropertiesTable
|
|
37
|
+
content={[
|
|
38
|
+
{
|
|
39
|
+
name: "steps",
|
|
40
|
+
type: "Step | Step[]",
|
|
41
|
+
description: "A single step or array of steps that must complete before continuing",
|
|
42
|
+
isOptional: false
|
|
43
|
+
}
|
|
44
|
+
]}
|
|
45
|
+
/>
|
|
46
|
+
|
|
47
|
+
## Returns
|
|
48
|
+
|
|
49
|
+
<PropertiesTable
|
|
50
|
+
content={[
|
|
51
|
+
{
|
|
52
|
+
name: "workflow",
|
|
53
|
+
type: "Workflow",
|
|
54
|
+
description: "The workflow instance for method chaining"
|
|
55
|
+
}
|
|
56
|
+
]}
|
|
57
|
+
/>
|
|
58
|
+
|
|
59
|
+
## Examples
|
|
60
|
+
|
|
61
|
+
### Single Dependency
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
workflow
|
|
65
|
+
.step(fetchData)
|
|
66
|
+
.then(processData)
|
|
67
|
+
.after(fetchData) // Branch after fetchData
|
|
68
|
+
.step(logData);
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Multiple Dependencies (Merging Branches)
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
workflow
|
|
75
|
+
.step(fetchUserData)
|
|
76
|
+
.then(validateUserData)
|
|
77
|
+
.step(fetchProductData)
|
|
78
|
+
.then(validateProductData)
|
|
79
|
+
.after([validateUserData, validateProductData]) // Wait for both validations to complete
|
|
80
|
+
.step(processOrder);
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Related
|
|
84
|
+
|
|
85
|
+
- [Branching Paths example](../../../examples/workflows/branching-paths.mdx)
|
|
86
|
+
- [Workflow Class Reference](./workflow.mdx)
|
|
87
|
+
- [Step Reference](./step-class.mdx)
|
|
88
|
+
- [Control Flow Guide](../../workflows/control-flow.mdx#merging-multiple-branches)
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: ".afterEvent() Method | Mastra Docs"
|
|
3
|
+
description: "Reference for the afterEvent method in Mastra workflows that creates event-based suspension points."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# afterEvent()
|
|
7
|
+
|
|
8
|
+
The `afterEvent()` method creates a suspension point in your workflow that waits for a specific event to occur before continuing execution.
|
|
9
|
+
|
|
10
|
+
## Syntax
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
workflow.afterEvent(eventName: string): Workflow
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Parameters
|
|
17
|
+
|
|
18
|
+
| Parameter | Type | Description |
|
|
19
|
+
|-----------|------|-------------|
|
|
20
|
+
| eventName | string | The name of the event to wait for. Must match an event defined in the workflow's `events` configuration. |
|
|
21
|
+
|
|
22
|
+
## Return Value
|
|
23
|
+
|
|
24
|
+
Returns the workflow instance for method chaining.
|
|
25
|
+
|
|
26
|
+
## Description
|
|
27
|
+
|
|
28
|
+
The `afterEvent()` method is used to create an automatic suspension point in your workflow that waits for a specific named event. It's essentially a declarative way to define a point where your workflow should pause and wait for an external event to occur.
|
|
29
|
+
|
|
30
|
+
When you call `afterEvent()`, Mastra:
|
|
31
|
+
|
|
32
|
+
1. Creates a special step with ID `__eventName_event`
|
|
33
|
+
2. This step automatically suspends the workflow execution
|
|
34
|
+
3. The workflow remains suspended until the specified event is triggered via `resumeWithEvent()`
|
|
35
|
+
4. When the event occurs, execution continues with the step following the `afterEvent()` call
|
|
36
|
+
|
|
37
|
+
This method is part of Mastra's event-driven workflow capabilities, allowing you to create workflows that coordinate with external systems or user interactions without manually implementing suspension logic.
|
|
38
|
+
|
|
39
|
+
## Usage Notes
|
|
40
|
+
|
|
41
|
+
- The event specified in `afterEvent()` must be defined in the workflow's `events` configuration with a schema
|
|
42
|
+
- The special step created has a predictable ID format: `__eventName_event` (e.g., `__approvalReceived_event`)
|
|
43
|
+
- Any step following `afterEvent()` can access the event data via `context.inputData.resumedEvent`
|
|
44
|
+
- Event data is validated against the schema defined for that event when `resumeWithEvent()` is called
|
|
45
|
+
|
|
46
|
+
## Examples
|
|
47
|
+
|
|
48
|
+
### Basic Usage
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
// Define workflow with events
|
|
52
|
+
const workflow = new Workflow({
|
|
53
|
+
name: 'approval-workflow',
|
|
54
|
+
events: {
|
|
55
|
+
approval: {
|
|
56
|
+
schema: z.object({
|
|
57
|
+
approved: z.boolean(),
|
|
58
|
+
approverName: z.string(),
|
|
59
|
+
}),
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// Build workflow with event suspension point
|
|
65
|
+
workflow
|
|
66
|
+
.step(submitRequest)
|
|
67
|
+
.afterEvent('approval') // Workflow suspends here
|
|
68
|
+
.step(processApproval) // This step runs after the event occurs
|
|
69
|
+
.commit();
|
|
70
|
+
```
|
|
71
|
+
## Related
|
|
72
|
+
|
|
73
|
+
- [Event-Driven Workflows](./events.mdx)
|
|
74
|
+
- [resumeWithEvent()](./resumeWithEvent.mdx)
|
|
75
|
+
- [Suspend and Resume](../../workflows/suspend-and-resume.mdx)
|
|
76
|
+
- [Workflow Class](./workflow.mdx)
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: Workflow.commit() | Running Workflows | Mastra Docs"
|
|
3
|
+
description: Documentation for the `.commit()` method in workflows, which re-initializes the workflow machine with the current step configuration.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Workflow.commit()
|
|
7
|
+
|
|
8
|
+
The `.commit()` method re-initializes the workflow's state machine with the current step configuration.
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
workflow
|
|
14
|
+
.step(stepA)
|
|
15
|
+
.then(stepB)
|
|
16
|
+
.commit();
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Returns
|
|
20
|
+
|
|
21
|
+
<PropertiesTable
|
|
22
|
+
content={[
|
|
23
|
+
{
|
|
24
|
+
name: "workflow",
|
|
25
|
+
type: "Workflow",
|
|
26
|
+
description: "The workflow instance"
|
|
27
|
+
}
|
|
28
|
+
]}
|
|
29
|
+
/>
|
|
30
|
+
|
|
31
|
+
## Related
|
|
32
|
+
|
|
33
|
+
- [Branching Paths example](../../../examples/workflows/branching-paths.mdx)
|
|
34
|
+
- [Workflow Class Reference](./workflow.mdx)
|
|
35
|
+
- [Step Reference](./step-class.mdx)
|
|
36
|
+
- [Control Flow Guide](../../workflows/control-flow.mdx)
|
|
37
|
+
```
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: Workflow.createRun() | Running Workflows | Mastra Docs"
|
|
3
|
+
description: "Documentation for the `.createRun()` method in workflows, which initializes a new workflow run instance."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Workflow.createRun()
|
|
7
|
+
|
|
8
|
+
The `.createRun()` method initializes a new workflow run instance. It generates a unique run ID for tracking and returns a start function that begins workflow execution when called.
|
|
9
|
+
|
|
10
|
+
One reason to use `.createRun()` vs `.execute()` is to get a unique run ID for tracking, logging, or subscribing via `.watch()`.
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
const { runId, start, watch } = workflow.createRun();
|
|
16
|
+
|
|
17
|
+
const result = await start();
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Returns
|
|
21
|
+
|
|
22
|
+
<PropertiesTable
|
|
23
|
+
content={[
|
|
24
|
+
{
|
|
25
|
+
name: "runId",
|
|
26
|
+
type: "string",
|
|
27
|
+
description: "Unique identifier for tracking this workflow run",
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: "start",
|
|
31
|
+
type: "() => Promise<WorkflowResult>",
|
|
32
|
+
description: "Function that begins workflow execution when called",
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: "watch",
|
|
36
|
+
type: "(callback: (record: WorkflowResult) => void) => () => void",
|
|
37
|
+
description: "Function that accepts a callback function that will be called with each transition of the workflow run",
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: "resume",
|
|
41
|
+
type: "({stepId: string, context: Record<string, any>}) => Promise<WorkflowResult>",
|
|
42
|
+
description: "Function that resumes a workflow run from a given step ID and context",
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: "resumeWithEvent",
|
|
46
|
+
type: "(eventName: string, data: any) => Promise<WorkflowResult>",
|
|
47
|
+
description: "Function that resumes a workflow run from a given event name and data",
|
|
48
|
+
},
|
|
49
|
+
]}
|
|
50
|
+
/>
|
|
51
|
+
|
|
52
|
+
## Error Handling
|
|
53
|
+
|
|
54
|
+
The start function may throw validation errors if the workflow configuration is invalid:
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
try {
|
|
58
|
+
const { runId, start, watch, resume, resumeWithEvent } = workflow.createRun();
|
|
59
|
+
await start({ triggerData: data });
|
|
60
|
+
} catch (error) {
|
|
61
|
+
if (error instanceof ValidationError) {
|
|
62
|
+
// Handle validation errors
|
|
63
|
+
console.log(error.type); // 'circular_dependency' | 'no_terminal_path' | 'unreachable_step'
|
|
64
|
+
console.log(error.details);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Related
|
|
70
|
+
|
|
71
|
+
- [Workflow Class Reference](./workflow.mdx)
|
|
72
|
+
- [Step Class Reference](./step-class.mdx)
|
|
73
|
+
- See the [Creating a Workflow](../../../examples/workflows/creating-a-workflow.mdx) example for complete usage
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
```
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: Workflow.else() | Conditional Branching | Mastra Docs"
|
|
3
|
+
description: "Documentation for the `.else()` method in Mastra workflows, which creates an alternative branch when an if condition is false."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Workflow.else()
|
|
7
|
+
|
|
8
|
+
> Experimental
|
|
9
|
+
|
|
10
|
+
The `.else()` method creates an alternative branch in the workflow that executes when the preceding `if` condition evaluates to false. This enables workflows to follow different paths based on conditions.
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```typescript copy showLineNumbers
|
|
15
|
+
workflow
|
|
16
|
+
.step(startStep)
|
|
17
|
+
.if(async ({ context }) => {
|
|
18
|
+
const value = context.getStepResult<{ value: number }>('start')?.value;
|
|
19
|
+
return value < 10;
|
|
20
|
+
})
|
|
21
|
+
.then(ifBranchStep)
|
|
22
|
+
.else() // Alternative branch when the condition is false
|
|
23
|
+
.then(elseBranchStep)
|
|
24
|
+
.commit();
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Parameters
|
|
28
|
+
|
|
29
|
+
The `else()` method does not take any parameters.
|
|
30
|
+
|
|
31
|
+
## Returns
|
|
32
|
+
|
|
33
|
+
<PropertiesTable
|
|
34
|
+
content={[
|
|
35
|
+
{
|
|
36
|
+
name: "workflow",
|
|
37
|
+
type: "Workflow",
|
|
38
|
+
description: "The workflow instance for method chaining"
|
|
39
|
+
}
|
|
40
|
+
]}
|
|
41
|
+
/>
|
|
42
|
+
|
|
43
|
+
## Behavior
|
|
44
|
+
|
|
45
|
+
- The `else()` method must follow an `if()` branch in the workflow definition
|
|
46
|
+
- It creates a branch that executes only when the preceding `if` condition evaluates to false
|
|
47
|
+
- You can chain multiple steps after an `else()` using `.then()`
|
|
48
|
+
- You can nest additional `if`/`else` conditions within an `else` branch
|
|
49
|
+
|
|
50
|
+
## Error Handling
|
|
51
|
+
|
|
52
|
+
The `else()` method requires a preceding `if()` statement. If you try to use it without a preceding `if`, an error will be thrown:
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
try {
|
|
56
|
+
// This will throw an error
|
|
57
|
+
workflow
|
|
58
|
+
.step(someStep)
|
|
59
|
+
.else()
|
|
60
|
+
.then(anotherStep)
|
|
61
|
+
.commit();
|
|
62
|
+
} catch (error) {
|
|
63
|
+
console.error(error); // "No active condition found"
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Related
|
|
68
|
+
|
|
69
|
+
- [if Reference](./if.mdx)
|
|
70
|
+
- [then Reference](./then.mdx)
|
|
71
|
+
- [Control Flow Guide](../../workflows/control-flow.mdx)
|
|
72
|
+
- [Step Condition Reference](./step-condition.mdx)
|