tee342 commited on
Commit
e6a7c54
Β·
verified Β·
1 Parent(s): 440165c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -46
app.py CHANGED
@@ -22,7 +22,7 @@ from faster_whisper import WhisperModel
22
  from mutagen.mp3 import MP3
23
  from mutagen.id3 import ID3, TIT2, TPE1, TALB, TYER
24
 
25
- # Suppress warnings
26
  warnings.filterwarnings("ignore")
27
 
28
  # === Helper Functions ===
@@ -306,24 +306,21 @@ def analyze_audio(audio_path):
306
 
307
  return stats, image
308
 
309
- # === Auto-Save Sessions ===
310
- def auto_save_session(data):
311
- import base64
312
- encoded = base64.b64encode(json.dumps(data).encode()).decode()
313
- return f"https://your-studio-url?load={encoded}"
314
-
315
- # === Voiceprint Matching ===
316
  from resemblyzer import preprocess_wav, VoiceEncoder
317
 
318
  encoder = VoiceEncoder()
319
 
320
  def match_speakers(clip1, clip2):
321
- wav1 = preprocess_wav(clip1)
322
- wav2 = preprocess_wav(clip2)
323
- embed1 = encoder.embed_utterance(wav1)
324
- embed2 = encoder.embed_utterance(wav2)
325
- similarity = np.inner(embed1, embed2)
326
- return f"Speaker Match Score: {similarity:.2f}"
 
 
 
327
 
328
  # === Mix Two Tracks ===
329
  def mix_tracks(track1, track2, volume_offset=0):
@@ -346,12 +343,7 @@ def save_project(audio_path, preset_name, effects):
346
  pickle.dump(project_data, f)
347
  return out_path
348
 
349
- def load_project(project_file):
350
- with open(project_file.name, "rb") as f:
351
- data = pickle.load(f)
352
- return data["preset"], data["effects"]
353
-
354
- # === UI ===
355
  effect_options = [
356
  "Noise Reduction",
357
  "Compress Dynamic Range",
@@ -438,7 +430,7 @@ with gr.Blocks(title="AI Audio Studio", css="style.css") as demo:
438
  inputs=gr.Audio(label="Upload Audio", type="filepath"),
439
  outputs=gr.Textbox(label="Transcribed Text", lines=10),
440
  title="Transcribe & Edit Spoken Content",
441
- description="Convert voice to text and edit it before re-exporting."
442
  )
443
 
444
  # --- TTS Voice Generator ---
@@ -451,7 +443,7 @@ with gr.Blocks(title="AI Audio Studio", css="style.css") as demo:
451
  description="Type anything and turn it into natural-sounding speech."
452
  )
453
 
454
- # --- Voiceprint Matching ---
455
  with gr.Tab("πŸ§β€β™‚οΈ Match Speakers"):
456
  gr.Interface(
457
  fn=match_speakers,
@@ -464,29 +456,6 @@ with gr.Blocks(title="AI Audio Studio", css="style.css") as demo:
464
  description="Detect speaker similarity using AI."
465
  )
466
 
467
- # --- Voice Cloning (AI Dubbing) ---
468
- with gr.Tab("🎭 Voice Cloning (AI Dubbing)"):
469
- gr.Interface(
470
- fn=clone_voice,
471
- inputs=[
472
- gr.File(label="Source Voice"),
473
- gr.File(label="Target Voice")
474
- ],
475
- outputs=gr.Audio(label="Cloned Output", type="filepath"),
476
- title="Replace Voice with Another",
477
- description="Clone voice from source to target speaker."
478
- )
479
-
480
- # --- AI Mastering Mode ---
481
- with gr.Tab("πŸ“ˆ AI Mastering Mode"):
482
- gr.Interface(
483
- fn=ai_mastering,
484
- inputs=gr.Audio(label="Upload Track", type="filepath"),
485
- outputs=gr.Audio(label="Mastered Output", type="filepath"),
486
- title="Auto-Master Your Track",
487
- description="Smart mastering for streaming platforms like Spotify, YouTube, or podcasts."
488
- )
489
-
490
  # --- Mix Two Tracks ---
491
  with gr.Tab("πŸ”€ Mix Two Tracks"):
492
  gr.Interface(
@@ -498,7 +467,7 @@ with gr.Blocks(title="AI Audio Studio", css="style.css") as demo:
498
  ],
499
  outputs=gr.File(label="Mixed Output"),
500
  title="Overlay Two Tracks",
501
- description="Mix, blend, or subtract two audio files."
502
  )
503
 
504
  # --- Load/Save Project ---
 
22
  from mutagen.mp3 import MP3
23
  from mutagen.id3 import ID3, TIT2, TPE1, TALB, TYER
24
 
25
+ # Suppress warnings for cleaner logs
26
  warnings.filterwarnings("ignore")
27
 
28
  # === Helper Functions ===
 
306
 
307
  return stats, image
308
 
309
+ # === Speaker Matching (Voiceprint) ===
 
 
 
 
 
 
310
  from resemblyzer import preprocess_wav, VoiceEncoder
311
 
312
  encoder = VoiceEncoder()
313
 
314
  def match_speakers(clip1, clip2):
315
+ try:
316
+ wav1 = preprocess_wav(clip1)
317
+ wav2 = preprocess_wav(clip2)
318
+ embed1 = encoder.embed_utterance(wav1)
319
+ embed2 = encoder.embed_utterance(wav2)
320
+ similarity = np.inner(embed1, embed2)
321
+ return f"Speaker Match Score: {similarity:.2f}"
322
+ except Exception as e:
323
+ return f"⚠️ Error: {str(e)}"
324
 
325
  # === Mix Two Tracks ===
326
  def mix_tracks(track1, track2, volume_offset=0):
 
343
  pickle.dump(project_data, f)
344
  return out_path
345
 
346
+ # UI Setup
 
 
 
 
 
347
  effect_options = [
348
  "Noise Reduction",
349
  "Compress Dynamic Range",
 
430
  inputs=gr.Audio(label="Upload Audio", type="filepath"),
431
  outputs=gr.Textbox(label="Transcribed Text", lines=10),
432
  title="Transcribe & Edit Spoken Content",
433
+ description="Convert voice to text, then edit the script before exporting again."
434
  )
435
 
436
  # --- TTS Voice Generator ---
 
443
  description="Type anything and turn it into natural-sounding speech."
444
  )
445
 
446
+ # --- Speaker Matching ---
447
  with gr.Tab("πŸ§β€β™‚οΈ Match Speakers"):
448
  gr.Interface(
449
  fn=match_speakers,
 
456
  description="Detect speaker similarity using AI."
457
  )
458
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
459
  # --- Mix Two Tracks ---
460
  with gr.Tab("πŸ”€ Mix Two Tracks"):
461
  gr.Interface(
 
467
  ],
468
  outputs=gr.File(label="Mixed Output"),
469
  title="Overlay Two Tracks",
470
+ description="Mix or subtract two audio files."
471
  )
472
 
473
  # --- Load/Save Project ---