@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,378 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Storage in Mastra | Mastra Docs
|
|
3
|
+
description: Overview of Mastra's storage system and data persistence capabilities.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
import { Tabs } from "nextra/components";
|
|
7
|
+
|
|
8
|
+
import { PropertiesTable } from "@/components/properties-table";
|
|
9
|
+
import { SchemaTable } from "@/components/schema-table";
|
|
10
|
+
import { StorageOverviewImage } from "@/components/storage-overview-image";
|
|
11
|
+
|
|
12
|
+
# MastraStorage
|
|
13
|
+
|
|
14
|
+
`MastraStorage` provides a unified interface for managing:
|
|
15
|
+
|
|
16
|
+
- **Suspended Workflows**: the serialized state of suspended workflows (so they can be resumed later)
|
|
17
|
+
- **Memory**: threads and messages per `resourceId` in your application
|
|
18
|
+
- **Traces**: OpenTelemetry traces from all components of Mastra
|
|
19
|
+
- **Eval Datasets**: scores and scoring reasons from eval runs
|
|
20
|
+
|
|
21
|
+
<br />
|
|
22
|
+
|
|
23
|
+
<br />
|
|
24
|
+
|
|
25
|
+
<StorageOverviewImage />
|
|
26
|
+
|
|
27
|
+
Mastra provides different storage providers, but you can treat them as interchangeable. Eg, you could use libsql in development but postgres in production, and your code will work the same both ways.
|
|
28
|
+
|
|
29
|
+
## Configuration
|
|
30
|
+
|
|
31
|
+
Mastra can be configured with a default storage option:
|
|
32
|
+
|
|
33
|
+
```typescript copy
|
|
34
|
+
import { Mastra } from "@mastra/core/mastra";
|
|
35
|
+
import { DefaultStorage } from "@mastra/core/storage/libsql";
|
|
36
|
+
|
|
37
|
+
const mastra = new Mastra({
|
|
38
|
+
storage: new DefaultStorage({
|
|
39
|
+
config: {
|
|
40
|
+
url: "file:.mastra/mastra.db",
|
|
41
|
+
},
|
|
42
|
+
}),
|
|
43
|
+
});
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Data Schema
|
|
47
|
+
|
|
48
|
+
<Tabs items={['Messages', 'Threads', 'Workflows', 'Eval Datasets', 'Traces']}>
|
|
49
|
+
<Tabs.Tab>
|
|
50
|
+
Stores conversation messages and their metadata. Each message belongs to a thread and contains the actual content along with metadata about the sender role and message type.
|
|
51
|
+
|
|
52
|
+
<br />
|
|
53
|
+
<SchemaTable
|
|
54
|
+
columns={[
|
|
55
|
+
{
|
|
56
|
+
name: "id",
|
|
57
|
+
type: "uuidv4",
|
|
58
|
+
description: "Unique identifier for the message (format: `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`)",
|
|
59
|
+
constraints: [
|
|
60
|
+
{ type: "primaryKey" },
|
|
61
|
+
{ type: "nullable", value: false }
|
|
62
|
+
]
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: "thread_id",
|
|
66
|
+
type: "uuidv4",
|
|
67
|
+
description: "Parent thread reference",
|
|
68
|
+
constraints: [
|
|
69
|
+
{ type: "foreignKey", value: "threads.id" },
|
|
70
|
+
{ type: "nullable", value: false }
|
|
71
|
+
]
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: "content",
|
|
75
|
+
type: "text",
|
|
76
|
+
constraints: [{ type: "nullable", value: false }]
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: "role",
|
|
80
|
+
type: "text",
|
|
81
|
+
description: "Enum of `system | user | assistant | tool`",
|
|
82
|
+
constraints: [{ type: "nullable", value: false }]
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: "type",
|
|
86
|
+
type: "text",
|
|
87
|
+
description: "Enum of `text | tool-call | tool-result`",
|
|
88
|
+
constraints: [{ type: "nullable", value: false }]
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: "createdAt",
|
|
92
|
+
type: "timestamp",
|
|
93
|
+
description: "Used for thread message ordering",
|
|
94
|
+
constraints: [{ type: "nullable", value: false }]
|
|
95
|
+
}
|
|
96
|
+
]}
|
|
97
|
+
/>
|
|
98
|
+
</Tabs.Tab>
|
|
99
|
+
<Tabs.Tab>
|
|
100
|
+
Groups related messages together and associates them with a resource. Contains metadata about the conversation.
|
|
101
|
+
|
|
102
|
+
<br />
|
|
103
|
+
<SchemaTable
|
|
104
|
+
columns={[
|
|
105
|
+
{
|
|
106
|
+
name: "id",
|
|
107
|
+
type: "uuidv4",
|
|
108
|
+
description: "Unique identifier for the thread (format: `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`)",
|
|
109
|
+
constraints: [
|
|
110
|
+
{ type: "primaryKey" },
|
|
111
|
+
{ type: "nullable", value: false }
|
|
112
|
+
]
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: "resourceId",
|
|
116
|
+
type: "text",
|
|
117
|
+
description: "Primary identifier of the external resource this thread is associated with. Used to group and retrieve related threads.",
|
|
118
|
+
constraints: [{ type: "nullable", value: false }]
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: "title",
|
|
122
|
+
type: "text",
|
|
123
|
+
description: "Title of the conversation thread",
|
|
124
|
+
constraints: [{ type: "nullable", value: false }]
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
name: "metadata",
|
|
128
|
+
type: "text",
|
|
129
|
+
description: "Custom thread metadata as stringified JSON. Example:",
|
|
130
|
+
example: {
|
|
131
|
+
category: "support",
|
|
132
|
+
priority: 1
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
name: "createdAt",
|
|
137
|
+
type: "timestamp",
|
|
138
|
+
constraints: [{ type: "nullable", value: false }]
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
name: "updatedAt",
|
|
142
|
+
type: "timestamp",
|
|
143
|
+
description: "Used for thread ordering history",
|
|
144
|
+
constraints: [{ type: "nullable", value: false }]
|
|
145
|
+
}
|
|
146
|
+
]}
|
|
147
|
+
/>
|
|
148
|
+
</Tabs.Tab>
|
|
149
|
+
<Tabs.Tab>
|
|
150
|
+
When `suspend` is called on a workflow, its state is saved in the following format. When `resume` is called, that state is rehydrated.
|
|
151
|
+
|
|
152
|
+
<br />
|
|
153
|
+
<SchemaTable
|
|
154
|
+
columns={[
|
|
155
|
+
{
|
|
156
|
+
name: "workflow_name",
|
|
157
|
+
type: "text",
|
|
158
|
+
description: "Name of the workflow",
|
|
159
|
+
constraints: [{ type: "nullable", value: false }]
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
name: "run_id",
|
|
163
|
+
type: "uuidv4",
|
|
164
|
+
description: "Unique identifier for the workflow execution. Used to track state across suspend/resume cycles (format: `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`)",
|
|
165
|
+
constraints: [{ type: "nullable", value: false }]
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
name: "snapshot",
|
|
169
|
+
type: "text",
|
|
170
|
+
description: "Serialized workflow state as JSON. Example:",
|
|
171
|
+
example: {
|
|
172
|
+
value: { currentState: 'running' },
|
|
173
|
+
context: {
|
|
174
|
+
stepResults: {},
|
|
175
|
+
attempts: {},
|
|
176
|
+
triggerData: {}
|
|
177
|
+
},
|
|
178
|
+
activePaths: [],
|
|
179
|
+
runId: '550e8400-e29b-41d4-a716-446655440000',
|
|
180
|
+
timestamp: 1648176000000
|
|
181
|
+
},
|
|
182
|
+
constraints: [{ type: "nullable", value: false }]
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
name: "createdAt",
|
|
186
|
+
type: "timestamp",
|
|
187
|
+
constraints: [{ type: "nullable", value: false }]
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
name: "updatedAt",
|
|
191
|
+
type: "timestamp",
|
|
192
|
+
description: "Last modification time, used to track state changes during workflow execution",
|
|
193
|
+
constraints: [{ type: "nullable", value: false }]
|
|
194
|
+
}
|
|
195
|
+
]}
|
|
196
|
+
/>
|
|
197
|
+
</Tabs.Tab>
|
|
198
|
+
<Tabs.Tab>
|
|
199
|
+
Stores eval results from running metrics against agent outputs.
|
|
200
|
+
|
|
201
|
+
<br />
|
|
202
|
+
<SchemaTable
|
|
203
|
+
columns={[
|
|
204
|
+
{
|
|
205
|
+
name: "input",
|
|
206
|
+
type: "text",
|
|
207
|
+
description: "Input provided to the agent",
|
|
208
|
+
constraints: [{ type: "nullable", value: false }]
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
name: "output",
|
|
212
|
+
type: "text",
|
|
213
|
+
description: "Output generated by the agent",
|
|
214
|
+
constraints: [{ type: "nullable", value: false }]
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
name: "result",
|
|
218
|
+
type: "jsonb",
|
|
219
|
+
description: "Eval result data that includes score and details. Example:",
|
|
220
|
+
example: {
|
|
221
|
+
score: 0.95,
|
|
222
|
+
details: {
|
|
223
|
+
reason: "Response accurately reflects source material",
|
|
224
|
+
citations: ["page 1", "page 3"]
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
constraints: [{ type: "nullable", value: false }]
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
name: "agent_name",
|
|
231
|
+
type: "text",
|
|
232
|
+
constraints: [{ type: "nullable", value: false }]
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
name: "metric_name",
|
|
236
|
+
type: "text",
|
|
237
|
+
description: "e.g Faithfulness, Hallucination, etc.",
|
|
238
|
+
constraints: [{ type: "nullable", value: false }]
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
name: "instructions",
|
|
242
|
+
type: "text",
|
|
243
|
+
description: "System prompt or instructions for the agent",
|
|
244
|
+
constraints: [{ type: "nullable", value: false }]
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
name: "test_info",
|
|
248
|
+
type: "jsonb",
|
|
249
|
+
description: "Additional test metadata and configuration",
|
|
250
|
+
constraints: [{ type: "nullable", value: false }]
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
name: "global_run_id",
|
|
254
|
+
type: "uuidv4",
|
|
255
|
+
description: "Groups related evaluation runs (e.g. all unit tests in a CI run)",
|
|
256
|
+
constraints: [{ type: "nullable", value: false }]
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
name: "run_id",
|
|
260
|
+
type: "uuidv4",
|
|
261
|
+
description: "Unique identifier for the run being evaluated (format: `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`)",
|
|
262
|
+
constraints: [{ type: "nullable", value: false }]
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
name: "created_at",
|
|
266
|
+
type: "timestamp",
|
|
267
|
+
constraints: [{ type: "nullable", value: false }]
|
|
268
|
+
}
|
|
269
|
+
]}
|
|
270
|
+
/>
|
|
271
|
+
</Tabs.Tab>
|
|
272
|
+
<Tabs.Tab>
|
|
273
|
+
Captures OpenTelemetry traces for monitoring and debugging.
|
|
274
|
+
|
|
275
|
+
<br />
|
|
276
|
+
<SchemaTable
|
|
277
|
+
columns={[
|
|
278
|
+
{
|
|
279
|
+
name: "id",
|
|
280
|
+
type: "text",
|
|
281
|
+
description: "Unique trace identifier",
|
|
282
|
+
constraints: [
|
|
283
|
+
{ type: "nullable", value: false },
|
|
284
|
+
{ type: "primaryKey" }
|
|
285
|
+
]
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
name: "parentSpanId",
|
|
289
|
+
type: "text",
|
|
290
|
+
description: "ID of the parent span. Null if span is top level",
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
name: "name",
|
|
294
|
+
type: "text",
|
|
295
|
+
description: "Hierarchical operation name (e.g. `workflow.myWorkflow.execute`, `http.request`, `database.query`)",
|
|
296
|
+
constraints: [{ type: "nullable", value: false }],
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
name: "traceId",
|
|
300
|
+
type: "text",
|
|
301
|
+
description: "Root trace identifier that groups related spans",
|
|
302
|
+
constraints: [{ type: "nullable", value: false }]
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
name: "scope",
|
|
306
|
+
type: "text",
|
|
307
|
+
description: "Library/package/service that created the span (e.g. `@mastra/core`, `express`, `pg`)",
|
|
308
|
+
constraints: [{ type: "nullable", value: false }]
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
name: "kind",
|
|
312
|
+
type: "integer",
|
|
313
|
+
description: "`INTERNAL` (0, within process), `CLIENT` (1, outgoing calls), `SERVER` (2, incoming calls), `PRODUCER` (3, async job creation), `CONSUMER` (4, async job processing)",
|
|
314
|
+
constraints: [{ type: "nullable", value: false }]
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
name: "attributes",
|
|
318
|
+
type: "jsonb",
|
|
319
|
+
description: "User defined key-value pairs that contain span metadata",
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
name: "status",
|
|
323
|
+
type: "jsonb",
|
|
324
|
+
description: "JSON object with `code` (UNSET=0, ERROR=1, OK=2) and optional `message`. Example:",
|
|
325
|
+
example: {
|
|
326
|
+
code: 1,
|
|
327
|
+
message: "HTTP request failed with status 500"
|
|
328
|
+
}
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
name: "events",
|
|
332
|
+
type: "jsonb",
|
|
333
|
+
description: "Time-stamped events that occurred during the span",
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
name: "links",
|
|
337
|
+
type: "jsonb",
|
|
338
|
+
description: "Links to other related spans",
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
name: "other",
|
|
342
|
+
type: "text",
|
|
343
|
+
description: "Additional OpenTelemetry span fields as stringified JSON. Example:",
|
|
344
|
+
example: {
|
|
345
|
+
droppedAttributesCount: 2,
|
|
346
|
+
droppedEventsCount: 1,
|
|
347
|
+
instrumentationLibrary: "@opentelemetry/instrumentation-http"
|
|
348
|
+
}
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
name: "startTime",
|
|
352
|
+
type: "bigint",
|
|
353
|
+
description: "Nanoseconds since Unix epoch when span started",
|
|
354
|
+
constraints: [{ type: "nullable", value: false }]
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
name: "endTime",
|
|
358
|
+
type: "bigint",
|
|
359
|
+
description: "Nanoseconds since Unix epoch when span ended",
|
|
360
|
+
constraints: [{ type: "nullable", value: false }]
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
name: "createdAt",
|
|
364
|
+
type: "timestamp",
|
|
365
|
+
constraints: [{ type: "nullable", value: false }]
|
|
366
|
+
}
|
|
367
|
+
]}
|
|
368
|
+
/>
|
|
369
|
+
</Tabs.Tab>
|
|
370
|
+
</Tabs>
|
|
371
|
+
|
|
372
|
+
## Storage Providers
|
|
373
|
+
|
|
374
|
+
Mastra supports the following providers:
|
|
375
|
+
|
|
376
|
+
- For local development, check out [LibSQL Storage](../../reference/storage/libsql.mdx)
|
|
377
|
+
- For production, check out [PostgreSQL Storage](../../reference/storage/postgresql.mdx)
|
|
378
|
+
- For serverless deployments, check out [Upstash Storage](../../reference/storage/upstash.mdx)
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Voice in Mastra | Mastra Docs
|
|
3
|
+
description: Overview of voice capabilities in Mastra, including text-to-speech, speech-to-text, and real-time voice-to-voice interactions.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Voice in Mastra
|
|
7
|
+
|
|
8
|
+
Mastra's Voice system provides a unified interface for voice interactions, enabling text-to-speech (TTS), speech-to-text (STT), and real-time voice-to-voice capabilities in your applications.
|
|
9
|
+
|
|
10
|
+
## Key Features
|
|
11
|
+
|
|
12
|
+
- Standardized API across different voice providers
|
|
13
|
+
- Support for multiple voice services
|
|
14
|
+
- Voice-to-voice interactions using events for continuous audio streaming
|
|
15
|
+
- Composable voice providers for mixing TTS and STT services
|
|
16
|
+
|
|
17
|
+
## Adding Voice to Agents
|
|
18
|
+
|
|
19
|
+
To learn how to integrate voice capabilities into your agents, check out the [Adding Voice to Agents](../agents/adding-voice.mdx) documentation. This section covers how to use both single and multiple voice providers, as well as real-time interactions.
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## Example of Using a Single Voice Provider
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { OpenAIVoice } from "@mastra/voice-openai";
|
|
26
|
+
|
|
27
|
+
// Initialize OpenAI voice for TTS
|
|
28
|
+
const voice = new OpenAIVoice({
|
|
29
|
+
speechModel: {
|
|
30
|
+
name: "tts-1-hd", // Specify the TTS model
|
|
31
|
+
apiKey: process.env.OPENAI_API_KEY, // Your OpenAI API key
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// Convert text to speech
|
|
36
|
+
const audioStream = await voice.speak("Hello! How can I assist you today?", {
|
|
37
|
+
speaker: "default", // Optional: specify a speaker
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// Play the audio response
|
|
41
|
+
playAudio(audioStream);
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Example of Using Multiple Voice Providers
|
|
45
|
+
This example demonstrates how to create and use two different voice providers in Mastra: OpenAI for speech-to-text (STT) and PlayAI for text-to-speech (TTS).
|
|
46
|
+
|
|
47
|
+
Start by creating instances of the voice providers with any necessary configuration.
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
import { OpenAIVoice } from "@mastra/voice-openai";
|
|
51
|
+
import { PlayAIVoice } from "@mastra/voice-playai";
|
|
52
|
+
import { CompositeVoice } from "@mastra/core/voice";
|
|
53
|
+
|
|
54
|
+
// Initialize OpenAI voice for STT
|
|
55
|
+
const input = new OpenAIVoice({
|
|
56
|
+
listeningModel: {
|
|
57
|
+
name: "whisper-1",
|
|
58
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// Initialize PlayAI voice for TTS
|
|
63
|
+
const output = new PlayAIVoice({
|
|
64
|
+
speechModel: {
|
|
65
|
+
name: "playai-voice",
|
|
66
|
+
apiKey: process.env.PLAYAI_API_KEY,
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// Combine the providers using CompositeVoice
|
|
71
|
+
const voice = new CompositeVoice({
|
|
72
|
+
input,
|
|
73
|
+
output,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// Implement voice interactions using the combined voice provider
|
|
77
|
+
const audioStream = getMicrophoneStream(); // Assume this function gets audio input
|
|
78
|
+
const transcript = await voice.listen(audioStream);
|
|
79
|
+
|
|
80
|
+
// Log the transcribed text
|
|
81
|
+
console.log("Transcribed text:", transcript);
|
|
82
|
+
|
|
83
|
+
// Convert text to speech
|
|
84
|
+
const responseAudio = await voice.speak(`You said: ${transcript}`, {
|
|
85
|
+
speaker: "default", // Optional: specify a speaker
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// Play the audio response
|
|
89
|
+
playAudio(responseAudio);
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Real-time Capabilities
|
|
93
|
+
|
|
94
|
+
Many voice providers support real-time speech-to-speech interactions through WebSocket connections, enabling:
|
|
95
|
+
|
|
96
|
+
- Live voice conversations with AI
|
|
97
|
+
- Streaming transcription
|
|
98
|
+
- Real-time text-to-speech synthesis
|
|
99
|
+
- Tool usage during conversations
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
## Voice Configuration
|
|
103
|
+
|
|
104
|
+
Voice providers can be configured with different models and options:
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
const voice = new OpenAIVoice({
|
|
108
|
+
speechModel: {
|
|
109
|
+
name: "tts-1-hd",
|
|
110
|
+
apiKey: process.env.OPENAI_API_KEY
|
|
111
|
+
},
|
|
112
|
+
listeningModel: {
|
|
113
|
+
name: "whisper-1"
|
|
114
|
+
},
|
|
115
|
+
speaker: "alloy"
|
|
116
|
+
});
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Available Voice Providers
|
|
120
|
+
|
|
121
|
+
Mastra supports a variety of voice providers, including:
|
|
122
|
+
|
|
123
|
+
- OpenAI
|
|
124
|
+
- PlayAI
|
|
125
|
+
- Murf
|
|
126
|
+
- ElevenLabs
|
|
127
|
+
- [More](https://github.com/mastra-ai/mastra/tree/main/voice)
|
|
128
|
+
|
|
129
|
+
## More Resources
|
|
130
|
+
|
|
131
|
+
- [CompositeVoice](../../reference/voice/composite-voice.mdx)
|
|
132
|
+
- [MastraVoice](../../reference/voice/mastra-voice.mdx)
|
|
133
|
+
- [OpenAI Voice](../../reference/voice/openai.mdx)
|
|
134
|
+
- [PlayAI Voice](../../reference/voice/playai.mdx)
|
|
135
|
+
- [Voice Examples](../../examples/voice/text-to-speech.mdx)
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Speech-to-Text (STT) in Mastra | Mastra Docs
|
|
3
|
+
description: Overview of Speech-to-Text capabilities in Mastra, including configuration, usage, and integration with voice providers.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Speech-to-Text (STT)
|
|
7
|
+
|
|
8
|
+
Speech-to-Text (STT) in Mastra provides a standardized interface for converting audio input into text across multiple service providers. This section covers STT configuration and usage. Check out the [Adding Voice to Agents](../agents/adding-voice.mdx) documentation to learn how to use STT in an agent.
|
|
9
|
+
|
|
10
|
+
## Speech Configuration
|
|
11
|
+
|
|
12
|
+
To use STT in Mastra, you need to provide a `listeningModel` configuration when initializing the voice provider. This configuration includes parameters such as:
|
|
13
|
+
|
|
14
|
+
- **`name`**: The specific STT model to use.
|
|
15
|
+
- **`apiKey`**: Your API key for authentication.
|
|
16
|
+
- **Provider-specific options**: Additional options that may be required or supported by the specific voice provider.
|
|
17
|
+
|
|
18
|
+
**Note**: All of these parameters are optional. You can use the default settings provided by the voice provider, which will depend on the specific provider you are using.
|
|
19
|
+
|
|
20
|
+
### Example Configuration
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
const voice = new OpenAIVoice({
|
|
24
|
+
listeningModel: {
|
|
25
|
+
name: "whisper-1",
|
|
26
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// If using default settings the configuration can be simplified to:
|
|
31
|
+
const voice = new OpenAIVoice();
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Using the Listen Method
|
|
35
|
+
|
|
36
|
+
The primary method for STT is the `listen()` method, which converts spoken audio into text. Here's how to use it:
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
const audioStream = getMicrophoneStream(); // Assume this function gets audio input
|
|
40
|
+
const transcript = await voice.listen(audioStream, {
|
|
41
|
+
filetype: "m4a", // Optional: specify the audio file type
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**Note**: If you are using a voice-to-voice provider, such as `OpenAIRealtimeVoice`, the `listen()` method will emit a "writing" event instead of returning a transcript directly.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Text-to-Speech (TTS) in Mastra | Mastra Docs
|
|
3
|
+
description: Overview of Text-to-Speech capabilities in Mastra, including configuration, usage, and integration with voice providers.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Text-to-Speech (TTS)
|
|
7
|
+
|
|
8
|
+
Text-to-Speech (TTS) in Mastra offers a unified API for synthesizing spoken audio from text using various provider services. This section explains TTS configuration options and implementation methods. For integrating TTS capabilities with agents, refer to the [Adding Voice to Agents](../agents/adding-voice.mdx) documentation.
|
|
9
|
+
|
|
10
|
+
## Speech Configuration
|
|
11
|
+
|
|
12
|
+
To use TTS in Mastra, you need to provide a `speechModel` configuration when initializing the voice provider. This configuration includes parameters such as:
|
|
13
|
+
|
|
14
|
+
- **`name`**: The specific TTS model to use.
|
|
15
|
+
- **`apiKey`**: Your API key for authentication.
|
|
16
|
+
- **Provider-specific options**: Additional options that may be required or supported by the specific voice provider.
|
|
17
|
+
|
|
18
|
+
The **`speaker`** option is specified separately and allows you to select different voices for speech synthesis.
|
|
19
|
+
|
|
20
|
+
**Note**: All of these parameters are optional. You can use the default settings provided by the voice provider, which will depend on the specific provider you are using.
|
|
21
|
+
|
|
22
|
+
### Example Configuration
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
const voice = new OpenAIVoice({
|
|
26
|
+
speechModel: {
|
|
27
|
+
name: "tts-1-hd",
|
|
28
|
+
apiKey: process.env.OPENAI_API_KEY
|
|
29
|
+
},
|
|
30
|
+
speaker: "alloy",
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// If using default settings the configuration can be simplified to:
|
|
34
|
+
const voice = new OpenAIVoice();
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Using the Speak Method
|
|
38
|
+
|
|
39
|
+
The primary method for TTS is the `speak()` method, which converts text to speech. This method can accept options that allows you to specify the speaker and other provider-specific options. Here's how to use it:
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
const readableStream = await voice.speak("Hello, world!", {
|
|
43
|
+
speaker: "default", // Optional: specify a speaker
|
|
44
|
+
properties: {
|
|
45
|
+
speed: 1.0, // Optional: adjust speech speed
|
|
46
|
+
pitch: "default", // Optional: specify pitch if supported
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**Note**: If you are using a voice-to-voice provider, such as `OpenAIRealtimeVoice`, the `speak()` method will emit a "speaking" event instead of returning an Readable Stream.
|
|
52
|
+
|