Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: deprecate @mastra/speech-openai for @mastra/voice-openai #1989

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/thin-worlds-tie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@mastra/speech-openai': minor
'@mastra/voice-openai': minor
---

Deprecate @mastra/speech-openai for @mastra/voice-openai
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@ openapi-ts-error*
.secrets
# Local Netlify folder
.netlify
.npmrc
.npmrc

# Test output directories
voice/**/test-output*/
35 changes: 30 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ packages:
- "vector-stores/*"
- "stores/*"
- "speech/*"
- "voice/*"
- "client-sdks/*"
- "!packages/cli/admin"
- "integration-generator/*"
Expand Down
66 changes: 12 additions & 54 deletions speech/openai/README.md
Original file line number Diff line number Diff line change
@@ -1,67 +1,25 @@
# @mastra/speech-openai
# @mastra/speech-openai (DEPRECATED)

OpenAI Speech integration for Mastra, providing Text-to-Speech (TTS) capabilities using OpenAI's advanced speech models.
⚠️ **This package is deprecated.** Please use [@mastra/voice-openai](https://github.com/mastra-ai/mastra/tree/main/voice/openai) instead.

## Installation
## Migration

```bash
npm install @mastra/speech-openai
```

## Configuration
The new package `@mastra/voice-openai` provides both Text-to-Speech and Speech-to-Text capabilities. To migrate:

The module requires the following environment variable:
1. Install the new package:

```bash
OPENAI_API_KEY=your_api_key
npm uninstall @mastra/speech-openai
npm install @mastra/voice-openai
```

## Usage
2. Update your imports:

```typescript
// Old
import { OpenAITTS } from '@mastra/speech-openai';

// Initialize with configuration
const tts = new OpenAITTS({
model: {
name: 'alloy', // Default voice
apiKey: 'your-api-key', // Optional, can use OPENAI_API_KEY env var
},
});

// List available voices
const voices = await tts.voices();

// Generate speech
const result = await tts.generate({
voice: 'alloy',
text: 'Hello from Mastra!',
});

// Stream speech
const stream = await tts.stream({
voice: 'alloy',
text: 'Hello from Mastra!',
});
// New
import { OpenAIVoice } from '@mastra/voice-openai';
```

## Features

- High-quality Text-to-Speech synthesis
- Multiple voice options
- Streaming support
- Natural and expressive speech output
- Fast generation times

## Voice Options

OpenAI provides several high-quality voices:

- alloy (Neutral)
- echo (Male)
- fable (Male)
- onyx (Male)
- nova (Female)
- shimmer (Female)

View the complete list in the `voices.ts` file or [OpenAI's documentation](https://platform.openai.com/docs/guides/text-to-speech).
For detailed migration instructions and new features, please refer to the [@mastra/voice-openai documentation](https://github.com/mastra-ai/mastra/tree/main/voice/openai).
8 changes: 3 additions & 5 deletions speech/openai/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@mastra/speech-openai",
"version": "0.1.3-alpha.0",
"description": "Mastra OpenAI speech integration",
"description": "Mastra OpenAI speech integration (deprecated, please use @mastra/voice-openai instead)",
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand All @@ -16,8 +16,7 @@
},
"scripts": {
"build": "tsup src/index.ts --format esm --experimental-dts --clean --treeshake",
"build:watch": "pnpm build --watch",
"test": "vitest run"
"test": "echo \"deprecated\""
},
"dependencies": {
"@mastra/core": "workspace:^",
Expand All @@ -28,7 +27,6 @@
"@microsoft/api-extractor": "^7.49.2",
"@types/node": "^22.13.1",
"tsup": "^8.0.1",
"typescript": "^5.7.3",
"vitest": "^2.1.8"
"typescript": "^5.7.3"
}
}
114 changes: 0 additions & 114 deletions speech/openai/src/index.test.ts

This file was deleted.

4 changes: 4 additions & 0 deletions speech/openai/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ interface OpenAITTSConfig {
apiKey?: string;
}

throw new Error(
'@mastra/speech-openai is deprecated. Please use @mastra/voice-openai instead, which provides both Text-to-Speech and Speech-to-Text capabilities.',
);

export class OpenAITTS extends MastraTTS {
client: OpenAI;
constructor({ model }: { model: OpenAITTSConfig }) {
Expand Down
8 changes: 8 additions & 0 deletions voice/openai/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# @mastra/voice-openai

## 0.1.0

### Changes

- `@mastra/speech-openai` is now deprecated. Please use `@mastra/voice-openai` instead.
- This package provides both Text-to-Speech (TTS) and Speech-to-Text (STT) capabilities through OpenAI's API.
Loading