Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -17,23 +17,27 @@ def run_pipeline(audio_input, remove_fillers, remove_stutters, remove_silences,
|
|
| 17 |
os.makedirs(out_dir, exist_ok=True)
|
| 18 |
|
| 19 |
try:
|
| 20 |
-
# 1. Clean (
|
| 21 |
res = denoiser.process(
|
| 22 |
audio_input, out_dir,
|
| 23 |
fillers=remove_fillers,
|
| 24 |
stutters=remove_stutters,
|
| 25 |
-
long_silences=remove_silences
|
|
|
|
|
|
|
| 26 |
)
|
| 27 |
|
| 28 |
# 2. Transcribe
|
| 29 |
-
|
|
|
|
|
|
|
| 30 |
if remove_fillers:
|
| 31 |
text = denoiser.clean_transcript_fillers(text)
|
| 32 |
|
| 33 |
# 3. Translate
|
| 34 |
translated = translator.translate(text, target_lang)
|
| 35 |
|
| 36 |
-
# 4. Final MP3 Export
|
| 37 |
final_mp3 = os.path.join(out_dir, "ClearWave_Final.mp3")
|
| 38 |
subprocess.run([
|
| 39 |
"ffmpeg", "-y", "-i", res['audio_path'],
|
|
@@ -44,20 +48,43 @@ def run_pipeline(audio_input, remove_fillers, remove_stutters, remove_silences,
|
|
| 44 |
except Exception as e:
|
| 45 |
return None, f"Error: {e}", ""
|
| 46 |
|
| 47 |
-
#
|
| 48 |
-
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
with gr.Row():
|
| 51 |
-
with gr.Column():
|
| 52 |
-
audio_in = gr.Audio(label="Upload Audio (
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
os.makedirs(out_dir, exist_ok=True)
|
| 18 |
|
| 19 |
try:
|
| 20 |
+
# 1. Clean (Passes all 5 specific toggles to the API)
|
| 21 |
res = denoiser.process(
|
| 22 |
audio_input, out_dir,
|
| 23 |
fillers=remove_fillers,
|
| 24 |
stutters=remove_stutters,
|
| 25 |
+
long_silences=remove_silences,
|
| 26 |
+
breath=remove_breaths,
|
| 27 |
+
mouth_sounds=remove_mouth
|
| 28 |
)
|
| 29 |
|
| 30 |
# 2. Transcribe
|
| 31 |
+
text_data = transcriber.transcribe(res['audio_path'])
|
| 32 |
+
text = text_data['text']
|
| 33 |
+
|
| 34 |
if remove_fillers:
|
| 35 |
text = denoiser.clean_transcript_fillers(text)
|
| 36 |
|
| 37 |
# 3. Translate
|
| 38 |
translated = translator.translate(text, target_lang)
|
| 39 |
|
| 40 |
+
# 4. Final MP3 Export (Guarantees .mp3 output)
|
| 41 |
final_mp3 = os.path.join(out_dir, "ClearWave_Final.mp3")
|
| 42 |
subprocess.run([
|
| 43 |
"ffmpeg", "-y", "-i", res['audio_path'],
|
|
|
|
| 48 |
except Exception as e:
|
| 49 |
return None, f"Error: {e}", ""
|
| 50 |
|
| 51 |
+
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 52 |
+
# GRADIO INTERFACE (The Golden Layout)
|
| 53 |
+
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 54 |
+
with gr.Blocks(title="ClearWave AI Studio") as demo:
|
| 55 |
+
gr.Markdown("# ποΈ ClearWave AI Studio")
|
| 56 |
+
gr.Markdown("Professional MP3 Audio Cleaning, Transcription, and Translation.")
|
| 57 |
+
|
| 58 |
with gr.Row():
|
| 59 |
+
with gr.Column(scale=1):
|
| 60 |
+
audio_in = gr.Audio(label="Upload Audio (WhatsApp, AAC, WAV, MP3)", type="filepath")
|
| 61 |
+
|
| 62 |
+
with gr.Group():
|
| 63 |
+
gr.Markdown("### π οΈ Audio Cleaning Settings")
|
| 64 |
+
f_check = gr.Checkbox(label="Remove Fillers (um, ah)", value=True)
|
| 65 |
+
s_check = gr.Checkbox(label="Remove Stutters", value=True)
|
| 66 |
+
z_check = gr.Checkbox(label="Remove Long Silences", value=True)
|
| 67 |
+
b_check = gr.Checkbox(label="Remove Breaths", value=True)
|
| 68 |
+
m_check = gr.Checkbox(label="Remove Mouth Noises", value=True)
|
| 69 |
+
|
| 70 |
+
target_lang = gr.Dropdown(
|
| 71 |
+
choices=["Hindi", "Telugu", "Spanish", "French", "German", "Japanese", "Arabic"],
|
| 72 |
+
value="Hindi",
|
| 73 |
+
label="Translation Target Language"
|
| 74 |
+
)
|
| 75 |
+
|
| 76 |
+
process_btn = gr.Button("π Generate Studio MP3", variant="primary")
|
| 77 |
+
|
| 78 |
+
with gr.Column(scale=1):
|
| 79 |
+
audio_out = gr.Audio(label="Final Cleaned MP3 Output")
|
| 80 |
+
transcript_output = gr.Textbox(label="Cleaned Transcript", lines=5)
|
| 81 |
+
translation_output = gr.Textbox(label="Translation", lines=5)
|
| 82 |
+
|
| 83 |
+
process_btn.click(
|
| 84 |
+
fn=run_pipeline,
|
| 85 |
+
inputs=[audio_in, f_check, s_check, z_check, b_check, m_check, target_lang],
|
| 86 |
+
outputs=[audio_out, transcript_output, translation_output]
|
| 87 |
+
)
|
| 88 |
+
|
| 89 |
+
if __name__ == "__main__":
|
| 90 |
+
demo.launch(theme=gr.themes.Soft())
|