152 lines
5.8 KiB
Python
152 lines
5.8 KiB
Python
import os
|
||
import sys
|
||
import gradio as gr
|
||
|
||
applio_dir = r"C:\GitHub\VocoLoom\Applio"
|
||
sys.path.insert(0, applio_dir)
|
||
os.chdir(applio_dir)
|
||
|
||
from core import run_tts_script, run_infer_script
|
||
|
||
MODEL_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"
|
||
OUTPUT_DIR = r"C:\GitHub\VocoLoom"
|
||
|
||
def tts_generate(text, mode, speed_boost):
|
||
if not text.strip():
|
||
return None, "Bitte gib einen Text ein."
|
||
|
||
rate = 12 if mode == "platz" else 5
|
||
if speed_boost:
|
||
rate += 10
|
||
|
||
base_voice = "de-DE-KillianNeural" if mode == "platz" else "de-DE-ConradNeural"
|
||
out_tts = os.path.join(OUTPUT_DIR, "temp_web_tts.wav")
|
||
out_rvc = os.path.join(OUTPUT_DIR, "temp_web_juergen.wav")
|
||
|
||
run_tts_script(
|
||
tts_file="",
|
||
tts_text=text,
|
||
tts_voice=base_voice,
|
||
tts_rate=rate,
|
||
pitch=0,
|
||
index_rate=0.75,
|
||
volume_envelope=1.0,
|
||
protect=0.33,
|
||
f0_method="rmvpe",
|
||
output_tts_path=out_tts,
|
||
output_rvc_path=out_rvc,
|
||
pth_path=MODEL_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,
|
||
sid=0,
|
||
formant_shifting=False,
|
||
formant_qfrency=1.0,
|
||
formant_timbre=1.0,
|
||
cleanup_mode="off",
|
||
cleanup_strength=12,
|
||
)
|
||
|
||
return out_rvc, f"Erfolgreich generiert ({mode.upper()}, +{rate}% Tempo)"
|
||
|
||
def vc_convert(audio_path):
|
||
if not audio_path:
|
||
return None, "Bitte nimm Audio auf oder lade eine Datei hoch."
|
||
|
||
out_rvc = os.path.join(OUTPUT_DIR, "temp_web_vc_juergen.wav")
|
||
run_infer_script(
|
||
pitch=0,
|
||
index_rate=0.75,
|
||
volume_envelope=1.0,
|
||
protect=0.33,
|
||
f0_method="rmvpe",
|
||
input_path=audio_path,
|
||
output_path=out_rvc,
|
||
pth_path=MODEL_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,
|
||
)
|
||
return out_rvc, "Stimme erfolgreich in Jürgen Seiferth umgewandelt!"
|
||
|
||
with gr.Blocks(title="VocoLoom - Jürgen Seiferth Voice Clone") as demo:
|
||
gr.Markdown("# 🎡 VocoLoom: Jürgen Seiferth (1995 Original)")
|
||
gr.Markdown("*Breakdance-Schausteller-Stimme geklont aus MDR 'Die Welt ist unser Feld' (300 Epochen RVC + FAISS Index)*")
|
||
|
||
with gr.Tab("✍️ Text-to-Speech (Schreiben -> Jürgen spricht)"):
|
||
with gr.Row():
|
||
with gr.Column(scale=2):
|
||
text_input = gr.Textbox(
|
||
label="Text eingeben",
|
||
placeholder="Schreib hier, was Jürgen sagen soll...",
|
||
lines=3,
|
||
value="Frag ma, ob de die Fotos vom Tobias kriegst! Wir ham keene gemacht. Aber nich in die Gruppen neistellen... der Kenny stellt's bloß wieder online!"
|
||
)
|
||
with gr.Row():
|
||
mode_radio = gr.Radio(
|
||
choices=[("🔥 Impulsiv / Auf dem Platz", "platz"), ("☕ Ruhig / LKW-Fahrerkabine", "lkw")],
|
||
value="platz",
|
||
label="Stimmung / Modus"
|
||
)
|
||
speed_check = gr.Checkbox(label="Schnelleres Sprechtempo (+10%)", value=False)
|
||
|
||
generate_btn = gr.Button("🎙️ Jürgen sprechen lassen", variant="primary")
|
||
|
||
gr.Examples(
|
||
examples=[
|
||
["Frag ma, ob de die Fotos vom Tobias kriegst! Wir ham keene gemacht. Aber nich in die Gruppen neistellen... der Kenny stellt's bloß wieder online!", "platz"],
|
||
["Fertig Ballett oder was?! Mensch, da guckt man nicht zu, da packt man an!", "platz"],
|
||
["Was soll mich aufregen? Eigentlich gar nicht. Von der Sache her lässt mich alles eiskalt. Hauptsache angekommen, stimmt's?!", "lkw"],
|
||
["Pass mal auf! Was nicht ganz läuft so wie ich das will, das wird so gemacht, damit das läuft!", "platz"],
|
||
],
|
||
inputs=[text_input, mode_radio]
|
||
)
|
||
|
||
with gr.Column(scale=1):
|
||
audio_output = gr.Audio(label="Jürgen spricht:", type="filepath")
|
||
status_box = gr.Textbox(label="Status", interactive=False)
|
||
|
||
generate_btn.click(
|
||
tts_generate,
|
||
inputs=[text_input, mode_radio, speed_check],
|
||
outputs=[audio_output, status_box]
|
||
)
|
||
|
||
with gr.Tab("🎤 Voice Changer (Mikrofon / Audio -> Jürgen)"):
|
||
gr.Markdown("Sprich selbst ins Mikrofon (mit Dialekt/Betonung) oder lade Audio hoch – das Modell wandelt deine Stimme 1:1 in Jürgen Seiferth um!")
|
||
with gr.Row():
|
||
with gr.Column():
|
||
audio_input = gr.Audio(label="Deine Stimme aufnehmen oder hochladen", type="filepath")
|
||
convert_btn = gr.Button("🔄 In Jürgen umwandeln", variant="primary")
|
||
with gr.Column():
|
||
vc_output = gr.Audio(label="Ergebnis in Jürgens Stimme:", type="filepath")
|
||
vc_status = gr.Textbox(label="Status", interactive=False)
|
||
|
||
convert_btn.click(
|
||
vc_convert,
|
||
inputs=[audio_input],
|
||
outputs=[vc_output, vc_status]
|
||
)
|
||
|
||
if __name__ == "__main__":
|
||
demo.launch(server_name="127.0.0.1", server_port=7860, inbrowser=False)
|