-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic-usage.ts
More file actions
36 lines (30 loc) · 1.05 KB
/
Copy pathbasic-usage.ts
File metadata and controls
36 lines (30 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { TTSRelay } from '../src/ttsRelay';
import { MinimaxProviderAdapter } from '../src/adapters/minimax/providerAdapter';
import { LoggingMiddleware } from '../src/middleware/logging';
async function basicUsageExample() {
// 创建TTS中继实例
const ttsRelay = new TTSRelay();
// 注册Minimax适配器
const minimaxAdapter = new MinimaxProviderAdapter('your-api-key', 'your-group-id');
ttsRelay.registerAdapter('minimax', minimaxAdapter);
// 注册日志中间件
const loggingMiddleware = new LoggingMiddleware();
ttsRelay.use(loggingMiddleware);
try {
// 基本文本合成
const result = await ttsRelay.synthesize('minimax', {
text: '你好,欢迎使用统一TTS服务!',
voice: 'female-tianmei',
model: 'speech-02-hd',
format: 'mp3',
});
console.log('合成成功,音频ID:', result.id);
console.log('音频数据长度:', result.data.length);
} catch (error) {
console.error('TTS合成失败:', error);
}
}
// 运行示例
if (require.main === module) {
basicUsageExample();
}