Spaces:
Sleeping

File size: 2,005 Bytes
ef890be
 
 
 
6ebd8cd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), "src"))

import gradio as gr
from trimly import trim_audio, clean_tmp

clean_tmp()

with gr.Blocks(
    title="Trimly",
    theme=gr.themes.Soft(primary_hue="teal", secondary_hue="teal", neutral_hue="slate"),
    css="""
    @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap');
    body, .gradio-container {font-family: 'Poppins', sans-serif;}
    .gradio-container {padding: 2rem;}
    """
) as demo:

    gr.Markdown("""
    ## Trimly 
    **Clean up your voiceovers by removing dead air and long pauses using FFmpeg.**
    """)

    with gr.Row():
        with gr.Column():
            audio_input = gr.Audio(label="Upload MP3 or WAV", type="filepath")
            threshold = gr.Slider(-60, 0, value=-45, step=1, label="Silence Threshold (dB)")
            min_silence = gr.Slider(0.01, 1.0, value=0.05, step=0.01, label="Min Silence Duration (sec)")
            trim_btn = gr.Button("Submit", variant="primary")
            status = gr.Markdown("")

        with gr.Column():
            audio_output = gr.Audio(label="Trimmed Output", type="filepath", interactive=False, show_download_button=True)
            
            gr.Markdown("""
            ### 🛠️ How It Works
            This tool uses FFmpeg's `silenceremove` filter to trim silent sections from your voiceover.

            - **Silence Threshold**: Controls what is considered "silence". Lower = more aggressive.
            - **Min Silence Duration**: Minimum pause length (in seconds) before trimming kicks in.
            - **Output**: Enhanced audio is saved in the `tmp/` folder and auto-deleted on app restart.

            ⚡ _Built for voiceovers, audiobooks, and content creators who hate dead air._
            """)

    trim_btn.click(
        fn=trim_audio,
        inputs=[audio_input, threshold, min_silence],
        outputs=[status, audio_output]
    )

demo.queue().launch(inbrowser=True)