testingfaces commited on
Commit
10abbbe
Β·
verified Β·
1 Parent(s): b0359bf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -18
app.py CHANGED
@@ -25,7 +25,7 @@ def run_pipeline(audio_input, remove_fillers, remove_stutters, remove_silences,
25
  os.makedirs(out_dir, exist_ok=True)
26
 
27
  try:
28
- # 1. CLEANING (Handles WhatsApp/Any Format)
29
  logger.info("[Step 1] Cleaning Audio...")
30
  res = denoiser.process(
31
  audio_input, out_dir,
@@ -36,22 +36,20 @@ def run_pipeline(audio_input, remove_fillers, remove_stutters, remove_silences,
36
  mouth_sounds=remove_mouth
37
  )
38
 
39
- # 2. TRANSCRIPTION (Fixed the Tuple Index Error)
40
  logger.info("[Step 2] Transcribing...")
41
  transcript_data = transcriber.transcribe(res['audio_path'])
42
 
43
- # Safe Extraction Logic
44
  if isinstance(transcript_data, dict):
45
  text = transcript_data.get('text', "")
46
- elif isinstance(transcript_data, (list, tuple)):
47
- text = transcript_data[0]
48
  else:
49
  text = str(transcript_data)
50
 
51
  if remove_fillers:
52
  text = denoiser.clean_transcript_fillers(text)
53
 
54
- # 3. TRANSLATION (Fixed the Task Error)
55
  logger.info(f"[Step 3] Translating to {target_lang}...")
56
  translated = translator.translate(text, target_lang)
57
 
@@ -68,9 +66,6 @@ def run_pipeline(audio_input, remove_fillers, remove_stutters, remove_silences,
68
  logger.error(f"Pipeline crashed: {e}")
69
  return None, f"Error: {str(e)}", ""
70
 
71
- # ══════════════════════════════════════════════════════════════════
72
- # PROFESSIONAL INTERFACE
73
- # ══════════════════════════════════════════════════════════════════
74
  with gr.Blocks(title="ClearWave AI Studio") as demo:
75
  gr.Markdown("# πŸŽ™οΈ ClearWave AI Studio")
76
  gr.Markdown("Upload any recording. Receive a professional MP3, Transcript, and Translation.")
@@ -78,7 +73,6 @@ with gr.Blocks(title="ClearWave AI Studio") as demo:
78
  with gr.Row():
79
  with gr.Column(scale=1):
80
  audio_in = gr.Audio(label="Input Audio (WhatsApp, AAC, WAV, MP3)", type="filepath")
81
-
82
  with gr.Group():
83
  gr.Markdown("### πŸ› οΈ Studio Cleaning Controls")
84
  f = gr.Checkbox(label="Remove Fillers", value=True)
@@ -86,25 +80,18 @@ with gr.Blocks(title="ClearWave AI Studio") as demo:
86
  z = gr.Checkbox(label="Remove Long Silences", value=True)
87
  b = gr.Checkbox(label="Remove Breaths", value=True)
88
  m = gr.Checkbox(label="Remove Mouth Noises", value=True)
89
-
90
  lang = gr.Dropdown(
91
  choices=["Hindi", "Telugu", "Spanish", "French", "German", "Japanese", "Arabic"],
92
  value="Hindi",
93
  label="Translation Target"
94
  )
95
-
96
  btn = gr.Button("πŸš€ Generate Studio MP3", variant="primary")
97
-
98
  with gr.Column(scale=1):
99
  audio_out = gr.Audio(label="Studio MP3 Output")
100
  t_out = gr.Textbox(label="Transcript", lines=5)
101
  tr_out = gr.Textbox(label="Translation", lines=5)
102
 
103
- btn.click(
104
- fn=run_pipeline,
105
- inputs=[audio_in, f, s, z, b, m, lang],
106
- outputs=[audio_out, t_out, tr_out]
107
- )
108
 
109
  if __name__ == "__main__":
110
  demo.launch()
 
25
  os.makedirs(out_dir, exist_ok=True)
26
 
27
  try:
28
+ # 1. CLEANING
29
  logger.info("[Step 1] Cleaning Audio...")
30
  res = denoiser.process(
31
  audio_input, out_dir,
 
36
  mouth_sounds=remove_mouth
37
  )
38
 
39
+ # 2. TRANSCRIPTION
40
  logger.info("[Step 2] Transcribing...")
41
  transcript_data = transcriber.transcribe(res['audio_path'])
42
 
43
+ # Safe Extraction Logic for the 'text' key
44
  if isinstance(transcript_data, dict):
45
  text = transcript_data.get('text', "")
 
 
46
  else:
47
  text = str(transcript_data)
48
 
49
  if remove_fillers:
50
  text = denoiser.clean_transcript_fillers(text)
51
 
52
+ # 3. TRANSLATION
53
  logger.info(f"[Step 3] Translating to {target_lang}...")
54
  translated = translator.translate(text, target_lang)
55
 
 
66
  logger.error(f"Pipeline crashed: {e}")
67
  return None, f"Error: {str(e)}", ""
68
 
 
 
 
69
  with gr.Blocks(title="ClearWave AI Studio") as demo:
70
  gr.Markdown("# πŸŽ™οΈ ClearWave AI Studio")
71
  gr.Markdown("Upload any recording. Receive a professional MP3, Transcript, and Translation.")
 
73
  with gr.Row():
74
  with gr.Column(scale=1):
75
  audio_in = gr.Audio(label="Input Audio (WhatsApp, AAC, WAV, MP3)", type="filepath")
 
76
  with gr.Group():
77
  gr.Markdown("### πŸ› οΈ Studio Cleaning Controls")
78
  f = gr.Checkbox(label="Remove Fillers", value=True)
 
80
  z = gr.Checkbox(label="Remove Long Silences", value=True)
81
  b = gr.Checkbox(label="Remove Breaths", value=True)
82
  m = gr.Checkbox(label="Remove Mouth Noises", value=True)
 
83
  lang = gr.Dropdown(
84
  choices=["Hindi", "Telugu", "Spanish", "French", "German", "Japanese", "Arabic"],
85
  value="Hindi",
86
  label="Translation Target"
87
  )
 
88
  btn = gr.Button("πŸš€ Generate Studio MP3", variant="primary")
 
89
  with gr.Column(scale=1):
90
  audio_out = gr.Audio(label="Studio MP3 Output")
91
  t_out = gr.Textbox(label="Transcript", lines=5)
92
  tr_out = gr.Textbox(label="Translation", lines=5)
93
 
94
+ btn.click(fn=run_pipeline, inputs=[audio_in, f, s, z, b, m, lang], outputs=[audio_out, t_out, tr_out])
 
 
 
 
95
 
96
  if __name__ == "__main__":
97
  demo.launch()