> For the complete documentation index, see [llms.txt](https://docs.clore.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.clore.ai/guides/guides_v2-hi/audio-and-voice/xtts-coqui.md).

# XTTS (Coqui)

Coqui XTTS का उपयोग करके आवाज़ क्लोनिंग के साथ प्राकृतिक भाषण उत्पन्न करें।

{% hint style="success" %}
सभी उदाहरण GPU सर्वरों पर चलाए जा सकते हैं जिन्हें द्वारा किराए पर लिया गया है [CLORE.AI मार्केटप्लेस](https://clore.ai/marketplace).
{% endhint %}

## CLORE.AI पर किराये पर लेना

1. पर जाएँ [CLORE.AI मार्केटप्लेस](https://clore.ai/marketplace)
2. GPU प्रकार, VRAM, और मूल्य के अनुसार फ़िल्टर करें
3. चुनें **ऑन-डिमांड** (निश्चित दर) या **स्पॉट** (बिड प्राइस)
4. अपना ऑर्डर कॉन्फ़िगर करें:
   * Docker इमेज चुनें
   * पोर्ट सेट करें (SSH के लिए TCP, वेब UI के लिए HTTP)
   * यदि आवश्यक हो तो एनवायरनमेंट वेरिएबल जोड़ें
   * स्टार्टअप कमांड दर्ज करें
5. भुगतान चुनें: **CLORE**, **BTC**, या **USDT/USDC**
6. ऑर्डर बनाएं और डिप्लॉयमेंट का इंतज़ार करें

### अपने सर्वर तक पहुँचें

* कनेक्शन विवरण में खोजें **मेरे ऑर्डर**
* वेब इंटरफेस: HTTP पोर्ट URL का उपयोग करें
* SSH: `ssh -p <port> root@<proxy-address>`

## XTTS क्या है?

XTTS (Coqui द्वारा) प्रदान करता है:

* उच्च गुणवत्ता पाठ-से-वॉक
* 6 सेकंड के ऑडियो से आवाज़ क्लोनिंग
* 17 भाषाएँ समर्थित
* भावनात्मक नियंत्रण
* स्ट्रीमिंग समर्थन

## आवश्यकताएँ

| मोड            | VRAM | अनुशंसित |
| -------------- | ---- | -------- |
| इनफेरेन्स      | 4GB  | RTX 3060 |
| तेज़ निष्कर्षण | 6GB  | RTX 3080 |
| स्ट्रीमिंग     | 4GB  | RTX 3060 |

## त्वरित तैनाती

**Docker इमेज:**

```
pytorch/pytorch:2.5.1-cuda12.4-cudnn9-runtime
```

**पोर्ट:**

```
22/tcp
8000/http
```

**कमांड:**

```bash
pip install TTS && \
tts-server --model_name tts_models/multilingual/multi-dataset/xtts_v2
```

## अपनी सेवा तक पहुँचना

डिप्लॉयमेंट के बाद, अपना खोजें `http_pub` URL में **मेरे ऑर्डर**:

1. जाएँ **मेरे ऑर्डर** पृष्ठ
2. अपने ऑर्डर पर क्लिक करें
3. खोजें `http_pub` URL (उदा., `abc123.clorecloud.net`)

उपयोग करें `https://YOUR_HTTP_PUB_URL` की बजाय `localhost` नीचे दिए उदाहरणों में।

## इंस्टॉलेशन

```bash
pip install TTS
```

## मूल उपयोग

### सरल TTS

```python
from TTS.api import TTS

# XTTS v2 लोड करें
tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2").to("cuda")

# स्पीच जेनरेट करें
tts.tts_to_file(
    text="Hello, this is a test of the XTTS text to speech system.",
    file_path="output.wav",
    language="en"
)
```

### वॉइस क्लोनिंग

```python
from TTS.api import TTS

tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2").to("cuda")

# संदर्भ ऑडियो से आवाज़ क्लोन करें (6+ सेकंड)
tts.tts_to_file(
    text="This is my cloned voice speaking new text.",
    file_path="cloned_output.wav",
    speaker_wav="reference_voice.wav",
    language="en"
)
```

## एकाधिक भाषाएँ

```python
from TTS.api import TTS

tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2").to("cuda")

# अंग्रेज़ी
tts.tts_to_file(
    text="Hello, how are you today?",
    file_path="english.wav",
    speaker_wav="voice.wav",
    language="en"
)

# स्पेनिश
tts.tts_to_file(
    text="Hola, ¿cómo estás hoy?",
    file_path="spanish.wav",
    speaker_wav="voice.wav",
    language="es"
)

# जर्मन
tts.tts_to_file(
    text="Hallo, wie geht es dir heute?",
    file_path="german.wav",
    speaker_wav="voice.wav",
    language="de"
)

# रूसी
tts.tts_to_file(
    text="Привет, как дела?",
    file_path="russian.wav",
    speaker_wav="voice.wav",
    language="ru"
)
```

### समर्थित भाषाएँ

| कोड   | भाषा            |
| ----- | --------------- |
| en    | अंग्रेज़ी       |
| es    | स्पेनिश         |
| fr    | फ़्रेंच         |
| de    | जर्मन           |
| it    | इतालवी          |
| pt    | पुर्तगाली       |
| pl    | पोलिश           |
| tr    | तुर्की          |
| ru    | रूसी            |
| nl    | डच              |
| cs    | चेकोस्लोवाकियाई |
| ar    | अरबी            |
| zh-cn | चीनी            |
| ja    | जापानी          |
| hu    | हंगेरियन        |
| ko    | कोरियाई         |
| hi    | हिन्दी          |

## स्ट्रीमिंग TTS

```python
from TTS.tts.configs.xtts_config import XttsConfig
from TTS.tts.models.xtts import Xtts
import torch
import sounddevice as sd

# मॉडल लोड करें
config = XttsConfig()
config.load_json("path/to/config.json")
model = Xtts.init_from_config(config)
model.load_checkpoint(config, checkpoint_dir="path/to/model")
model.cuda()

# स्पीकर एम्बेडिंग प्राप्त करें
gpt_cond_latent, speaker_embedding = model.get_conditioning_latents(
    audio_path="reference.wav"
)

# स्ट्रीम जनरेशन
chunks = model.inference_stream(
    text="This is a streaming test of the XTTS system.",
    language="en",
    gpt_cond_latent=gpt_cond_latent,
    speaker_embedding=speaker_embedding,
    stream_chunk_size=20
)

# रीयल-टाइम में चलाएँ
for chunk in chunks:
    audio = chunk.cpu().numpy()
    sd.play(audio, samplerate=24000)
    sd.wait()
```

## Gradio इंटरफ़ेस

```python
import gradio as gr
from TTS.api import TTS
import tempfile

tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2").to("cuda")

def generate_speech(text, reference_audio, language):
    with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as f:
        if reference_audio:
            tts.tts_to_file(
                text=text,
                file_path=f.name,
                speaker_wav=reference_audio,
                language=language
            )
        else:
            tts.tts_to_file(
                text=text,
                file_path=f.name,
                language=language
            )
        return f.name

demo = gr.Interface(
    fn=generate_speech,
    inputs=[
        gr.Textbox(label="Text to speak", lines=5),
        gr.Audio(type="filepath", label="Reference Voice (optional)"),
        gr.Dropdown(
            ["en", "es", "fr", "de", "it", "pt", "ru", "zh-cn", "ja"],
            value="en",
            label="Language"
        )
    ],
    outputs=gr.Audio(label="Generated Speech"),
    title="XTTS Voice Cloning"
)

demo.launch(server_name="0.0.0.0", server_port=7860)
```

## API सर्वर

```python
from fastapi import FastAPI, UploadFile, File, Form
from fastapi.responses import FileResponse
from TTS.api import TTS
import tempfile
import os

app = FastAPI()
tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2").to("cuda")

@app.post("/synthesize")
async def synthesize(
    text: str = Form(...),
    language: str = Form(default="en"),
    speaker: UploadFile = File(default=None)
):
    with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as out_file:
        if speaker:
            # अपलोड किया गया संदर्भ सहेजें
            with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as ref_file:
                ref_file.write(await speaker.read())
                ref_path = ref_file.name

            tts.tts_to_file(
                text=text,
                file_path=out_file.name,
                speaker_wav=ref_path,
                language=language
            )
            os.unlink(ref_path)
        else:
            tts.tts_to_file(
                text=text,
                file_path=out_file.name,
                language=language
            )

        return FileResponse(out_file.name, media_type="audio/wav")

# चलाएँ: uvicorn server:app --host 0.0.0.0 --port 8000
```

## बैच प्रोसेसिंग

```python
from TTS.api import TTS
import os

tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2").to("cuda")

texts = [
    "हमारे प्लेटफ़ॉर्म में आपका स्वागत है।",
    "कृपया निम्न जानकारी की समीक्षा करें।",
    "आपके ध्यान के लिए धन्यवाद।",
    "आपका दिन शुभ हो!"
]

reference_voice = "speaker.wav"
output_dir = "./audio_files"
os.makedirs(output_dir, exist_ok=True)

for i, text in enumerate(texts):
    output_path = f"{output_dir}/audio_{i:03d}.wav"

    tts.tts_to_file(
        text=text,
        file_path=output_path,
        speaker_wav=reference_voice,
        language="en"
    )

    print(f"Generated: {output_path}")
```

## वॉइस फाइन-ट्यूनिंग

बेहतर आवाज़ क्लोनिंग के लिए:

```python
from TTS.tts.configs.xtts_config import XttsConfig
from TTS.tts.models.xtts import Xtts

config = XttsConfig()
model = Xtts.init_from_config(config)

# बेहतर गुणवत्ता के लिए कई संदर्भ नमूने उपयोग करें
reference_files = [
    "sample1.wav",
    "sample2.wav",
    "sample3.wav"
]

# कई नमूनों से स्पीकर एम्बेडिंग निकालें
gpt_cond_latent, speaker_embedding = model.get_conditioning_latents(
    audio_path=reference_files
)

# औसत एम्बेडिंग के साथ जनरेट करें
output = model.inference(
    text="High quality cloned speech.",
    language="en",
    gpt_cond_latent=gpt_cond_latent,
    speaker_embedding=speaker_embedding
)
```

## ऑडियो प्रीप्रोसेसिंग

```python
import librosa
import soundfile as sf

def prepare_reference(input_path, output_path, target_sr=22050):
    # लोड और रिसैम्पल करें
    audio, sr = librosa.load(input_path, sr=target_sr)

    # मौन को ट्रिम करें
    audio, _ = librosa.effects.trim(audio, top_db=20)

    # सामान्यीकरण
    audio = librosa.util.normalize(audio)

    # सहेजें
    sf.write(output_path, audio, target_sr)

# संदर्भ ऑडियो तैयार करें
prepare_reference("raw_voice.wav", "clean_voice.wav")
```

## प्रदर्शन

| मोड        | GPU      | स्पीड               |
| ---------- | -------- | ------------------- |
| मानक       | RTX 3060 | \~0.5x वास्तविक समय |
| मानक       | RTX 4090 | \~2x वास्तविक समय   |
| स्ट्रीमिंग | RTX 3060 | \~1x वास्तविक समय   |
| स्ट्रीमिंग | RTX 4090 | \~3x वास्तविक समय   |

## गुणवत्ता सुझाव

* 6-15 सेकंड का साफ़ संदर्भ ऑडियो उपयोग करें
* संदर्भ में पृष्ठभूमि शोर से बचें
* टेक्स्ट और संदर्भ की भाषा मिलाएँ
* बेहतर परिणामों के लिए कई संदर्भ नमूने उपयोग करें

## समस्याओं का निवारण

### खराब आवाज़ गुणवत्ता

* साफ़ संदर्भ ऑडियो
* लंबा संदर्भ (10+ सेकंड)
* बोलने की शैली मिलाएँ

### भाषा उच्चारण गलत

* सही भाषा कोड सुनिश्चित करें
* देशी वक्ता का संदर्भ उपयोग करें

### धीमा जनरेशन

* GPU निष्कर्षण सक्षम करें
* स्ट्रीमिंग मोड उपयोग करें
* प्रति कॉल टेक्स्ट की लंबाई कम करें

## लागत अनुमान

सामान्य CLORE.AI मार्केटप्लेस दरें (2024 के अनुसार):

| GPU       | घंटात्मक दर | दैनिक दर | 4-घंटे सत्र |
| --------- | ----------- | -------- | ----------- |
| RTX 3060  | \~$0.03     | \~$0.70  | \~$0.12     |
| RTX 3090  | \~$0.06     | \~$1.50  | \~$0.25     |
| RTX 4090  | \~$0.10     | \~$2.30  | \~$0.40     |
| A100 40GB | \~$0.17     | \~$4.00  | \~$0.70     |
| A100 80GB | \~$0.25     | \~$6.00  | \~$1.00     |

*कीमतें प्रदाता और मांग के अनुसार बदलती हैं। जाँच करें* [*CLORE.AI मार्केटप्लेस*](https://clore.ai/marketplace) *वर्तमान दरों के लिए।*

**पैसे बचाएँ:**

* उपयोग करें **स्पॉट** लचीले वर्कलोड के लिए मार्केट (अक्सर 30-50% सस्ता)
* भुगतान करें **CLORE** टोकन के साथ
* विभिन्न प्रदाताओं के बीच कीमतों की तुलना करें

## अगले कदम

* [Bark TTS](/guides/guides_v2-hi/audio-and-voice/bark-tts.md) - भावनात्मक TTS
* [SadTalker](/guides/guides_v2-hi/talking-heads/sadtalker.md) - टॉकिंग हेड्स
* [RVC वॉयस क्लोन](/guides/guides_v2-hi/audio-and-voice/rvc-voice-clone.md) - वॉयस कन्वर्शन


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.clore.ai/guides/guides_v2-hi/audio-and-voice/xtts-coqui.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
