testingfaces commited on
Commit
c8ad66c
Β·
verified Β·
1 Parent(s): fbee549

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +47 -20
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 (Supports WhatsApp via Denoiser pre-process)
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
- text = transcriber.transcribe(res['audio_path'])['text']
 
 
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
- # UI Design
48
- with gr.Blocks() as demo:
49
- gr.Markdown("# πŸŽ™οΈ ClearWave: Universal Audio Studio")
 
 
 
 
50
  with gr.Row():
51
- with gr.Column():
52
- audio_in = gr.Audio(label="Upload Audio (Any Format)", type="filepath")
53
- f = gr.Checkbox(label="Remove Fillers/Stutters", value=True)
54
- lang = gr.Dropdown(choices=["Hindi", "Telugu", "Spanish"], value="Hindi", label="Translate to")
55
- btn = gr.Button("πŸš€ Process to Studio MP3", variant="primary")
56
- with gr.Column():
57
- audio_out = gr.Audio(label="Final Studio MP3")
58
- t_out = gr.Textbox(label="Transcript")
59
- tr_out = gr.Textbox(label="Translation")
60
-
61
- btn.click(run_pipeline, [audio_in, f, f, f, f, f, lang], [audio_out, t_out, tr_out])
62
-
63
- demo.launch(theme=gr.themes.Soft())
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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())