دليل تثبيت FantasyTalking

المتطلبات

قبل تثبيت FantasyTalking، تأكّد من أن بيئة التطوير لديك تستوفي المتطلبات التالية. بالنسبة لأنظمة التشغيل، يدعم المشروع Windows وmacOS وLinux. ويُوصى باستخدام نظام 64-بت للحصول على أفضل أداء. يُتطلّب إصدار Node.js 14.0 أو أعلى، وإصدار Python 3.7 أو أعلى. وإذا كنت تستخدم الواجهة الخلفية بـ Python، فيجب أيضًا تثبيت أداة معالجة الصوت FFmpeg.

وبالنسبة للعتاد، للحصول على تجربة تخليق كلام سلسة، يُوصى بنظام يمتلك ذاكرة وصول عشوائي لا تقل عن 4GB ومعالج ثنائي النواة. وبالنسبة للتطبيقات التي تتطلّب تخليق كلام في الزمن الحقيقي، يُوصى باستخدام تخزين SSD لتقليل زمن تأخير الإدخال/الإخراج. وإذا كنت تخطّط لتدريب النماذج أو تطوير أصوات مخصّصة، فستحتاج إلى بطاقة رسومات تدعم CUDA.

طرق التثبيت

يدعم FantasyTalking طرق تثبيت متعددة. ويمكن للمطوّرين اختيار الطريقة الأنسب بناءً على احتياجاتهم ومجموعتهم التقنية.

باستخدام 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

باستخدام 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

البناء من المصدر

# 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

البدء السريع

مثال JavaScript/TypeScript

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

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')

خيارات التكوين

يوفّر FantasyTalking خيارات تكوين غنية يمكن ضبطها وفقًا للاحتياجات المحدّدة.

التكوين الأساسي

المعاملالنوعالقيمة الافتراضيةالوصف
apiKeystring-مفتاح API، مطلوب
apiUrlstringDefaultعنوان خادم API
timeoutnumber30000مهلة الطلب (بالميلي ثانية)
retriesnumber3عدد مرات إعادة محاولة الطلب

تكوين الصوت

المعاملالنوعالقيمة الافتراضيةالوصف
voice.stylestringneutralنمط الصوت: neutral، happy، sad، angry، excited
voice.languagestringen-USرمز اللغة
voice.speednumber1.0معدّل سرعة الكلام، النطاق 0.5-2.0
voice.pitchnumber1.0النغمة، النطاق 0.5-2.0
voice.volumenumber1.0مستوى الصوت، النطاق 0-1.0

التكوين المتقدّم

بالنسبة للمستخدمين المتقدّمين، يمكن تكوين مزيد من المعاملات للتحكم الأدق:

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
  }
});

نشر الخدمة

النشر عبر Docker

يوفّر المشروع صور Docker لسهولة النشر:

# 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

خدمة مستضافة ذاتيًا

للتحكم الكامل، يمكنك نشر خدمة الواجهة الخلفية الخاصة بك:

# 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

بعد تشغيل الخدمة، يمكنك إرسال طلبات تخليق الكلام عبر واجهة RESTful API. وبالنسبة لتوثيق API التفصيلي، يُرجى الرجوع إلى التوثيق الرسمي.

التحقق من التثبيت

بعد التثبيت، يمكنك التحقق من أن FantasyTalking يعمل بشكل صحيح:

# Test with command line tool
fantasy-talking --text "Test voice" --output test.wav

# Or run example
npm run example

إذا كان كل شيء يعمل، فينبغي أن ترى أنه تم توليد ملف الصوت بنجاح. وبالنسبة لمشكلات التثبيت الشائعة وحلولها، يُرجى الرجوع إلى صفحة الأسئلة الشائعة.