| import os |
| import gradio as gr |
| from TTS.api import TTS |
|
|
| print("β³ XTTS-v2 Model Download ho raha hai... Isme 10-15 min lagenge!") |
|
|
| |
| os.environ["COQUI_TOS_AGREED"] = "1" |
|
|
| |
| |
| tts = TTS(model_name="tts_models/multilingual/multi-dataset/xtts_v2", gpu=False) |
|
|
| def clone_voice(script, ref_audio): |
| if not script or not ref_audio: |
| return None, "β οΈ Bhai, Script aur Reference Voice dono zaroori hain!" |
| |
| try: |
| output_file = "voiceforge_final.wav" |
| |
| |
| tts.tts_to_file( |
| text=script, |
| file_path=output_file, |
| speaker_wav=ref_audio, |
| language="en" |
| ) |
|
|
| |
| return output_file, "β
Boom! Teri apni AI ne locally aawaz bana di!" |
| |
| except Exception as e: |
| return None, f"β οΈ Error: {str(e)}" |
|
|
| |
| with gr.Blocks(theme=gr.themes.Monochrome()) as iface: |
| gr.Markdown("# ποΈ VoiceForge Mobile Studio") |
| gr.Markdown("### β‘ True Local AI Clone Engine (XTTS-v2) | Dev: Naman Rai") |
| |
| with gr.Row(): |
| with gr.Column(): |
| ref_audio_input = gr.Audio(type="filepath", label="π΅ Reference Voice (5-10 sec saaf aawaz)") |
| script_input = gr.Textbox( |
| label="π Script Yahan Daal", |
| lines=4, |
| placeholder="Bhai log, aaj ke is montage mein..." |
| ) |
| generate_btn = gr.Button("π Generate Clone", variant="primary") |
| |
| with gr.Column(): |
| audio_output = gr.Audio(label="VoiceForge Output") |
| status_output = gr.Textbox(label="System Console") |
|
|
| generate_btn.click( |
| fn=clone_voice, |
| inputs=[script_input, ref_audio_input], |
| outputs=[audio_output, status_output], |
| api_name="clone_voice" |
| ) |
|
|
| |
| iface.queue(default_concurrency_limit=1, max_size=50).launch() |
|
|