Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -131,6 +131,11 @@ def apply_bitcrush(audio, bit_depth=8):
|
|
| 131 |
downsampled = np.round(samples / (32768 / max_val)).astype(np.int16)
|
| 132 |
return array_to_audiosegment(downsampled, audio.frame_rate // 2, channels=audio.channels)
|
| 133 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
# === Loudness Matching ===
|
| 135 |
|
| 136 |
try:
|
|
@@ -699,13 +704,8 @@ with gr.Blocks() as demo:
|
|
| 699 |
formant_shift = gr.Slider(minimum=-2, maximum=2, value=1.0, step=0.1, label="Formant Shift")
|
| 700 |
formant_output = gr.Audio(label="Natural-Sounding Vocal", type="numpy")
|
| 701 |
formant_btn = gr.Button("Apply Correction")
|
| 702 |
-
|
| 703 |
-
|
| 704 |
-
samples, sr = audiosegment_to_array(audio)
|
| 705 |
-
corrected_samples = librosa.effects.pitch_shift(samples, sr=sr, n_steps=shift)
|
| 706 |
-
return array_to_audiosegment(corrected_samples.astype(np.int16), sr, channels=audio.channels)
|
| 707 |
-
|
| 708 |
-
|
| 709 |
# Tab: Voice Swap / Cloning
|
| 710 |
with gr.Tab("🔁 Voice Swap / Cloning"):
|
| 711 |
source_voice = gr.File(label="Source Voice Clip")
|
|
|
|
| 131 |
downsampled = np.round(samples / (32768 / max_val)).astype(np.int16)
|
| 132 |
return array_to_audiosegment(downsampled, audio.frame_rate // 2, channels=audio.channels)
|
| 133 |
|
| 134 |
+
def formant_correct(audio, shift=1.0):
|
| 135 |
+
samples, sr = audiosegment_to_array(audio)
|
| 136 |
+
corrected_samples = librosa.effects.pitch_shift(samples, sr=sr, n_steps=shift)
|
| 137 |
+
return array_to_audiosegment(corrected_samples.astype(np.int16), sr, channels=audio.channels)
|
| 138 |
+
|
| 139 |
# === Loudness Matching ===
|
| 140 |
|
| 141 |
try:
|
|
|
|
| 704 |
formant_shift = gr.Slider(minimum=-2, maximum=2, value=1.0, step=0.1, label="Formant Shift")
|
| 705 |
formant_output = gr.Audio(label="Natural-Sounding Vocal", type="numpy")
|
| 706 |
formant_btn = gr.Button("Apply Correction")
|
| 707 |
+
formant_btn.click(fn=formant_correct, inputs=[formant_audio, formant_shift], outputs=formant_output)
|
| 708 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 709 |
# Tab: Voice Swap / Cloning
|
| 710 |
with gr.Tab("🔁 Voice Swap / Cloning"):
|
| 711 |
source_voice = gr.File(label="Source Voice Clip")
|