Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import os
|
| 3 |
import subprocess
|
| 4 |
-
import soundfile as sf
|
| 5 |
import logging
|
| 6 |
from datetime import datetime
|
| 7 |
|
|
@@ -43,8 +42,6 @@ def run_pipeline(audio_input, remove_fillers, remove_stutters, remove_silences,
|
|
| 43 |
|
| 44 |
# Step 2: Transcription (Department 2)
|
| 45 |
logger.info("[Pipeline] Step 2/3 β Transcribing with Groq...")
|
| 46 |
-
# Note: We transcribe the original input for better context,
|
| 47 |
-
# or denoise_result['audio_path'] for cleaner text.
|
| 48 |
transcript_data = transcriber.transcribe(denoise_result['audio_path'])
|
| 49 |
final_transcript = transcript_data['text']
|
| 50 |
|
|
@@ -57,13 +54,12 @@ def run_pipeline(audio_input, remove_fillers, remove_stutters, remove_silences,
|
|
| 57 |
translated_text = translator.translate(final_transcript, target_lang)
|
| 58 |
|
| 59 |
# FINAL STEP: Ensure the output audio is high-quality MP3
|
| 60 |
-
# We use ffmpeg to convert the processed WAV from Cleanvoice to MP3
|
| 61 |
final_mp3_path = os.path.join(output_dir, "ClearWave_Final.mp3")
|
| 62 |
|
| 63 |
subprocess.run([
|
| 64 |
"ffmpeg", "-y", "-i", denoise_result['audio_path'],
|
| 65 |
"-codec:a", "libmp3lame",
|
| 66 |
-
"-qscale:a", "2",
|
| 67 |
final_mp3_path
|
| 68 |
], capture_output=True, check=True)
|
| 69 |
|
|
@@ -74,11 +70,11 @@ def run_pipeline(audio_input, remove_fillers, remove_stutters, remove_silences,
|
|
| 74 |
return None, f"Error: {str(e)}", ""
|
| 75 |
|
| 76 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 77 |
-
# GRADIO UI ARCHITECTURE
|
| 78 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 79 |
-
with gr.Blocks(
|
| 80 |
gr.Markdown("# ποΈ ClearWave AI Studio")
|
| 81 |
-
gr.Markdown("Transform raw recordings into studio-quality MP3s
|
| 82 |
|
| 83 |
with gr.Row():
|
| 84 |
with gr.Column(scale=1):
|
|
@@ -86,7 +82,7 @@ with gr.Blocks(theme=gr.themes.Soft(), title="ClearWave AI Studio") as demo:
|
|
| 86 |
|
| 87 |
with gr.Group():
|
| 88 |
gr.Markdown("### π οΈ Audio Cleaning Settings")
|
| 89 |
-
f_check = gr.Checkbox(label="Remove Fillers
|
| 90 |
s_check = gr.Checkbox(label="Remove Stutters", value=True)
|
| 91 |
z_check = gr.Checkbox(label="Remove Long Silences", value=True)
|
| 92 |
b_check = gr.Checkbox(label="Remove Breaths", value=True)
|
|
@@ -102,8 +98,10 @@ with gr.Blocks(theme=gr.themes.Soft(), title="ClearWave AI Studio") as demo:
|
|
| 102 |
|
| 103 |
with gr.Column(scale=1):
|
| 104 |
audio_output = gr.Audio(label="Cleaned Audio (MP3)", type="filepath")
|
| 105 |
-
|
| 106 |
-
|
|
|
|
|
|
|
| 107 |
|
| 108 |
process_btn.click(
|
| 109 |
fn=run_pipeline,
|
|
@@ -112,4 +110,5 @@ with gr.Blocks(theme=gr.themes.Soft(), title="ClearWave AI Studio") as demo:
|
|
| 112 |
)
|
| 113 |
|
| 114 |
if __name__ == "__main__":
|
| 115 |
-
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import os
|
| 3 |
import subprocess
|
|
|
|
| 4 |
import logging
|
| 5 |
from datetime import datetime
|
| 6 |
|
|
|
|
| 42 |
|
| 43 |
# Step 2: Transcription (Department 2)
|
| 44 |
logger.info("[Pipeline] Step 2/3 β Transcribing with Groq...")
|
|
|
|
|
|
|
| 45 |
transcript_data = transcriber.transcribe(denoise_result['audio_path'])
|
| 46 |
final_transcript = transcript_data['text']
|
| 47 |
|
|
|
|
| 54 |
translated_text = translator.translate(final_transcript, target_lang)
|
| 55 |
|
| 56 |
# FINAL STEP: Ensure the output audio is high-quality MP3
|
|
|
|
| 57 |
final_mp3_path = os.path.join(output_dir, "ClearWave_Final.mp3")
|
| 58 |
|
| 59 |
subprocess.run([
|
| 60 |
"ffmpeg", "-y", "-i", denoise_result['audio_path'],
|
| 61 |
"-codec:a", "libmp3lame",
|
| 62 |
+
"-qscale:a", "2",
|
| 63 |
final_mp3_path
|
| 64 |
], capture_output=True, check=True)
|
| 65 |
|
|
|
|
| 70 |
return None, f"Error: {str(e)}", ""
|
| 71 |
|
| 72 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 73 |
+
# GRADIO UI ARCHITECTURE (Gradio 6.0 Optimized)
|
| 74 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 75 |
+
with gr.Blocks(title="ClearWave AI Studio") as demo:
|
| 76 |
gr.Markdown("# ποΈ ClearWave AI Studio")
|
| 77 |
+
gr.Markdown("Transform raw recordings into studio-quality MP3s.")
|
| 78 |
|
| 79 |
with gr.Row():
|
| 80 |
with gr.Column(scale=1):
|
|
|
|
| 82 |
|
| 83 |
with gr.Group():
|
| 84 |
gr.Markdown("### π οΈ Audio Cleaning Settings")
|
| 85 |
+
f_check = gr.Checkbox(label="Remove Fillers", value=True)
|
| 86 |
s_check = gr.Checkbox(label="Remove Stutters", value=True)
|
| 87 |
z_check = gr.Checkbox(label="Remove Long Silences", value=True)
|
| 88 |
b_check = gr.Checkbox(label="Remove Breaths", value=True)
|
|
|
|
| 98 |
|
| 99 |
with gr.Column(scale=1):
|
| 100 |
audio_output = gr.Audio(label="Cleaned Audio (MP3)", type="filepath")
|
| 101 |
+
# In Gradio 6.0, copy button is enabled via 'show_copy_button' in some versions,
|
| 102 |
+
# but if it fails, we use the standard Textbox
|
| 103 |
+
transcript_output = gr.Textbox(label="Cleaned Transcript", lines=5)
|
| 104 |
+
translation_output = gr.Textbox(label="Translation", lines=5)
|
| 105 |
|
| 106 |
process_btn.click(
|
| 107 |
fn=run_pipeline,
|
|
|
|
| 110 |
)
|
| 111 |
|
| 112 |
if __name__ == "__main__":
|
| 113 |
+
# Theme is now passed here in Gradio 6.0
|
| 114 |
+
demo.launch(theme=gr.themes.Soft())
|