OpenAI-style TTS SDK for Tencent Cloud - Simple, elegant, multi-language
English | ็ฎไฝไธญๆ
FlowTTS is a lightweight Text-to-Speech SDK that wraps Tencent Cloud's TRTC TTS API with an OpenAI-compatible interface. Available in Node.js, Python, Go, and Java.
Experience FlowTTS instantly without any setup:
| Platform | Link | Description |
|---|---|---|
| Hugging Face | gonghaoran/flow-tts | Free Gradio demo |
| Streamlit | flowtts.streamlit.app | Interactive demo |
| Replicate | chicogong/flow-tts | API + Playground |
BYOK (Bring Your Own Key): You need your own Tencent Cloud credentials to use these demos. See flowtts-byok for deployment guides.
- ๐ฏ OpenAI-Compatible API - Drop-in replacement for OpenAI TTS
- ๐ Multi-Language SDKs - Node.js, Python, and Go implementations
- โก Zero Dependencies - Uses only built-in libraries
- ๐ท Type-Safe - Full TypeScript, Python type hints, and Go static typing
- ๐ Streaming Support - Real-time audio streaming
- ๐ค Rich Voice Library - 380+ preset voices in multiple languages
- ๐ Auto Language Detection - Automatically detects text language
npm install flow-ttspip install flow-ttsgo get github.com/chicogong/flow-tts/goimport { FlowTTS } from 'flow-tts';
const client = new FlowTTS({
secretId: process.env.TX_SECRET_ID!,
secretKey: process.env.TX_SECRET_KEY!,
sdkAppId: parseInt(process.env.TRTC_SDK_APP_ID!)
});
// OpenAI-compatible API
const response = await client.audio.speech.create({
text: 'Hello, world!',
voice: 'v-female-R2s4N9qJ'
});
await fs.writeFile('output.wav', response.audio);from flow_tts import FlowTTS
client = FlowTTS({
"secret_id": "your-secret-id",
"secret_key": "your-secret-key",
"sdk_app_id": 1400000000
})
# Synthesize speech
response = client.synthesize({
"text": "ไฝ ๅฅฝ๏ผไธ็๏ผ",
"voice": "v-female-R2s4N9qJ",
"format": "wav"
})
# Save to file
with open("output.wav", "wb") as f:
f.write(response["audio"])package main
import (
"os"
flowtts "github.com/chicogong/flow-tts/go"
)
func main() {
client, _ := flowtts.NewClient(flowtts.Config{
SecretID: os.Getenv("TX_SECRET_ID"),
SecretKey: os.Getenv("TX_SECRET_KEY"),
SdkAppID: 1400000000,
})
response, _ := client.Synthesize(flowtts.SynthesizeOptions{
Text: "ไฝ ๅฅฝ๏ผไธ็๏ผ",
Voice: "v-female-R2s4N9qJ",
Format: flowtts.AudioFormatWAV,
})
os.WriteFile("output.wav", response.Audio, 0644)
}The SDK provides 380+ preset voices:
- 77 Turbo voices (low latency)
- 303 Extended voices (high quality)
| Voice ID | Name | Language | Features |
|---|---|---|---|
v-female-R2s4N9qJ |
ๆธฉๆๅงๅง | Chinese | Gentle, Warm |
v-male-Bk7vD3xP |
ๅจไธฅ้ธๆป | Chinese | Mature, Steady |
v-female-p9Xy7Q1L |
ๆธ ๆฐๅฅณๆ็ฝ | English | Clear, Professional |
All SDKs support real-time streaming:
Node.js:
for await (const chunk of client.synthesizeStream({ text: '...' })) {
if (chunk.type === 'audio') {
console.log(`Received ${chunk.data.length} bytes`);
}
}Python:
for chunk in client.synthesize_stream({"text": "..."}):
if chunk["type"] == "audio":
print(f"Received {len(chunk['data'])} bytes")Go:
chunkChan, _ := client.SynthesizeStream(flowtts.SynthesizeOptions{Text: "..."})
for chunk := range chunkChan {
if chunk.Type == "audio" {
fmt.Printf("Received %d bytes\n", len(chunk.Data))
}
}All SDKs require the same credentials:
TX_SECRET_ID=your-tencent-cloud-secret-id
TX_SECRET_KEY=your-tencent-cloud-secret-key
TRTC_SDK_APP_ID=your-trtc-app-id# Install dependencies (Node.js)
pnpm install
# Build Node.js SDK
pnpm --filter flow-tts build
# Test Python SDK
cd packages/python && pytest
# Test Go SDK
cd packages/go && go test ./...| Feature | Node.js | Python | Go |
|---|---|---|---|
| Zero Dependencies | โ | โ | โ |
| Type Safety | TypeScript | Type Hints | Static Types |
| Streaming | โ | โ | โ |
| Voice Library | 380+ | 380+ | 380+ |
| OpenAI Compatible | โ | โ | โ |
| Package Manager | npm | PyPI | go get |
MIT License - see LICENSE file
Issues and Pull Requests are welcome!
- Live Demo: Hugging Face Space
- BYOK Guide: flowtts-byok
- GitHub: chicogong/flow-tts
- npm: flow-tts
- PyPI: flow-tts
- Go Package: github.com/chicogong/flow-tts/go
Built on top of Tencent Cloud TRTC TTS API.