https://github.com/chicogong/flow-tts
OpenAI-style TTS SDK for Tencent Cloud - simple, elegant, multi-language
https://github.com/chicogong/flow-tts
golang java nodejs openai openai-compatible python sdk streaming tencent-cloud text-to-speech tts typescript voice-synthesis
Last synced: 4 months ago
JSON representation
OpenAI-style TTS SDK for Tencent Cloud - simple, elegant, multi-language
- Host: GitHub
- URL: https://github.com/chicogong/flow-tts
- Owner: chicogong
- License: mit
- Created: 2025-12-21T07:37:10.000Z (6 months ago)
- Default Branch: master
- Last Pushed: 2025-12-30T19:06:10.000Z (5 months ago)
- Last Synced: 2026-01-03T16:48:34.450Z (5 months ago)
- Topics: golang, java, nodejs, openai, openai-compatible, python, sdk, streaming, tencent-cloud, text-to-speech, tts, typescript, voice-synthesis
- Language: Java
- Homepage: https://huggingface.co/spaces/gonghaoran/flow-tts
- Size: 153 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# FlowTTS
[](https://github.com/chicogong/flow-tts/actions/workflows/node-ci.yml)
[](https://github.com/chicogong/flow-tts/actions/workflows/python-ci.yml)
[](https://github.com/chicogong/flow-tts/actions/workflows/go-ci.yml)
[](https://opensource.org/licenses/MIT)
> OpenAI-style TTS SDK for Tencent Cloud - Simple, elegant, multi-language
English | [įŽäŊ䏿](./README_CN.md)
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**.
## đŽ Try it Now
Experience FlowTTS instantly without any setup:
| Platform | Link | Description |
|----------|------|-------------|
| Hugging Face | [gonghaoran/flow-tts](https://huggingface.co/spaces/gonghaoran/flow-tts) | Free Gradio demo |
| Streamlit | [flowtts.streamlit.app](https://flowtts.streamlit.app) | Interactive demo |
| Replicate | [chicogong/flow-tts](https://replicate.com/chicogong/flow-tts) | API + Playground |
> **BYOK (Bring Your Own Key)**: You need your own Tencent Cloud credentials to use these demos.
> See [flowtts-byok](https://github.com/chicogong/flowtts-byok) for deployment guides.
## ⨠Features
- đ¯ **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
## đĻ Installation
### Node.js
```bash
npm install flow-tts
```
### Python
```bash
pip install flow-tts
```
### Go
```bash
go get github.com/chicogong/flow-tts/go
```
## đ Quick Start
### Node.js
```typescript
import { 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);
```
### Python
```python
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"])
```
### Go
```go
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)
}
```
## đ Documentation
- [Node.js SDK Documentation](./packages/node/README.md)
- [Python SDK Documentation](./packages/python/README.md)
- [Go SDK Documentation](./packages/go/README.md)
## đ¤ Voice Library
The SDK provides **380+ preset voices**:
- 77 Turbo voices (low latency)
- 303 Extended voices (high quality)
### Recommended Voices
| Voice ID | Name | Language | Features |
|---------|------|---------|----------|
| `v-female-R2s4N9qJ` | 渊æå§å§ | Chinese | Gentle, Warm |
| `v-male-Bk7vD3xP` | å¨ä¸Ĩ鏿ģ | Chinese | Mature, Steady |
| `v-female-p9Xy7Q1L` | æ¸
æ°åĨŗæįŊ | English | Clear, Professional |
## đ Streaming Support
All SDKs support real-time streaming:
**Node.js:**
```typescript
for await (const chunk of client.synthesizeStream({ text: '...' })) {
if (chunk.type === 'audio') {
console.log(`Received ${chunk.data.length} bytes`);
}
}
```
**Python:**
```python
for chunk in client.synthesize_stream({"text": "..."}):
if chunk["type"] == "audio":
print(f"Received {len(chunk['data'])} bytes")
```
**Go:**
```go
chunkChan, _ := client.SynthesizeStream(flowtts.SynthesizeOptions{Text: "..."})
for chunk := range chunkChan {
if chunk.Type == "audio" {
fmt.Printf("Received %d bytes\n", len(chunk.Data))
}
}
```
## âī¸ Configuration
All SDKs require the same credentials:
```bash
TX_SECRET_ID=your-tencent-cloud-secret-id
TX_SECRET_KEY=your-tencent-cloud-secret-key
TRTC_SDK_APP_ID=your-trtc-app-id
```
## đ§ Development
```bash
# 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 ./...
```
## đ SDK Comparison
| 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 |
## đ License
MIT License - see [LICENSE](./LICENSE) file
## đ¤ Contributing
Issues and Pull Requests are welcome!
## đŽ Links
- **Live Demo**: [Hugging Face Space](https://huggingface.co/spaces/gonghaoran/flow-tts)
- **BYOK Guide**: [flowtts-byok](https://github.com/chicogong/flowtts-byok)
- **GitHub**: [chicogong/flow-tts](https://github.com/chicogong/flow-tts)
- **npm**: [flow-tts](https://www.npmjs.com/package/flow-tts)
- **PyPI**: [flow-tts](https://pypi.org/project/flow-tts/)
- **Go Package**: [github.com/chicogong/flow-tts/go](https://pkg.go.dev/github.com/chicogong/flow-tts/go)
## đ Acknowledgments
Built on top of Tencent Cloud TRTC TTS API.