Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -21,7 +21,7 @@ from faster_whisper import WhisperModel
|
|
| 21 |
from TTS.api import TTS
|
| 22 |
import base64
|
| 23 |
import pickle
|
| 24 |
-
import
|
| 25 |
import soundfile as sf
|
| 26 |
from moviepy.editor import VideoFileClip
|
| 27 |
|
|
@@ -462,7 +462,7 @@ def live_effect_preview(stream, selected_effect):
|
|
| 462 |
except Exception as e:
|
| 463 |
return None
|
| 464 |
|
| 465 |
-
# === Voice Command Parsing ===
|
| 466 |
def voice_to_effect(command):
|
| 467 |
command = command.lower()
|
| 468 |
if "noise reduction" in command or "remove noise" in command:
|
|
@@ -491,7 +491,7 @@ def stretch_to_bpm(audio_path, target_bpm=128):
|
|
| 491 |
y_np = y.numpy().flatten()
|
| 492 |
tempo, _ = librosa.beat.beat_track(y=y_np, sr=sr)
|
| 493 |
ratio = target_bpm / tempo
|
| 494 |
-
stretched = librosa.effects.time_stretch(y_np,
|
| 495 |
out_path = os.path.join(tempfile.gettempdir(), "stretched_output.wav")
|
| 496 |
sf.write(out_path, stretched, sr, format='WAV')
|
| 497 |
return out_path
|
|
@@ -514,6 +514,15 @@ def re_sync_audio(video_path, edited_audio_path):
|
|
| 514 |
final_clip.write_videofile(out_path, codec="libx264", audio_codec="aac")
|
| 515 |
return out_path
|
| 516 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 517 |
# === Main UI β With Studio Pulse Branding ===
|
| 518 |
with gr.Blocks(css="""
|
| 519 |
body {
|
|
@@ -671,7 +680,7 @@ with gr.Blocks(css="""
|
|
| 671 |
allow_flagging="never"
|
| 672 |
)
|
| 673 |
|
| 674 |
-
# --- Remix Mode β Apply Effects to
|
| 675 |
with gr.Tab("π Remix Mode"):
|
| 676 |
with gr.Row():
|
| 677 |
with gr.Column(min_width=200):
|
|
@@ -684,11 +693,9 @@ with gr.Blocks(css="""
|
|
| 684 |
gr.File(label="Bass"),
|
| 685 |
gr.File(label="Other")
|
| 686 |
]
|
| 687 |
-
|
| 688 |
split_button.click(fn=stem_split, inputs=[input_audio_remix], outputs=stem_outputs)
|
| 689 |
|
| 690 |
gr.Markdown("#### Apply Effects to Individual Stems")
|
| 691 |
-
|
| 692 |
with gr.Row():
|
| 693 |
with gr.Column(min_width=200):
|
| 694 |
vocals_path = gr.File(label="Vocals Track")
|
|
@@ -773,9 +780,7 @@ with gr.Blocks(css="""
|
|
| 773 |
gr.Interface(
|
| 774 |
fn=voice_to_effect,
|
| 775 |
inputs=gr.Textbox(label="Describe What You Want", lines=5),
|
| 776 |
-
outputs=gr.CheckboxGroup(choices=list(effect_map.keys())
|
| 777 |
-
title="Tell Us What You Want β We'll Apply It",
|
| 778 |
-
description="Say things like 'remove noise' or 'boost bass'"
|
| 779 |
)
|
| 780 |
|
| 781 |
# --- Multi-track Mixing Console ===
|
|
|
|
| 21 |
from TTS.api import TTS
|
| 22 |
import base64
|
| 23 |
import pickle
|
| 24 |
+
import json
|
| 25 |
import soundfile as sf
|
| 26 |
from moviepy.editor import VideoFileClip
|
| 27 |
|
|
|
|
| 462 |
except Exception as e:
|
| 463 |
return None
|
| 464 |
|
| 465 |
+
# === Voice Command Parsing (No Crepe Needed) ===
|
| 466 |
def voice_to_effect(command):
|
| 467 |
command = command.lower()
|
| 468 |
if "noise reduction" in command or "remove noise" in command:
|
|
|
|
| 491 |
y_np = y.numpy().flatten()
|
| 492 |
tempo, _ = librosa.beat.beat_track(y=y_np, sr=sr)
|
| 493 |
ratio = target_bpm / tempo
|
| 494 |
+
stretched = librosa.effects.time_stretch(y_np, ratio)
|
| 495 |
out_path = os.path.join(tempfile.gettempdir(), "stretched_output.wav")
|
| 496 |
sf.write(out_path, stretched, sr, format='WAV')
|
| 497 |
return out_path
|
|
|
|
| 514 |
final_clip.write_videofile(out_path, codec="libx264", audio_codec="aac")
|
| 515 |
return out_path
|
| 516 |
|
| 517 |
+
# === Multi-track Mixing Console ===
|
| 518 |
+
def mix_tracks(track1_path, track2_path, vol1, vol2):
|
| 519 |
+
seg1 = AudioSegment.from_file(track1_path) * vol1
|
| 520 |
+
seg2 = AudioSegment.from_file(track2_path) * vol2
|
| 521 |
+
mixed = seg1.overlay(seg2)
|
| 522 |
+
out_path = os.path.join(tempfile.gettempdir(), "mixed_output.wav")
|
| 523 |
+
mixed.export(out_path, format="wav")
|
| 524 |
+
return out_path
|
| 525 |
+
|
| 526 |
# === Main UI β With Studio Pulse Branding ===
|
| 527 |
with gr.Blocks(css="""
|
| 528 |
body {
|
|
|
|
| 680 |
allow_flagging="never"
|
| 681 |
)
|
| 682 |
|
| 683 |
+
# --- Remix Mode β Apply Effects to Individual Stems ===
|
| 684 |
with gr.Tab("π Remix Mode"):
|
| 685 |
with gr.Row():
|
| 686 |
with gr.Column(min_width=200):
|
|
|
|
| 693 |
gr.File(label="Bass"),
|
| 694 |
gr.File(label="Other")
|
| 695 |
]
|
|
|
|
| 696 |
split_button.click(fn=stem_split, inputs=[input_audio_remix], outputs=stem_outputs)
|
| 697 |
|
| 698 |
gr.Markdown("#### Apply Effects to Individual Stems")
|
|
|
|
| 699 |
with gr.Row():
|
| 700 |
with gr.Column(min_width=200):
|
| 701 |
vocals_path = gr.File(label="Vocals Track")
|
|
|
|
| 780 |
gr.Interface(
|
| 781 |
fn=voice_to_effect,
|
| 782 |
inputs=gr.Textbox(label="Describe What You Want", lines=5),
|
| 783 |
+
outputs=gr.CheckboxGroup(choices=list(effect_map.keys()), label="Suggested Effects")
|
|
|
|
|
|
|
| 784 |
)
|
| 785 |
|
| 786 |
# --- Multi-track Mixing Console ===
|