Add fine-grained RVC index tuning and natural Ruhrpott phrasing scripts
This commit is contained in:
1 parent
4b97ae9613
commit
8da48317e4
2 files changed
+237
No files matched your search
@@ -0,0 +1,86 @@
|
||||
import os
|
||||
import sys
|
||||
import torch
|
||||
import numpy as np
|
||||
import soundfile as sf
|
||||
|
||||
BASE_DIR = r"C:\GitHub\VocoLoom"
|
||||
os.chdir(r"C:\GitHub\VocoLoom\Applio")
|
||||
sys.path.insert(0, r"C:\GitHub\VocoLoom\Applio")
|
||||
from core import run_infer_script
|
||||
|
||||
pth_path = r"C:\GitHub\VocoLoom\Applio\logs\Juergen_Seiferth\Juergen_Seiferth_300e_7800s.pth"
|
||||
index_path = r"C:\GitHub\VocoLoom\Applio\logs\Juergen_Seiferth\Juergen_Seiferth.index"
|
||||
|
||||
from f5_tts.infer.utils_infer import (
|
||||
load_vocoder,
|
||||
infer_process,
|
||||
preprocess_ref_audio_text,
|
||||
)
|
||||
from f5_tts.model import CFM, DiT
|
||||
from f5_tts.model.utils import get_tokenizer
|
||||
|
||||
device = "cuda" if torch.cuda.is_available() else "cpu"
|
||||
VOCAB_PATH = os.path.join(BASE_DIR, "models", "F5-TTS-German", "vocab.txt")
|
||||
CKPT_PATH = os.path.join(BASE_DIR, "ckpts", "Juergen_Seiferth", "model_200.pt")
|
||||
REF_AUDIO = os.path.join(BASE_DIR, "cleaned_dataset", "snippet_10_00-06-13-10_to_00-06-23-10_clean.wav")
|
||||
REF_TEXT = "Ich bin immer zufrieden. Ich muss das mal so sagen. Was nicht ganz läuft so wie ich das will, das wird so gemacht, damit das läuft. Zum Endeffekt ist passend."
|
||||
|
||||
vocab_char_map, vocab_size = get_tokenizer(VOCAB_PATH, "custom")
|
||||
mel_spec_kwargs = dict(n_fft=1024, hop_length=256, win_length=1024, n_mel_channels=100, target_sample_rate=24000, mel_spec_type="vocos")
|
||||
model_cfg = dict(dim=1024, depth=22, heads=16, ff_mult=2, text_dim=512, text_mask_padding=False, conv_layers=4, pe_attn_head=1)
|
||||
|
||||
vocoder = load_vocoder(vocoder_name="vocos", is_local=False, device=device)
|
||||
ref_audio_proc, ref_text_proc = preprocess_ref_audio_text(REF_AUDIO, REF_TEXT)
|
||||
|
||||
model = CFM(
|
||||
transformer=DiT(**model_cfg, text_num_embeds=vocab_size, mel_dim=100),
|
||||
mel_spec_kwargs=mel_spec_kwargs,
|
||||
vocab_char_map=vocab_char_map,
|
||||
)
|
||||
checkpoint = torch.load(CKPT_PATH, map_location=device, weights_only=True)
|
||||
ema_state = {k.replace("ema_model.", ""): v for k, v in checkpoint["ema_model_state_dict"].items() if k not in ["initted", "step"]}
|
||||
for key in ["mel_spec.mel_stft.mel_scale.fb", "mel_spec.mel_stft.spectrogram.window"]:
|
||||
if key in ema_state:
|
||||
del ema_state[key]
|
||||
model.load_state_dict(ema_state)
|
||||
model = model.to(device).eval()
|
||||
|
||||
part1_k = "Frag mal, ob du die Fotos vom Tobias kriegst. Wir haben keine gemacht."
|
||||
part2_k = "Aber nicht in die Gruppen rein senden! Der Kenny stellt's bloß wieder online."
|
||||
k1, sr, _ = infer_process(ref_audio_proc, ref_text_proc, part1_k, model, vocoder, mel_spec_type="vocos", nfe_step=64, cfg_strength=1.8, target_rms=0.1, speed=1.0, device=device)
|
||||
k2, _, _ = infer_process(ref_audio_proc, ref_text_proc, part2_k, model, vocoder, mel_spec_type="vocos", nfe_step=64, cfg_strength=1.8, target_rms=0.1, speed=1.0, device=device)
|
||||
silence_250ms = np.zeros(int(24000 * 0.25), dtype=np.float32)
|
||||
full_k = np.concatenate([k1, silence_250ms, k2])
|
||||
k_f5 = os.path.join(BASE_DIR, "juergen_kriegst_f5.wav")
|
||||
k_rvc = os.path.join(BASE_DIR, "juergen_kriegst_rvc_perfect.wav")
|
||||
sf.write(k_f5, full_k, sr)
|
||||
|
||||
print("Applying RVC to 'kriegst' version...")
|
||||
run_infer_script(
|
||||
pitch=0,
|
||||
index_rate=0.45,
|
||||
volume_envelope=1.0,
|
||||
protect=0.33,
|
||||
f0_method="rmvpe",
|
||||
input_path=k_f5,
|
||||
output_path=k_rvc,
|
||||
pth_path=pth_path,
|
||||
index_path=index_path,
|
||||
f0_autotune=False,
|
||||
f0_autotune_strength=1.0,
|
||||
proposed_pitch=False,
|
||||
proposed_pitch_threshold=155.0,
|
||||
export_format="WAV",
|
||||
embedder_model="contentvec",
|
||||
embedder_model_custom=None,
|
||||
formant_shifting=False,
|
||||
formant_qfrency=1.0,
|
||||
formant_timbre=1.0,
|
||||
sid=0,
|
||||
inference_engine=None,
|
||||
onnx_precision="auto",
|
||||
cleanup_mode="off",
|
||||
cleanup_strength=12
|
||||
)
|
||||
print(f"[Done] Generated: {k_rvc}")
|
||||
@@ -0,0 +1,151 @@
|
||||
import os
|
||||
import sys
|
||||
import torch
|
||||
import numpy as np
|
||||
import soundfile as sf
|
||||
|
||||
BASE_DIR = r"C:\GitHub\VocoLoom"
|
||||
os.chdir(r"C:\GitHub\VocoLoom\Applio")
|
||||
sys.path.insert(0, r"C:\GitHub\VocoLoom\Applio")
|
||||
from core import run_infer_script
|
||||
|
||||
pth_path = r"C:\GitHub\VocoLoom\Applio\logs\Juergen_Seiferth\Juergen_Seiferth_300e_7800s.pth"
|
||||
index_path = r"C:\GitHub\VocoLoom\Applio\logs\Juergen_Seiferth\Juergen_Seiferth.index"
|
||||
|
||||
# 1. Test different RVC Index strengths on the best foundation audio (juergen_fresh_chunk_stellts.wav)
|
||||
base_wav = os.path.join(BASE_DIR, "juergen_fresh_chunk_stellts.wav")
|
||||
|
||||
for idx in [0.40, 0.55, 0.70]:
|
||||
out_name = f"juergen_stellts_idx{int(idx*100)}.wav"
|
||||
out_path = os.path.join(BASE_DIR, out_name)
|
||||
print(f"Generating RVC index {idx} -> {out_name}...")
|
||||
run_infer_script(
|
||||
pitch=0,
|
||||
index_rate=idx,
|
||||
volume_envelope=1.0,
|
||||
protect=0.33,
|
||||
f0_method="rmvpe",
|
||||
input_path=base_wav,
|
||||
output_path=out_path,
|
||||
pth_path=pth_path,
|
||||
index_path=index_path,
|
||||
f0_autotune=False,
|
||||
f0_autotune_strength=1.0,
|
||||
proposed_pitch=False,
|
||||
proposed_pitch_threshold=155.0,
|
||||
export_format="WAV",
|
||||
embedder_model="contentvec",
|
||||
embedder_model_custom=None,
|
||||
formant_shifting=False,
|
||||
formant_qfrency=1.0,
|
||||
formant_timbre=1.0,
|
||||
sid=0,
|
||||
inference_engine=None,
|
||||
onnx_precision="auto",
|
||||
cleanup_mode="off",
|
||||
cleanup_strength=12
|
||||
)
|
||||
|
||||
# 2. Test slightly deeper pitch (-1 semi-tone for Jürgen's raspy chest resonance)
|
||||
print("Generating RVC pitch -1 (index 0.45)...")
|
||||
run_infer_script(
|
||||
pitch=-1,
|
||||
index_rate=0.45,
|
||||
volume_envelope=1.0,
|
||||
protect=0.33,
|
||||
f0_method="rmvpe",
|
||||
input_path=base_wav,
|
||||
output_path=os.path.join(BASE_DIR, "juergen_stellts_deeper_pitch.wav"),
|
||||
pth_path=pth_path,
|
||||
index_path=index_path,
|
||||
f0_autotune=False,
|
||||
f0_autotune_strength=1.0,
|
||||
proposed_pitch=False,
|
||||
proposed_pitch_threshold=155.0,
|
||||
export_format="WAV",
|
||||
embedder_model="contentvec",
|
||||
embedder_model_custom=None,
|
||||
formant_shifting=False,
|
||||
formant_qfrency=1.0,
|
||||
formant_timbre=1.0,
|
||||
sid=0,
|
||||
inference_engine=None,
|
||||
onnx_precision="auto",
|
||||
cleanup_mode="off",
|
||||
cleanup_strength=12
|
||||
)
|
||||
|
||||
# 3. Test natural wording with 'kriegst' generated fresh with F5 Step 200 + RVC
|
||||
print("\nGenerating 'kriegst' natural Ruhrpott wording...")
|
||||
from f5_tts.infer.utils_infer import (
|
||||
load_vocoder,
|
||||
infer_process,
|
||||
preprocess_ref_audio_text,
|
||||
)
|
||||
from f5_tts.model import CFM, DiT
|
||||
from f5_tts.model.utils import get_tokenizer
|
||||
|
||||
device = "cuda" if torch.cuda.is_available() else "cpu"
|
||||
VOCAB_PATH = os.path.join(BASE_DIR, "models", "F5-TTS-German", "vocab.txt")
|
||||
CKPT_PATH = os.path.join(BASE_DIR, "ckpts", "Juergen_Seiferth", "model_200.pt")
|
||||
REF_AUDIO = os.path.join(BASE_DIR, "cleaned_dataset", "snippet_10_00-06-13-10_to_00-06-23-10_clean.wav")
|
||||
REF_TEXT = "Ich bin immer zufrieden. Ich muss das mal so sagen. Was nicht ganz läuft so wie ich das will, das wird so gemacht, damit das läuft. Zum Endeffekt ist passend."
|
||||
|
||||
vocab_char_map, vocab_size = get_tokenizer(VOCAB_PATH, "custom")
|
||||
mel_spec_kwargs = dict(n_fft=1024, hop_length=256, win_length=1024, n_mel_channels=100, target_sample_rate=24000, mel_spec_type="vocos")
|
||||
model_cfg = dict(dim=1024, depth=22, heads=16, ff_mult=2, text_dim=512, text_mask_padding=False, conv_layers=4, pe_attn_head=1)
|
||||
|
||||
vocoder = load_vocoder(vocoder_name="vocos", is_local=False, device=device)
|
||||
ref_audio_proc, ref_text_proc = preprocess_ref_audio_text(REF_AUDIO, REF_TEXT)
|
||||
|
||||
model = CFM(
|
||||
transformer=DiT(**model_cfg, text_num_embeds=vocab_size, mel_dim=100),
|
||||
mel_spec_kwargs=mel_spec_kwargs,
|
||||
vocab_char_map=vocab_char_map,
|
||||
)
|
||||
checkpoint = torch.load(CKPT_PATH, map_location=device, weights_only=True)
|
||||
ema_state = {k.replace("ema_model.", ""): v for k, v in checkpoint["ema_model_state_dict"].items() if k not in ["initted", "step"]}
|
||||
for key in ["mel_spec.mel_stft.mel_scale.fb", "mel_spec.mel_stft.spectrogram.window"]:
|
||||
if key in ema_state:
|
||||
del ema_state[key]
|
||||
model.load_state_dict(ema_state)
|
||||
model = model.to(device).eval()
|
||||
|
||||
part1_k = "Frag mal, ob du die Fotos vom Tobias kriegst. Wir haben keine gemacht."
|
||||
part2_k = "Aber nicht in die Gruppen rein senden! Der Kenny stellt's bloß wieder online."
|
||||
k1, sr, _ = infer_process(ref_audio_proc, ref_text_proc, part1_k, model, vocoder, mel_spec_type="vocos", nfe_step=64, cfg_strength=1.8, target_rms=0.1, speed=1.0, device=device)
|
||||
k2, _, _ = infer_process(ref_audio_proc, ref_text_proc, part2_k, model, vocoder, mel_spec_type="vocos", nfe_step=64, cfg_strength=1.8, target_rms=0.1, speed=1.0, device=device)
|
||||
silence_250ms = np.zeros(int(24000 * 0.25), dtype=np.float32)
|
||||
full_k = np.concatenate([k1, silence_250ms, k2])
|
||||
k_f5 = os.path.join(BASE_DIR, "juergen_kriegst_f5.wav")
|
||||
k_rvc = os.path.join(BASE_DIR, "juergen_kriegst_rvc_perfect.wav")
|
||||
sf.write(k_f5, full_k, sr)
|
||||
|
||||
run_infer_script(
|
||||
pitch=0,
|
||||
index_rate=0.45,
|
||||
volume_envelope=1.0,
|
||||
protect=0.33,
|
||||
f0_method="rmvpe",
|
||||
input_path=k_f5,
|
||||
output_path=k_rvc,
|
||||
pth_path=pth_path,
|
||||
index_path=index_path,
|
||||
f0_autotune=False,
|
||||
f0_autotune_strength=1.0,
|
||||
proposed_pitch=False,
|
||||
proposed_pitch_threshold=155.0,
|
||||
export_format="WAV",
|
||||
embedder_model="contentvec",
|
||||
embedder_model_custom=None,
|
||||
formant_shifting=False,
|
||||
formant_qfrency=1.0,
|
||||
formant_timbre=1.0,
|
||||
sid=0,
|
||||
inference_engine=None,
|
||||
onnx_precision="auto",
|
||||
cleanup_mode="off",
|
||||
cleanup_strength=12
|
||||
)
|
||||
|
||||
print(f"[Done] All variants generated! Final: {k_rvc}")
|
||||
Reference in new issue
Block a user