Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import torch
|
| 3 |
+
from kokoro import KModel, KPipeline
|
| 4 |
+
import numpy as np
|
| 5 |
+
|
| 6 |
+
# Load the lightweight 82M model
|
| 7 |
+
pipeline = KPipeline(lang_code='a') # 'a' for American English
|
| 8 |
+
|
| 9 |
+
def clone_voice(text, speed):
|
| 10 |
+
# This generates audio using the default voice
|
| 11 |
+
# To 'clone', you can later upload a voice traits file (.pt)
|
| 12 |
+
generator = pipeline(text, voice='af_bella', speed=speed, split_pattern=r'\n+')
|
| 13 |
+
|
| 14 |
+
for gs, ps, audio in generator:
|
| 15 |
+
return (24000, audio.numpy())
|
| 16 |
+
|
| 17 |
+
# Build the UI
|
| 18 |
+
demo = gr.Interface(
|
| 19 |
+
fn=clone_voice,
|
| 20 |
+
inputs=[
|
| 21 |
+
gr.Textbox(label="Enter Text", placeholder="Hello, I am your AI assistant..."),
|
| 22 |
+
gr.Slider(minimum=0.5, maximum=2.0, value=1.0, label="Speed")
|
| 23 |
+
],
|
| 24 |
+
outputs=gr.Audio(label="Cloned Voice"),
|
| 25 |
+
title="VJTI Voice Cloner",
|
| 26 |
+
description="Fast, free voice cloning running on Hugging Face CPU."
|
| 27 |
+
)
|
| 28 |
+
|
| 29 |
+
demo.launch()
|