Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add kNN-VC #256

Merged
merged 10 commits into from
Jan 15, 2025
Merged

Add kNN-VC #256

merged 10 commits into from
Jan 15, 2025

Conversation

eginhard
Copy link
Member

@eginhard eginhard commented Jan 14, 2025

New voice conversion model

Usage

from TTS.api import TTS

knnvc = TTS("voice_conversion_models/multilingual/multi-dataset/knnvc")
knnvc.voice_conversion_to_file("source.wav", ["target1.wav", "target2.wav", ...], "output.wav")

By default the prematched vocoder is used. For the non-prematched version:

knnvc = TTS(
    "voice_conversion_models/multilingual/multi-dataset/knnvc", 
    vocoder_name="vocoder_models/en/librispeech100/wavlm-hifigan"
)

CLI:

tts --model_name voice_conversion_models/multilingual/multi-dataset/knnvc \
    --source_wav source.wav \
    --target_wav target1.wav target2.wav ...

Internals

The vocoder models are the same as the original ones, but the model names and configs were modified with the following code to be compatible with Coqui and republished in https://github.com/idiap/coqui-ai-TTS/releases/tag/v0.25.2_models:

import torch
from TTS.vocoder.configs.hifigan_config import HifiganConfig

m = torch.load("prematch_g_02500000.pt", map_location="cpu")
m["model_disc"] = None
m["model"] = m.pop("generator")
torch.save(m, "model.pth")

hifigan_config = HifiganConfig()
hifigan_config["audio"]["sample_rate"] = 16000
hifigan_config["generator_model_params"]["inference_padding"] = 0
hifigan_config["generator_model_params"]["pre_linear"] = 1024
hifigan_config["generator_model_params"]["in_channels"] = 512
hifigan_config["generator_model_params"]["upsample_factors"] = [10, 8, 2, 2]
hifigan_config["generator_model_params"]["upsample_kernel_sizes"] = [20, 16, 4, 4]
hifigan_config.save_json("config.json")

@eginhard eginhard marked this pull request as ready for review January 15, 2025 14:19
@eginhard eginhard merged commit 205eed3 into dev Jan 15, 2025
@eginhard eginhard deleted the knnvc branch January 15, 2025 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants