xtts-sdk
v1.1.1
Published
Advanced Text-to-Speech SDK with streaming capabilities
Maintainers
Readme
XTTS SDK
Advanced Text-to-Speech SDK with streaming capabilities and high-quality audio synthesis.
Features
- 🎙️ High-quality text-to-speech synthesis
- 🌊 Real-time audio streaming
- 🎵 Multiple audio format support (MP3, WAV, PCM)
- 🔊 Direct audio playback
- ⚡ Async/await API
- 🎛️ Customizable voice settings (speed, volume, pitch)
- 📦 Lightweight and easy to use
Installation
npm install
npm run buildQuick Start
const { XTTS } = require('xtts-sdk');
async function main() {
const tts = new XTTS();
await tts.initialize();
await tts.synthesizeToFile('Hello, world!', 'output.mp3');
await tts.close();
}
main();API Reference
Constructor
new XTTS(options)Options:
voiceSettings: Voice configurationspeed: Speech speed (default: 1.0)vol: Volume (default: 1.0)pitch: Pitch adjustment (default: 0)englishNormalization: Enable English text normalization
audioSettings: Audio format configurationsampleRate: Sample rate in Hz (default: 32000)bitrate: Bitrate (default: 128000)format: Audio format - 'mp3', 'wav', or 'pcm' (default: 'mp3')channel: Number of channels (default: 1)
Methods
initialize()
Connects to the TTS service and starts a synthesis task.
await tts.initialize();synthesizeToFile(text, outputPath)
Synthesizes text and saves to a file.
await tts.synthesizeToFile('Hello!', 'output.mp3');synthesizeToStream(text, onChunk)
Synthesizes text with streaming callback.
await tts.synthesizeToStream('Hello!', (chunk) => {
console.log(`Received ${chunk.length} bytes`);
});synthesizeAndPlay(text, format, sampleRate)
Synthesizes and plays audio (requires ffplay).
await tts.synthesizeAndPlay('Hello!');close()
Closes the connection and cleans up resources.
await tts.close();Events
connected: Fired when connected to the servicetaskStarted: Fired when synthesis task startsaudioChunk: Fired for each audio chunk receivedcomplete: Fired when synthesis is completeerror: Fired on errorsdisconnected: Fired when disconnected
tts.on('audioChunk', (chunk) => {
console.log('Received chunk:', chunk.length);
});Examples
See the examples/ directory for complete examples:
basic-usage.js: Simple synthesis examplesadvanced-usage.js: Custom settings and event handling
Requirements
- Node.js 14+
- FFplay (optional, for audio playback)
Building
# Install dependencies
npm install
# Build TypeScript and apply heavy obfuscation
npm run build
# Verify protection (checks for exposed secrets)
npm run verify
# Clean build
npm run cleanSecurity
This SDK implement :
- ✅ Multi-layer encryption of all configuration
- ✅ 20+ obfuscation techniques applied during build
- ✅ Anti-debugging protection with runtime checks
- ✅ Self-defending code that breaks if tampered
- ✅ No plain-text secrets in compiled output
See SECURITY.md for detailed protection information.
Important: Only distribute the dist/ folder. Never expose source code (src/).
Protection Verification
After building, verify that no sensitive information is exposed:
npm run verifyThis will scan the compiled code for any plain-text secrets or identifiable information.
License
MIT
