
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
🌏 This README is in English. 点击查看中文文档 (中文说明)
UNITTS is a unified Text-to-Speech (TTS) library written in TypeScript, providing a unified API interface to support multiple TTS service providers.
npm install unitts
# or
pnpm add unitts
# or
yarn add unitts
import { TTSRelay } from 'unitts';
import { MinimaxProviderAdapter } from 'unitts/adapters';
// Create TTS relay instance
const ttsRelay = new TTSRelay();
// Register Minimax adapter
const minimaxAdapter = new MinimaxProviderAdapter('your-api-key', 'your-group-id');
ttsRelay.registerAdapter('minimax', minimaxAdapter);
// Text-to-speech
const result = await ttsRelay.synthesize('minimax', {
text: 'Hello, welcome to UNITTS!',
voice: 'female-tianmei',
model: 'speech-02-hd',
format: 'mp3',
});
console.log('Audio ID:', result.id);
console.log('Audio Data:', result.data); // Base64 encoded audio data
Currently supports the following TTS providers:
| Provider | Status | Description |
|---|---|---|
| Minimax | ✅ Ready | Minimax TTS service |
| Tencent | ✅ Ready | Tencent Cloud TTS service |
| Elevenlabs | ✅ Ready | Elevenlabs TTS service |
| OpenAI | 🚧 WIP | GPT series TTS service |
| Anthropic | 🚧 WIP | Claude TTS service |
| Google Gemini | 🚧 WIP | Gemini TTS service |
| Lovo.ai | 🚧 WIP |
import { TTSRelay } from 'unitts';
import { MinimaxProviderAdapter } from 'unitts/adapters';
const ttsRelay = new TTSRelay();
const minimaxAdapter = new MinimaxProviderAdapter('your-api-key', 'your-group-id');
ttsRelay.registerAdapter('minimax', minimaxAdapter);
// Streaming synthesis
const stream = ttsRelay.synthesizeStream('minimax', {
text: 'This is a streaming TTS synthesis example',
voice: 'male-qn-qingse',
model: 'speech-02-hd',
format: 'mp3',
stream: true,
});
for await (const chunk of stream) {
console.log('Audio chunk:', chunk.id, chunk.data.length);
if (chunk.final) {
console.log('Synthesis complete!');
break;
}
}
// Incremental synthesis - suitable for real-time text streams
async function* textGenerator() {
const sentences = ['Hello,', 'welcome to', 'UNITTS!'];
for (const sentence of sentences) {
yield sentence;
await new Promise((resolve) => setTimeout(resolve, 1000));
}
}
const stream = ttsRelay.synthesizeIncremental('minimax', textGenerator(), {
voice: 'female-tianmei',
model: 'speech-02-hd',
format: 'mp3',
});
for await (const chunk of stream) {
console.log('Incremental audio chunk:', chunk.id);
}
import { LoggingMiddleware, TimingMiddleware } from 'unitts/middleware';
// Add logging middleware
ttsRelay.use(new LoggingMiddleware());
// Add timing middleware
ttsRelay.use(new TimingMiddleware());
// All TTS calls will go through middleware
const result = await ttsRelay.synthesize('minimax', {
text: 'Test middleware feature',
voice: 'female-tianmei',
});
// Use Minimax-specific parameters
const result = await ttsRelay.synthesize('minimax', {
text: 'Test provider-specific parameters',
voice: 'female-tianmei',
format: 'mp3',
extra: {
// Minimax-specific parameters
speed: 1.2,
vol: 0.8,
pitch: 0,
timber_weights: [{ voice_id: 'female-tianmei', weight: 1 }],
},
});
The main TTS relay class, providing a unified API interface.
registerAdapter(provider, adapter) - Register a TTS provider adapteruse(middleware) - Add middlewaresynthesize(provider, params, options?) - Text-to-speechsynthesizeStream(provider, params, options?) - Streaming text-to-speechsynthesizeIncremental(provider, textStream, params, options?) - Incremental text-to-speechlistProviders() - List registered providersinterface UnifiedTTSParams {
text: string; // Text to synthesize
model?: string; // Model name
voice?: string; // Voice ID
pitch?: number; // Pitch (-20 to 20)
emotion?: string; // Emotion
rate?: number; // Speed (0.5 to 2.0)
volume?: number; // Volume (0 to 1)
format?: string; // Audio format (mp3, wav, pcm, etc.)
sampleRate?: number; // Sample rate
stream?: boolean; // Whether to output as stream
extra?: any; // Provider-specific parameters
}
interface UnifiedTTSAudio {
id: string; // Audio ID
data: string; // Base64 encoded audio data
model?: string; // Model used
object: 'tts.audio'; // Object type
metadata?: Record<string, any>; // Metadata
final: boolean; // Is this the final chunk
originalResponse?: any; // Original response
}
UNITTS uses the adapter pattern, making it easy to add new TTS providers:
src/clients/src/adapters/ and implement the IProviderAdapter interfacesrc/types/unified.tsindex.ts fileFor detailed development guide, see Development Docs.
# Run all tests
pnpm test
# Run tests and watch for file changes
pnpm test:watch
# Run a single test
pnpm test:run
# Build the project
pnpm build
# Build in watch mode
pnpm build:watch
# Clean build files
pnpm clean
See more usage examples in the examples directory:
Contributions are welcome! Please follow these steps:
git checkout -b feature/AmazingFeature)git commit -m 'Add some AmazingFeature')git push origin feature/AmazingFeature)This project is open-sourced under the MIT License.
Thanks to all the developers who contributed to this project!
If you find this project useful, please give it a ⭐!
FAQs
The TypeScript library for unified TTS client
The npm package unitts receives a total of 0 weekly downloads. As such, unitts popularity was classified as not popular.
We found that unitts demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.