FantasyTalking Installation Guide
Requirements
Before installing FantasyTalking, ensure your development environment meets the following requirements. For operating systems, the project supports Windows, macOS, and Linux. Using a 64-bit system is recommended for optimal performance. Node.js version 14.0 or higher is required, and Python version 3.7 or higher. If using the Python backend, FFmpeg audio processing tool also needs to be installed.
For hardware, to have a smooth speech synthesis experience, a system with at least 4GB of RAM and a dual-core processor is recommended. For applications requiring real-time speech synthesis, using SSD storage is recommended to reduce I/O latency. If planning model training or custom voice development, a CUDA-capable graphics card is needed.
Installation Methods
FantasyTalking supports multiple installation methods. Developers can choose the most suitable method based on their needs and technology stack.
Using npm (Node.js)
# Install core library
npm install fantasy-talking
# Install optional components
npm install fantasy-talking-ui # Web UI components
npm install fantasy-talking-node # Node.js backend support
Using pip (Python)
# Install core library
pip install fantasy-talking
# Install optional components
pip install fantasy-talking[ui] # Web UI components
pip install fantasy-talking[all] # All optional components
Building from Source
# Clone repository
git clone https://github.com/fantasytalking/fantasy-talking.git
cd fantasy-talking
# Install Node.js dependencies
npm install
# Install Python dependencies (optional)
pip install -r requirements.txt
# Build project
npm run build
Quick Start
JavaScript/TypeScript Example
const FantasyTalking = require('fantasy-talking');
// Initialize client
const client = new FantasyTalking({
apiKey: 'your-api-key',
// Optional: specify voice style
voice: {
style: 'neutral',
language: 'en-US',
speed: 1.0,
pitch: 1.0
}
});
// Synthesize speech
async function synthesize() {
const audio = await client.speak('Hello, this is a test voice from FantasyTalking');
console.log('Speech synthesis successful');
// Save to file
const fs = require('fs');
fs.writeFileSync('output.wav', audio);
// Or play directly
client.play(audio);
}
synthesize();
Python Example
from fantasy_talking import FantasyTalking
# Initialize client
client = FantasyTalking(
api_key='your-api-key',
voice={
'style': 'neutral',
'language': 'en-US',
'speed': 1.0,
'pitch': 1.0
}
)
# Synthesize speech
audio = client.speak('Hello, this is a test voice from FantasyTalking')
# Save to file
with open('output.wav', 'wb') as f:
f.write(audio)
print('Speech synthesis successful')
Configuration Options
FantasyTalking provides rich configuration options that can be adjusted according to specific needs.
Basic Configuration
| Parameter | Type | Default | Description |
|---|---|---|---|
| apiKey | string | - | API key, required |
| apiUrl | string | Default | API server address |
| timeout | number | 30000 | Request timeout (ms) |
| retries | number | 3 | Request retry count |
Voice Configuration
| Parameter | Type | Default | Description |
|---|---|---|---|
| voice.style | string | neutral | Voice style: neutral, happy, sad, angry, excited |
| voice.language | string | en-US | Language code |
| voice.speed | number | 1.0 | Speech rate, range 0.5-2.0 |
| voice.pitch | number | 1.0 | Pitch, range 0.5-2.0 |
| voice.volume | number | 1.0 | Volume, range 0-1.0 |
Advanced Configuration
For advanced users, more parameters can be configured for finer control:
const client = new FantasyTalking({
apiKey: 'your-api-key',
// Audio output format
audio: {
format: 'wav', // wav, mp3, ogg
sampleRate: 16000, // 8000, 16000, 24000, 48000
bitDepth: 16 // 8, 16, 24
},
// Dialogue configuration
dialogue: {
enable: true,
contextWindow: 5, // Number of dialogue turns to preserve
systemPrompt: 'You are a friendly voice assistant'
},
// Streaming output
stream: {
enable: true,
chunkSize: 1024 // Chunk size for streaming output
}
});
Service Deployment
Docker Deployment
The project provides Docker images for easy deployment:
# Pull image
docker pull fantasytalking/server:latest
# Run container
docker run -d \
--name fantasy-talking \
-p 8080:8080 \
-e API_KEY=your-api-key \
-e PORT=8080 \
fantasytalking/server:latest
Self-Hosted Service
For complete control, you can deploy your own backend service:
# Clone backend code
git clone https://github.com/fantasytalking/server.git
cd server
# Configure environment variables
cp .env.example .env
# Edit .env file, fill in API key and other configurations
# Start service
npm run start
After the service starts, you can make speech synthesis requests via the RESTful API. For detailed API documentation, please refer to the official documentation.
Verifying Installation
After installation, you can verify FantasyTalking is working correctly:
# Test with command line tool
fantasy-talking --text "Test voice" --output test.wav
# Or run example
npm run example
If everything is working, you should see the voice file generated successfully. For common installation issues and solutions, please refer to the FAQ page.
