Skip to content

[Bug] tts_with_vc / tts_with_vc_to_file fails with XTTS: multi-speaker validation ignores speaker_wav #4379

@rj25031

Description

@rj25031

Describe the bug

When using XTTS (tts_models/multilingual/multi-dataset/xtts_v2), the helper methods
tts_with_vc() and tts_with_vc_to_file() fail with:

ValueError: Model is multi-speaker but no speaker is provided.

This happens even when speaker_wav is provided, which should be sufficient for voice cloning with XTTS.

After inspecting the source, this appears to be a logic bug in how tts_with_vc internally calls tts_to_file.

To Reproduce

from TTS.api import TTS
import torch

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

tts.tts_with_vc_to_file(
text="This is a test to reproduce.",
language="en",
speaker_wav="sample.wav",
file_path="out.wav"
)

Expected behavior

ValueError: Model is multi-speaker but no speaker is provided.

Logs

Traceback (most recent call last):
  File "/home/rupesh/voice_clone/TTS/md.py", line 30, in <module>
    tts.tts_with_vc_to_file(
  File "/home/rupesh/voice_clone/TTS/TTS/api.py", line 455, in tts_with_vc_to_file
    wav = self.tts_with_vc(
  File "/home/rupesh/voice_clone/TTS/TTS/api.py", line 415, in tts_with_vc
    self.tts_to_file(
  File "/home/rupesh/voice_clone/TTS/TTS/api.py", line 332, in tts_to_file
    self._check_arguments(speaker=speaker, language=language, speaker_wav=speaker_wav, **kwargs)
  File "/home/rupesh/voice_clone/TTS/TTS/api.py", line 227, in _check_arguments
    raise ValueError("Model is multi-speaker but no `speaker` is provided.")
ValueError: Model is multi-speaker but no `speaker` is provided.

Environment

OS: Linux (Ubuntu)
Python: 3.10
TTS version: GitHub main (XTTS v2)
GPU: CUDA (also reproducible on CPU)(Nvidia RTX 3090)
torch installed using pip 
cuda version 11.8

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions