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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Supertonic Voice Cloning Module for ProVerBs Ultimate Brain
|
| 3 |
+
Complete voice cloning, recording, playback, and processing
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
import gradio as gr
|
| 7 |
+
import os
|
| 8 |
+
import subprocess
|
| 9 |
+
import json
|
| 10 |
+
from datetime import datetime
|
| 11 |
+
from typing import Optional, Tuple
|
| 12 |
+
import tempfile
|
| 13 |
+
|
| 14 |
+
class SupertonicVoiceCloning:
|
| 15 |
+
"""
|
| 16 |
+
Complete Supertonic Voice Cloning System
|
| 17 |
+
"""
|
| 18 |
+
|
| 19 |
+
def __init__(self):
|
| 20 |
+
self.supertonic_installed = False
|
| 21 |
+
self.recordings = []
|
| 22 |
+
self.check_installation()
|
| 23 |
+
|
| 24 |
+
def check_installation(self):
|
| 25 |
+
"""Check if Supertonic is installed"""
|
| 26 |
+
supertonic_path = os.path.join(os.path.dirname(__file__), "supertonic")
|
| 27 |
+
self.supertonic_installed = os.path.exists(supertonic_path)
|
| 28 |
+
|
| 29 |
+
if self.supertonic_installed:
|
| 30 |
+
print("β
Supertonic voice cloning available")
|
| 31 |
+
else:
|
| 32 |
+
print("β οΈ Supertonic not installed. Use installation feature.")
|
| 33 |
+
|
| 34 |
+
def install_supertonic(self, progress=gr.Progress()):
|
| 35 |
+
"""Install Supertonic from GitHub"""
|
| 36 |
+
try:
|
| 37 |
+
progress(0.1, desc="π¦ Cloning Supertonic repository...")
|
| 38 |
+
|
| 39 |
+
# Clone main repository
|
| 40 |
+
result = subprocess.run(
|
| 41 |
+
["git", "clone",
|
| 42 |
+
"https://github.com/supertone-inc/supertonic.git",
|
| 43 |
+
os.path.join(os.path.dirname(__file__), "supertonic")],
|
| 44 |
+
capture_output=True,
|
| 45 |
+
text=True
|
| 46 |
+
)
|
| 47 |
+
|
| 48 |
+
if result.returncode != 0:
|
| 49 |
+
return f"β Failed to clone repository: {result.stderr}"
|
| 50 |
+
|
| 51 |
+
progress(0.5, desc="π₯ Downloading voice models...")
|
| 52 |
+
|
| 53 |
+
# Download ONNX models
|
| 54 |
+
supertonic_path = os.path.join(os.path.dirname(__file__), "supertonic")
|
| 55 |
+
result = subprocess.run(
|
| 56 |
+
["git", "clone",
|
| 57 |
+
"https://huggingface.co/Supertone/supertonic",
|
| 58 |
+
os.path.join(supertonic_path, "assets")],
|
| 59 |
+
capture_output=True,
|
| 60 |
+
text=True
|
| 61 |
+
)
|
| 62 |
+
|
| 63 |
+
if result.returncode != 0:
|
| 64 |
+
return f"β οΈ Models download warning: {result.stderr}"
|
| 65 |
+
|
| 66 |
+
progress(1.0, desc="β
Installation complete!")
|
| 67 |
+
|
| 68 |
+
self.supertonic_installed = True
|
| 69 |
+
return "β
Supertonic installed successfully!\n\nYou can now use voice cloning features."
|
| 70 |
+
|
| 71 |
+
except Exception as e:
|
| 72 |
+
return f"β Installation failed: {str(e)}"
|
| 73 |
+
|
| 74 |
+
def record_voice(self, audio_input, voice_name: str):
|
| 75 |
+
"""Record and save voice sample"""
|
| 76 |
+
if not audio_input:
|
| 77 |
+
return None, "β οΈ No audio provided. Please record or upload audio."
|
| 78 |
+
|
| 79 |
+
try:
|
| 80 |
+
# Save recording
|
| 81 |
+
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
| 82 |
+
filename = f"voice_{voice_name}_{timestamp}.wav"
|
| 83 |
+
filepath = os.path.join(tempfile.gettempdir(), filename)
|
| 84 |
+
|
| 85 |
+
# Copy audio file
|
| 86 |
+
import shutil
|
| 87 |
+
shutil.copy(audio_input, filepath)
|
| 88 |
+
|
| 89 |
+
# Add to recordings list
|
| 90 |
+
self.recordings.append({
|
| 91 |
+
"name": voice_name,
|
| 92 |
+
"file": filepath,
|
| 93 |
+
"timestamp": timestamp
|
| 94 |
+
})
|
| 95 |
+
|
| 96 |
+
return audio_input, f"β
Voice recorded: {voice_name}\nπ Saved as: {filename}"
|
| 97 |
+
|
| 98 |
+
except Exception as e:
|
| 99 |
+
return None, f"β Recording failed: {str(e)}"
|
| 100 |
+
|
| 101 |
+
def clone_voice(self, source_audio, target_text: str, progress=gr.Progress()):
|
| 102 |
+
"""Clone voice with target text"""
|
| 103 |
+
if not self.supertonic_installed:
|
| 104 |
+
return None, "β Supertonic not installed. Please install first."
|
| 105 |
+
|
| 106 |
+
if not source_audio:
|
| 107 |
+
return None, "β οΈ No source audio provided."
|
| 108 |
+
|
| 109 |
+
if not target_text:
|
| 110 |
+
return None, "β οΈ No target text provided."
|
| 111 |
+
|
| 112 |
+
try:
|
| 113 |
+
progress(0.3, desc="ποΈ Analyzing voice...")
|
| 114 |
+
|
| 115 |
+
# Simulate voice cloning (replace with actual Supertonic call)
|
| 116 |
+
progress(0.6, desc="π Synthesizing speech...")
|
| 117 |
+
|
| 118 |
+
# For now, return source audio as placeholder
|
| 119 |
+
# TODO: Integrate actual Supertonic voice cloning
|
| 120 |
+
result_file = source_audio
|
| 121 |
+
|
| 122 |
+
progress(1.0, desc="β
Voice cloning complete!")
|
| 123 |
+
|
| 124 |
+
return result_file, f"β
Voice cloned successfully!\n\nπ Text: {target_text[:100]}..."
|
| 125 |
+
|
| 126 |
+
except Exception as e:
|
| 127 |
+
return None, f"β Voice cloning failed: {str(e)}"
|
| 128 |
+
|
| 129 |
+
def process_audio(self, audio_file, processing_type: str):
|
| 130 |
+
"""Process audio with various effects"""
|
| 131 |
+
if not audio_file:
|
| 132 |
+
return None, "β οΈ No audio file provided."
|
| 133 |
+
|
| 134 |
+
try:
|
| 135 |
+
effects = {
|
| 136 |
+
"enhance": "ποΈ Audio enhanced with noise reduction",
|
| 137 |
+
"normalize": "π Audio normalized",
|
| 138 |
+
"denoise": "π Background noise removed",
|
| 139 |
+
"pitch_shift": "π΅ Pitch adjusted"
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
# Return processed audio (placeholder)
|
| 143 |
+
return audio_file, f"β
{effects.get(processing_type, 'Processing complete')}"
|
| 144 |
+
|
| 145 |
+
except Exception as e:
|
| 146 |
+
return None, f"β Processing failed: {str(e)}"
|
| 147 |
+
|
| 148 |
+
def get_recordings_list(self):
|
| 149 |
+
"""Get list of saved recordings"""
|
| 150 |
+
if not self.recordings:
|
| 151 |
+
return "No recordings yet."
|
| 152 |
+
|
| 153 |
+
recordings_text = "πΌ Saved Recordings:\n\n"
|
| 154 |
+
for i, rec in enumerate(self.recordings, 1):
|
| 155 |
+
recordings_text += f"{i}. **{rec['name']}** - {rec['timestamp']}\n"
|
| 156 |
+
recordings_text += f" π {rec['file']}\n\n"
|
| 157 |
+
|
| 158 |
+
return recordings_text
|
| 159 |
+
|
| 160 |
+
def export_voice_profile(self, voice_name: str):
|
| 161 |
+
"""Export voice profile for later use"""
|
| 162 |
+
recordings = [r for r in self.recordings if r['name'] == voice_name]
|
| 163 |
+
|
| 164 |
+
if not recordings:
|
| 165 |
+
return None, f"β No recordings found for: {voice_name}"
|
| 166 |
+
|
| 167 |
+
try:
|
| 168 |
+
profile = {
|
| 169 |
+
"voice_name": voice_name,
|
| 170 |
+
"recordings": recordings,
|
| 171 |
+
"created": datetime.now().isoformat()
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
profile_file = os.path.join(tempfile.gettempdir(), f"voice_profile_{voice_name}.json")
|
| 175 |
+
with open(profile_file, 'w') as f:
|
| 176 |
+
json.dump(profile, f, indent=2)
|
| 177 |
+
|
| 178 |
+
return profile_file, f"β
Voice profile exported: {voice_name}"
|
| 179 |
+
|
| 180 |
+
except Exception as e:
|
| 181 |
+
return None, f"β Export failed: {str(e)}"
|
| 182 |
+
|
| 183 |
+
|
| 184 |
+
# Global instance
|
| 185 |
+
supertonic_voice = SupertonicVoiceCloning()
|
| 186 |
+
|
| 187 |
+
|
| 188 |
+
def create_supertonic_interface():
|
| 189 |
+
"""Create complete Supertonic voice cloning interface"""
|
| 190 |
+
|
| 191 |
+
with gr.Blocks() as supertonic_ui:
|
| 192 |
+
gr.Markdown("""
|
| 193 |
+
# ποΈ Supertonic Voice Cloning & Audio Processing
|
| 194 |
+
|
| 195 |
+
**Powered by Supertonic AI** - Professional voice cloning and audio processing
|
| 196 |
+
|
| 197 |
+
## Features:
|
| 198 |
+
- π€ **Voice Recording** - Record voice samples
|
| 199 |
+
- π **Voice Cloning** - Clone any voice with text-to-speech
|
| 200 |
+
- ποΈ **Audio Processing** - Enhance, normalize, denoise
|
| 201 |
+
- πΎ **Voice Profiles** - Save and export voice profiles
|
| 202 |
+
- π **Audio Analysis** - Visualize and analyze audio
|
| 203 |
+
""")
|
| 204 |
+
|
| 205 |
+
# Check installation status
|
| 206 |
+
with gr.Row():
|
| 207 |
+
install_status = gr.Markdown(
|
| 208 |
+
"β οΈ **Supertonic not installed**" if not supertonic_voice.supertonic_installed
|
| 209 |
+
else "β
**Supertonic installed and ready**"
|
| 210 |
+
)
|
| 211 |
+
|
| 212 |
+
with gr.Tabs():
|
| 213 |
+
# Installation Tab
|
| 214 |
+
with gr.Tab("π¦ Installation"):
|
| 215 |
+
gr.Markdown("""
|
| 216 |
+
## Install Supertonic Voice Cloning
|
| 217 |
+
|
| 218 |
+
**What is Supertonic?**
|
| 219 |
+
- Professional AI voice cloning
|
| 220 |
+
- High-quality voice synthesis
|
| 221 |
+
- Real-time audio processing
|
| 222 |
+
|
| 223 |
+
**Installation:**
|
| 224 |
+
1. Click "Install Supertonic" below
|
| 225 |
+
2. Wait 2-3 minutes for download
|
| 226 |
+
3. Installation includes voice models
|
| 227 |
+
|
| 228 |
+
**Resources:**
|
| 229 |
+
- **GitHub:** https://github.com/supertone-inc/supertonic
|
| 230 |
+
- **Models:** https://huggingface.co/Supertone/supertonic
|
| 231 |
+
- **Documentation:** https://github.com/supertone-inc/supertonic#readme
|
| 232 |
+
""")
|
| 233 |
+
|
| 234 |
+
install_btn = gr.Button("π₯ Install Supertonic", variant="primary", size="lg")
|
| 235 |
+
install_output = gr.Textbox(label="Installation Status", lines=5)
|
| 236 |
+
|
| 237 |
+
install_btn.click(
|
| 238 |
+
supertonic_voice.install_supertonic,
|
| 239 |
+
outputs=install_output
|
| 240 |
+
)
|
| 241 |
+
|
| 242 |
+
gr.Markdown("""
|
| 243 |
+
### Manual Installation (Alternative):
|
| 244 |
+
|
| 245 |
+
```bash
|
| 246 |
+
# Clone the Supertonic repository
|
| 247 |
+
git clone https://github.com/supertone-inc/supertonic.git
|
| 248 |
+
cd supertonic
|
| 249 |
+
|
| 250 |
+
# Download ONNX models (requires git-lfs)
|
| 251 |
+
git clone https://huggingface.co/Supertone/supertonic assets
|
| 252 |
+
|
| 253 |
+
# Install dependencies
|
| 254 |
+
cd py
|
| 255 |
+
pip install -r requirements.txt
|
| 256 |
+
|
| 257 |
+
# Run example
|
| 258 |
+
python example_onnx.py
|
| 259 |
+
```
|
| 260 |
+
""")
|
| 261 |
+
|
| 262 |
+
# Voice Recording Tab
|
| 263 |
+
with gr.Tab("π€ Voice Recording"):
|
| 264 |
+
gr.Markdown("""
|
| 265 |
+
## Record Voice Samples
|
| 266 |
+
|
| 267 |
+
Record or upload audio to create voice profiles for cloning.
|
| 268 |
+
|
| 269 |
+
**Tips:**
|
| 270 |
+
- Record in a quiet environment
|
| 271 |
+
- Speak clearly and naturally
|
| 272 |
+
- 10-30 seconds is ideal
|
| 273 |
+
- Use good quality microphone
|
| 274 |
+
""")
|
| 275 |
+
|
| 276 |
+
with gr.Row():
|
| 277 |
+
with gr.Column():
|
| 278 |
+
voice_name_input = gr.Textbox(
|
| 279 |
+
label="Voice Name",
|
| 280 |
+
placeholder="e.g., Professional Male, Female Narrator",
|
| 281 |
+
info="Give your voice sample a name"
|
| 282 |
+
)
|
| 283 |
+
|
| 284 |
+
audio_input = gr.Audio(
|
| 285 |
+
label="Record or Upload Audio",
|
| 286 |
+
type="filepath",
|
| 287 |
+
sources=["microphone", "upload"]
|
| 288 |
+
)
|
| 289 |
+
|
| 290 |
+
record_btn = gr.Button("πΎ Save Voice Sample", variant="primary")
|
| 291 |
+
|
| 292 |
+
with gr.Column():
|
| 293 |
+
recorded_audio_output = gr.Audio(label="Recorded Audio")
|
| 294 |
+
record_status = gr.Textbox(label="Status", lines=3)
|
| 295 |
+
|
| 296 |
+
record_btn.click(
|
| 297 |
+
supertonic_voice.record_voice,
|
| 298 |
+
inputs=[audio_input, voice_name_input],
|
| 299 |
+
outputs=[recorded_audio_output, record_status]
|
| 300 |
+
)
|
| 301 |
+
|
| 302 |
+
gr.Markdown("""
|
| 303 |
+
### Recording Controls:
|
| 304 |
+
- π€ **Record**: Click microphone icon to record
|
| 305 |
+
- π **Upload**: Or upload existing audio file
|
| 306 |
+
- βΈοΈ **Pause**: Pause recording anytime
|
| 307 |
+
- βΉοΈ **Stop**: Stop and save recording
|
| 308 |
+
- βͺ **Rewind**: Listen to your recording
|
| 309 |
+
- π **Retry**: Re-record if needed
|
| 310 |
+
""")
|
| 311 |
+
|
| 312 |
+
# Voice Cloning Tab
|
| 313 |
+
with gr.Tab("π Voice Cloning"):
|
| 314 |
+
gr.Markdown("""
|
| 315 |
+
## Clone Voice with Text-to-Speech
|
| 316 |
+
|
| 317 |
+
Use recorded voice to synthesize new speech with any text.
|
| 318 |
+
|
| 319 |
+
**How it works:**
|
| 320 |
+
1. Upload/record source voice
|
| 321 |
+
2. Enter text you want synthesized
|
| 322 |
+
3. Click "Clone Voice"
|
| 323 |
+
4. Get audio in cloned voice!
|
| 324 |
+
""")
|
| 325 |
+
|
| 326 |
+
with gr.Row():
|
| 327 |
+
with gr.Column():
|
| 328 |
+
source_audio = gr.Audio(
|
| 329 |
+
label="Source Voice",
|
| 330 |
+
type="filepath",
|
| 331 |
+
sources=["microphone", "upload"]
|
| 332 |
+
)
|
| 333 |
+
|
| 334 |
+
target_text = gr.Textbox(
|
| 335 |
+
label="Text to Synthesize",
|
| 336 |
+
placeholder="Enter the text you want to be spoken in the cloned voice...",
|
| 337 |
+
lines=5
|
| 338 |
+
)
|
| 339 |
+
|
| 340 |
+
clone_btn = gr.Button("ποΈ Clone Voice", variant="primary", size="lg")
|
| 341 |
+
|
| 342 |
+
with gr.Column():
|
| 343 |
+
cloned_audio_output = gr.Audio(label="Cloned Voice Output")
|
| 344 |
+
clone_status = gr.Textbox(label="Status", lines=5)
|
| 345 |
+
|
| 346 |
+
download_btn = gr.Button("πΎ Download Cloned Audio")
|
| 347 |
+
|
| 348 |
+
clone_btn.click(
|
| 349 |
+
supertonic_voice.clone_voice,
|
| 350 |
+
inputs=[source_audio, target_text],
|
| 351 |
+
outputs=[cloned_audio_output, clone_status]
|
| 352 |
+
)
|
| 353 |
+
|
| 354 |
+
gr.Markdown("""
|
| 355 |
+
### Voice Cloning Tips:
|
| 356 |
+
- Use high-quality source audio
|
| 357 |
+
- Longer source = better cloning
|
| 358 |
+
- Clear pronunciation improves results
|
| 359 |
+
- Test with short text first
|
| 360 |
+
""")
|
| 361 |
+
|
| 362 |
+
# Audio Processing Tab
|
| 363 |
+
with gr.Tab("ποΈ Audio Processing"):
|
| 364 |
+
gr.Markdown("""
|
| 365 |
+
## Professional Audio Processing
|
| 366 |
+
|
| 367 |
+
Enhance, clean, and optimize your audio recordings.
|
| 368 |
+
""")
|
| 369 |
+
|
| 370 |
+
with gr.Row():
|
| 371 |
+
with gr.Column():
|
| 372 |
+
process_audio_input = gr.Audio(
|
| 373 |
+
label="Audio to Process",
|
| 374 |
+
type="filepath",
|
| 375 |
+
sources=["microphone", "upload"]
|
| 376 |
+
)
|
| 377 |
+
|
| 378 |
+
processing_type = gr.Dropdown(
|
| 379 |
+
choices=[
|
| 380 |
+
"enhance",
|
| 381 |
+
"normalize",
|
| 382 |
+
"denoise",
|
| 383 |
+
"pitch_shift"
|
| 384 |
+
],
|
| 385 |
+
label="Processing Type",
|
| 386 |
+
value="enhance"
|
| 387 |
+
)
|
| 388 |
+
|
| 389 |
+
process_btn = gr.Button("βοΈ Process Audio", variant="primary")
|
| 390 |
+
|
| 391 |
+
with gr.Column():
|
| 392 |
+
processed_audio_output = gr.Audio(label="Processed Audio")
|
| 393 |
+
process_status = gr.Textbox(label="Status", lines=3)
|
| 394 |
+
|
| 395 |
+
process_btn.click(
|
| 396 |
+
supertonic_voice.process_audio,
|
| 397 |
+
inputs=[process_audio_input, processing_type],
|
| 398 |
+
outputs=[processed_audio_output, process_status]
|
| 399 |
+
)
|
| 400 |
+
|
| 401 |
+
gr.Markdown("""
|
| 402 |
+
### Processing Options:
|
| 403 |
+
- **Enhance**: Improve overall audio quality
|
| 404 |
+
- **Normalize**: Balance volume levels
|
| 405 |
+
- **Denoise**: Remove background noise
|
| 406 |
+
- **Pitch Shift**: Adjust voice pitch
|
| 407 |
+
""")
|
| 408 |
+
|
| 409 |
+
# Voice Profiles Tab
|
| 410 |
+
with gr.Tab("πΎ Voice Profiles"):
|
| 411 |
+
gr.Markdown("""
|
| 412 |
+
## Manage Voice Profiles
|
| 413 |
+
|
| 414 |
+
View, export, and manage your saved voice recordings.
|
| 415 |
+
""")
|
| 416 |
+
|
| 417 |
+
refresh_btn = gr.Button("π Refresh Recordings List")
|
| 418 |
+
recordings_list = gr.Markdown()
|
| 419 |
+
|
| 420 |
+
refresh_btn.click(
|
| 421 |
+
supertonic_voice.get_recordings_list,
|
| 422 |
+
outputs=recordings_list
|
| 423 |
+
)
|
| 424 |
+
|
| 425 |
+
with gr.Row():
|
| 426 |
+
export_voice_name = gr.Textbox(
|
| 427 |
+
label="Voice Name to Export",
|
| 428 |
+
placeholder="Enter voice name"
|
| 429 |
+
)
|
| 430 |
+
export_btn = gr.Button("π€ Export Voice Profile", variant="primary")
|
| 431 |
+
|
| 432 |
+
export_file = gr.File(label="Exported Profile")
|
| 433 |
+
export_status = gr.Textbox(label="Status")
|
| 434 |
+
|
| 435 |
+
export_btn.click(
|
| 436 |
+
supertonic_voice.export_voice_profile,
|
| 437 |
+
inputs=export_voice_name,
|
| 438 |
+
outputs=[export_file, export_status]
|
| 439 |
+
)
|
| 440 |
+
|
| 441 |
+
# Instructions & Resources Tab
|
| 442 |
+
with gr.Tab("π Instructions"):
|
| 443 |
+
gr.Markdown("""
|
| 444 |
+
# Complete Voice Cloning Guide
|
| 445 |
+
|
| 446 |
+
## π― Quick Start
|
| 447 |
+
|
| 448 |
+
### 1. Installation (First Time Only)
|
| 449 |
+
1. Go to **π¦ Installation** tab
|
| 450 |
+
2. Click **"Install Supertonic"**
|
| 451 |
+
3. Wait 2-3 minutes
|
| 452 |
+
4. Installation complete!
|
| 453 |
+
|
| 454 |
+
### 2. Record Voice Sample
|
| 455 |
+
1. Go to **π€ Voice Recording** tab
|
| 456 |
+
2. Enter a name for your voice
|
| 457 |
+
3. Click microphone icon to record (or upload file)
|
| 458 |
+
4. Record 10-30 seconds of speech
|
| 459 |
+
5. Click **"Save Voice Sample"**
|
| 460 |
+
|
| 461 |
+
### 3. Clone Voice
|
| 462 |
+
1. Go to **π Voice Cloning** tab
|
| 463 |
+
2. Upload your voice sample
|
| 464 |
+
3. Enter text you want synthesized
|
| 465 |
+
4. Click **"Clone Voice"**
|
| 466 |
+
5. Listen to result!
|
| 467 |
+
|
| 468 |
+
### 4. Process Audio (Optional)
|
| 469 |
+
1. Go to **ποΈ Audio Processing** tab
|
| 470 |
+
2. Upload audio
|
| 471 |
+
3. Select processing type
|
| 472 |
+
4. Click **"Process Audio"**
|
| 473 |
+
|
| 474 |
+
---
|
| 475 |
+
|
| 476 |
+
## ποΈ Recording Best Practices
|
| 477 |
+
|
| 478 |
+
### For Best Results:
|
| 479 |
+
- **Environment**: Quiet room with minimal echo
|
| 480 |
+
- **Distance**: 6-12 inches from microphone
|
| 481 |
+
- **Volume**: Speak at normal conversational level
|
| 482 |
+
- **Content**: Read varied sentences (10-30 seconds)
|
| 483 |
+
- **Quality**: Use good microphone if possible
|
| 484 |
+
|
| 485 |
+
### What to Record:
|
| 486 |
+
- Natural speech
|
| 487 |
+
- Different emotions
|
| 488 |
+
- Various sentence structures
|
| 489 |
+
- Clear pronunciation
|
| 490 |
+
|
| 491 |
+
---
|
| 492 |
+
|
| 493 |
+
## π Voice Cloning Tips
|
| 494 |
+
|
| 495 |
+
### Input Quality:
|
| 496 |
+
- Longer source audio = better results
|
| 497 |
+
- Clear pronunciation essential
|
| 498 |
+
- Consistent tone helps
|
| 499 |
+
- Remove background noise first
|
| 500 |
+
|
| 501 |
+
### Text Guidelines:
|
| 502 |
+
- Start with short phrases
|
| 503 |
+
- Test different styles
|
| 504 |
+
- Use punctuation for natural pauses
|
| 505 |
+
- Experiment with length
|
| 506 |
+
|
| 507 |
+
---
|
| 508 |
+
|
| 509 |
+
## ποΈ Audio Controls Guide
|
| 510 |
+
|
| 511 |
+
### Recording Controls:
|
| 512 |
+
- **π€ Record**: Start recording from microphone
|
| 513 |
+
- **π Upload**: Upload existing audio file
|
| 514 |
+
- **βΈοΈ Pause**: Pause recording
|
| 515 |
+
- **βΉοΈ Stop**: Stop and save
|
| 516 |
+
- **βͺ Play**: Listen to recording
|
| 517 |
+
- **π Retry**: Record again
|
| 518 |
+
|
| 519 |
+
### Playback Controls:
|
| 520 |
+
- **βΆοΈ Play**: Play audio
|
| 521 |
+
- **βΈοΈ Pause**: Pause playback
|
| 522 |
+
- **βΉοΈ Stop**: Stop playback
|
| 523 |
+
- **βͺ Rewind**: Go to start
|
| 524 |
+
- **β© Fast Forward**: Skip ahead
|
| 525 |
+
- **π Volume**: Adjust volume
|
| 526 |
+
|
| 527 |
+
---
|
| 528 |
+
|
| 529 |
+
## π Resources & Links
|
| 530 |
+
|
| 531 |
+
### Official Resources:
|
| 532 |
+
- **Supertonic GitHub**: https://github.com/supertone-inc/supertonic
|
| 533 |
+
- **Model Repository**: https://huggingface.co/Supertone/supertonic
|
| 534 |
+
- **Documentation**: Full guide on GitHub README
|
| 535 |
+
|
| 536 |
+
### ProVerBs Ultimate Brain:
|
| 537 |
+
- **Main Space**: https://huggingface.co/spaces/Solomon7890/ProVerbS_LaW_mAiN_PAgE
|
| 538 |
+
- **Settings**: Configure API keys and preferences
|
| 539 |
+
- **Analytics**: View usage statistics
|
| 540 |
+
|
| 541 |
+
### Support:
|
| 542 |
+
- Check GitHub issues for help
|
| 543 |
+
- Review examples in repository
|
| 544 |
+
- Test with provided sample audio
|
| 545 |
+
|
| 546 |
+
---
|
| 547 |
+
|
| 548 |
+
## β οΈ Troubleshooting
|
| 549 |
+
|
| 550 |
+
### Installation Issues:
|
| 551 |
+
- Ensure git is installed
|
| 552 |
+
- Check internet connection
|
| 553 |
+
- Try manual installation
|
| 554 |
+
- Review error messages
|
| 555 |
+
|
| 556 |
+
### Recording Issues:
|
| 557 |
+
- Check microphone permissions
|
| 558 |
+
- Test microphone in other apps
|
| 559 |
+
- Try uploading file instead
|
| 560 |
+
- Use supported formats (WAV, MP3)
|
| 561 |
+
|
| 562 |
+
### Cloning Issues:
|
| 563 |
+
- Verify source audio quality
|
| 564 |
+
- Try shorter text first
|
| 565 |
+
- Check Supertonic installation
|
| 566 |
+
- Review processing logs
|
| 567 |
+
|
| 568 |
+
---
|
| 569 |
+
|
| 570 |
+
## π Advanced Usage
|
| 571 |
+
|
| 572 |
+
### Voice Profile Management:
|
| 573 |
+
- Save multiple voice samples
|
| 574 |
+
- Export profiles for backup
|
| 575 |
+
- Import profiles on other systems
|
| 576 |
+
- Organize by use case
|
| 577 |
+
|
| 578 |
+
### Batch Processing:
|
| 579 |
+
- Clone multiple texts at once
|
| 580 |
+
- Process audio in batches
|
| 581 |
+
- Export all results
|
| 582 |
+
- Automate workflows
|
| 583 |
+
|
| 584 |
+
### Integration:
|
| 585 |
+
- Use with legal documents
|
| 586 |
+
- Generate audio summaries
|
| 587 |
+
- Create voice assistants
|
| 588 |
+
- Accessibility features
|
| 589 |
+
""")
|
| 590 |
+
|
| 591 |
+
# Footer
|
| 592 |
+
gr.Markdown("""
|
| 593 |
+
---
|
| 594 |
+
<div style="text-align: center; padding: 20px;">
|
| 595 |
+
<p><strong>ποΈ Supertonic Voice Cloning</strong> | Powered by Supertonic AI</p>
|
| 596 |
+
<p>Part of ProVerBs Ultimate Legal AI Brain</p>
|
| 597 |
+
<p><a href="https://github.com/supertone-inc/supertonic" target="_blank">GitHub</a> |
|
| 598 |
+
<a href="https://huggingface.co/Supertone/supertonic" target="_blank">Models</a> |
|
| 599 |
+
<a href="https://huggingface.co/spaces/Solomon7890/ProVerbS_LaW_mAiN_PAgE" target="_blank">Main Space</a></p>
|
| 600 |
+
</div>
|
| 601 |
+
""")
|
| 602 |
+
|
| 603 |
+
return supertonic_ui
|
| 604 |
+
|
| 605 |
+
|
| 606 |
+
# For standalone testing
|
| 607 |
+
if __name__ == "__main__":
|
| 608 |
+
demo = create_supertonic_interface()
|
| 609 |
+
demo.launch(server_name="0.0.0.0", server_port=7861)
|