> 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-de/sprechende-kopfe/wav2lip.md).

# Wav2Lip

Präzise Lippensynchronität zu jedem Audio mit Wav2Lip auf Clore.ai-GPUs

Synchronisiere Lippen mit beliebigem Audio mit Wav2Lip.

{% hint style="success" %}
Alle Beispiele können auf GPU-Servern ausgeführt werden, die gemietet wurden über [CLORE.AI-Marktplatz](https://clore.ai/marketplace).
{% endhint %}

## Mieten auf CLORE.AI

1. Besuchen [CLORE.AI-Marktplatz](https://clore.ai/marketplace)
2. Filtern nach GPU-Typ, VRAM und Preis
3. Wähle **On-Demand** (Festpreis) oder **Spot** (Gebotspreis)
4. Konfiguriere deine Bestellung:
   * Docker-Image auswählen
   * Ports festlegen (TCP für SSH, HTTP für Web-UIs)
   * Bei Bedarf Umgebungsvariablen hinzufügen
   * Startbefehl eingeben
5. Zahlung auswählen: **CLORE**, **BTC**, oder **USDT/USDC**
6. Bestellung erstellen und auf die Bereitstellung warten

### Greife auf deinen Server zu

* Verbindungsdetails finden in **Meine Bestellungen**
* Web-Oberflächen: Verwende die HTTP-Port-URL
* SSH: `ssh -p <port> root@<proxy-address>`

## Was ist Wav2Lip?

Wav2Lip bietet:

* Präzise Lippensynchronisation für jedes Gesicht
* Funktioniert mit jedem Audio
* Video- oder Bildeingabe
* Echtzeitfähig

## Anforderungen

| Modus         | VRAM | Empfohlen |
| ------------- | ---- | --------- |
| Einfach       | 4 GB | RTX 3060  |
| Hohe Qualität | 6 GB | RTX 3080  |
| HD            | 8 GB | RTX 4080  |

## Schnell bereitstellen

**Docker-Image:**

```
pytorch/pytorch:2.11.0-cuda12.8-cudnn9-devel
```

**Ports:**

```
22/tcp
7860/http
```

**Befehl:**

```bash
cd /workspace && \
git clone https://github.com/Rudrabha/Wav2Lip.git && \
cd Wav2Lip && \
pip install -r requirements.txt && \
wget "https://huggingface.co/spaces/wav2lip/wav2lip/resolve/main/checkpoints/wav2lip_gan.pth" -P checkpoints/ && \
python app.py
```

## Auf deinen Dienst zugreifen

Nach der Bereitstellung findest du deine `http_pub` URL in **Meine Bestellungen**:

1. Gehe zu **Meine Bestellungen** Seite
2. Klicke auf deine Bestellung
3. Finde die `http_pub` URL (z. B. `abc123.clorecloud.net`)

Verwende `https://YOUR_HTTP_PUB_URL` anstelle von `localhost` in den folgenden Beispielen.

## Installation

```bash
git clone https://github.com/Rudrabha/Wav2Lip.git
cd Wav2Lip
pip install -r requirements.txt

# Vorgetrainierte Modelle herunterladen
mkdir -p checkpoints
wget "https://huggingface.co/spaces/wav2lip/wav2lip/resolve/main/checkpoints/wav2lip.pth" -P checkpoints/
wget "https://huggingface.co/spaces/wav2lip/wav2lip/resolve/main/checkpoints/wav2lip_gan.pth" -P checkpoints/
```

## Grundlegende Verwendung

### Kommandozeile

```bash
python inference.py \
    --checkpoint_path checkpoints/wav2lip_gan.pth \
    --face input_video.mp4 \
    --audio audio.wav \
    --outfile output.mp4
```

### Mit Bildeingabe

```bash
python inference.py \
    --checkpoint_path checkpoints/wav2lip_gan.pth \
    --face face_image.jpg \
    --audio speech.wav \
    --outfile talking.mp4
```

## Python-API

```python
import subprocess

def wav2lip_sync(face_path, audio_path, output_path, checkpoint="checkpoints/wav2lip_gan.pth"):
    cmd = [
        "python", "inference.py",
        "--checkpoint_path", checkpoint,
        "--face", face_path,
        "--audio", audio_path,
        "--outfile", output_path
    ]
    subprocess.run(cmd, check=True)
    return output_path

# Verwendung
result = wav2lip_sync(
    face_path="video.mp4",
    audio_path="new_audio.wav",
    output_path="synced.mp4"
)
```

## Qualitätsoptionen

### Standardqualität (schneller)

```bash
python inference.py \
    --checkpoint_path checkpoints/wav2lip.pth \
    --face input.mp4 \
    --audio audio.wav \
    --outfile output.mp4
```

### Hohe Qualität (GAN)

```bash
python inference.py \
    --checkpoint_path checkpoints/wav2lip_gan.pth \
    --face input.mp4 \
    --audio audio.wav \
    --outfile output.mp4 \
    --pads 0 10 0 0 \      # Abstand: oben rechts unten links
    --resize_factor 1
```

## Parameter

```bash
python inference.py \
    --checkpoint_path checkpoints/wav2lip_gan.pth \
    --face video.mp4 \
    --audio audio.wav \
    --outfile result.mp4 \
    --pads 0 10 0 0 \      # Abstand: oben rechts unten links
    --resize_factor 1 \    # Verkleinerungsfaktor
    --crop "0 -1 0 -1" \   # Zuschneidebereich
    --box "-1 -1 -1 -1" \  # Gesichtsbox (automatische Erkennung)
    --nosmooth            # Zeitliche Glättung deaktivieren
```

### Tipps zu Abständen

| Gesichtsposition | Empfohlene Abstände |
| ---------------- | ------------------- |
| Zentriert        | 0 10 0 0            |
| Nahaufnahme      | 0 15 0 0            |
| Weit entfernt    | 0 5 0 0             |

## Batch-Verarbeitung

```python
import os
import subprocess

def batch_wav2lip(faces_dir, audio_path, output_dir):
    os.makedirs(output_dir, exist_ok=True)

    for filename in os.listdir(faces_dir):
        if filename.endswith(('.mp4', '.jpg', '.png')):
            face_path = os.path.join(faces_dir, filename)
            output_path = os.path.join(output_dir, f"synced_{filename}")

            if filename.endswith(('.jpg', '.png')):
                output_path = output_path.rsplit('.', 1)[0] + '.mp4'

            cmd = [
                "python", "inference.py",
                "--checkpoint_path", "checkpoints/wav2lip_gan.pth",
                "--face", face_path,
                "--audio", audio_path,
                "--outfile", output_path
            ]

            try:
                subprocess.run(cmd, check=True)
                print(f"Verarbeitet: {filename}")
            except subprocess.CalledProcessError as e:
                print(f"Fehler bei der Verarbeitung von {filename}: {e}")

# Verwendung
batch_wav2lip("./faces", "speech.wav", "./outputs")
```

## Gradio-Oberfläche

```python
import gradio as gr
import subprocess
import tempfile
import os

def lip_sync(face_video, audio, quality):
    checkpoint = "checkpoints/wav2lip_gan.pth" if quality == "High (GAN)" else "checkpoints/wav2lip.pth"

    with tempfile.NamedTemporaryFile(suffix=".mp4", delete=False) as out_file:
        output_path = out_file.name

    cmd = [
        "python", "inference.py",
        "--checkpoint_path", checkpoint,
        "--face", face_video,
        "--audio", audio,
        "--outfile", output_path
    ]

    subprocess.run(cmd, check=True)
    return output_path

demo = gr.Interface(
    fn=lip_sync,
    inputs=[
        gr.Video(label="Gesichtsvideo/-bild"),
        gr.Audio(type="filepath", label="Audio"),
        gr.Radio(["Standard", "Hoch (GAN)"], value="Hoch (GAN)", label="Qualität")
    ],
    outputs=gr.Video(label="Lippensynchronisiertes Video"),
    title="Wav2Lip - Lippensynchronisation"
)

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

## API-Server

```python
from fastapi import FastAPI, UploadFile, File
from fastapi.responses import FileResponse
import tempfile
import subprocess
import os

app = FastAPI()

@app.post("/sync")
async def sync_lips(
    face: UploadFile = File(...),
    audio: UploadFile = File(...),
    quality: str = "gan"
):
    with tempfile.TemporaryDirectory() as tmpdir:
        # Uploads speichern
        face_ext = os.path.splitext(face.filename)[1]
        face_path = os.path.join(tmpdir, f"face{face_ext}")
        audio_path = os.path.join(tmpdir, "audio.wav")
        output_path = os.path.join(tmpdir, "output.mp4")

        with open(face_path, "wb") as f:
            f.write(await face.read())
        with open(audio_path, "wb") as f:
            f.write(await audio.read())

        # Wav2Lip ausführen
        checkpoint = "checkpoints/wav2lip_gan.pth" if quality == "gan" else "checkpoints/wav2lip.pth"

        cmd = [
            "python", "inference.py",
            "--checkpoint_path", checkpoint,
            "--face", face_path,
            "--audio", audio_path,
            "--outfile", output_path
        ]

        subprocess.run(cmd, check=True)

        return FileResponse(output_path, media_type="video/mp4")

# Ausführen: uvicorn server:app --host 0.0.0.0 --port 8000
```

## TTS- + Wav2Lip-Pipeline

Komplette Text-zu-Video:

```python
from TTS.api import TTS
import subprocess

def text_to_lipsync(text, face_path, output_path, language="en"):
    # Sprache erzeugen
    tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2")
    audio_path = "temp_speech.wav"
    tts.tts_to_file(text=text, file_path=audio_path, language=language)

    # Lippensynchronisation
    cmd = [
        "python", "inference.py",
        "--checkpoint_path", "checkpoints/wav2lip_gan.pth",
        "--face", face_path,
        "--audio", audio_path,
        "--outfile", output_path
    ]
    subprocess.run(cmd, check=True)

    return output_path

# Verwendung
text_to_lipsync(
    "Hallo, willkommen zu unserer Präsentation.",
    "presenter.jpg",
    "talking_presenter.mp4"
)
```

## Nachbearbeitung

### Ergebnis hochskalieren

```python
import subprocess

def upscale_video(input_path, output_path):
    cmd = [
        "python", "-m", "realesrgan",
        "--input", input_path,
        "--output", output_path,
        "--scale", "2"
    ]
    subprocess.run(cmd, check=True)
```

### Audio wieder hinzufügen

```bash

# Falls Audio verloren ging, wieder hinzufügen
ffmpeg -i synced_video.mp4 -i original_audio.wav \
    -c:v copy -c:a aac \
    -map 0:v:0 -map 1:a:0 \
    final_output.mp4
```

## Fehlerbehebung

### Gesicht nicht erkannt

* Stelle sicher, dass das Gesicht klar sichtbar ist
* Gute Beleuchtung
* Frontale Aufnahme bevorzugt
* Eingabe mit höherer Auflösung

### Schlechte Synchronisationsqualität

* wav2lip\_gan.pth verwenden
* Abstände anpassen
* Audio-Samplerate prüfen (16 kHz empfohlen)

### Ruckelige Ausgabe

* resize\_factor erhöhen
* nosmooth deaktivieren
* Videoeingabe mit höherer Qualität verwenden

## Leistung

| Eingabe           | GPU      | Verarbeitungszeit |
| ----------------- | -------- | ----------------- |
| 10-Sek.-Video     | RTX 3060 | \~30s             |
| 10-Sek.-Video     | RTX 4090 | \~15s             |
| 30-Sek.-Video     | RTX 4090 | \~45s             |
| Bild + 10 s Audio | RTX 3090 | \~20 s            |

## Vergleich mit SadTalker

| Funktion          | Wav2Lip         | SadTalker      |
| ----------------- | --------------- | -------------- |
| Lippengenauigkeit | Hervorragend    | Gut            |
| Kopfbewegung      | Keine           | Natürlich      |
| Ausdruck          | Keine           | Kontrollierbar |
| Geschwindigkeit   | Schneller       | Langsamer      |
| Am besten für     | Synchronisation | Avatare        |

## Kostenschätzung

Übliche CLORE.AI-Marktplatzpreise (Stand 2024):

| GPU       | Stundensatz | Tagessatz | 4-Stunden-Sitzung |
| --------- | ----------- | --------- | ----------------- |
| 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           |

*Die Preise variieren je nach Anbieter und Nachfrage. Prüfen Sie* [*CLORE.AI-Marktplatz*](https://clore.ai/marketplace) *für aktuelle Preise.*

**Geld sparen:**

* Nutzen Sie den **Spot** Markt für unterbrechbare Arbeit — etwa ein Drittel der Server bietet Spot-Preise unter dem On-Demand-Preis (Median ca. 13 % Rabatt), der Rest ist gleichauf
* Bezahlen Sie mit **CLORE** Tokens
* Vergleichen Sie Preise zwischen verschiedenen Anbietern

## Nächste Schritte

* [SadTalker](/guides/guides_v2-de/sprechende-kopfe/sadtalker.md) - Kopfbewegung + Lippen
* [XTTS](/guides/guides_v2-de/audio-and-stimme/xtts-coqui.md) - Sprache erzeugen
* [RVC-Sprachklon](/guides/guides_v2-de/audio-and-stimme/rvc-voice-clone.md) - Stimmumwandlung


---

# 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-de/sprechende-kopfe/wav2lip.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.
