File size: 1,916 Bytes
00c92d1
 
 
 
 
 
9f5da27
 
00c92d1
124a1fb
00c92d1
 
 
124a1fb
 
00c92d1
124a1fb
9f5da27
 
 
 
124a1fb
00c92d1
 
 
 
 
 
124a1fb
 
 
 
 
bfed1fc
00c92d1
124a1fb
00c92d1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
55
56
# app.py
# =============
# This is a complete app.py file for an audio conversion app using Gradio and PyDub.

import gradio as gr
from pydub import AudioSegment
import os
from datetime import datetime

def convert_audio(file_path, volume_increase, bitrate):
    # Load the AAC file
    audio = AudioSegment.from_file(file_path, format="aac")
    
    # Increase the volume by the specified amount in dB
    audio = audio + volume_increase
    
    # Set the bitrate
    # Generate a unique filename to avoid overwriting
    timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
    output_filename = f"converted_{timestamp}.mp3"
    output_path = os.path.join(os.path.dirname(file_path), output_filename)
    audio.export(output_path, format="mp3", bitrate=f"{bitrate}k")
    
    return output_path

# Create the Gradio interface
iface = gr.Interface(
    fn=convert_audio,
    inputs=[
        gr.File(label="Upload AAC file"),
        gr.Slider(minimum=0, maximum=20, step=1, value=10, label="Volume Increase (dB)"),
        gr.Slider(minimum=32, maximum=320, step=8, value=64, label="Bitrate (kbps)")
    ],
    outputs=gr.Audio(label="Converted MP3 file", type="filepath"),
    title="AAC to MP3 Converter",
    description="Upload an AAC file, and it will be converted to MP3 with the specified volume increase and bitrate."
)

# Launch the Gradio app
if __name__ == "__main__":
    iface.launch()

# Dependencies
# =============
# The following dependencies are required to run this app:
# - gradio
# - pydub
# - ffmpeg (required by pydub for audio processing)
#
# You can install these dependencies using pip:
# pip install gradio pydub
#
# Note: ffmpeg is not a Python package but a system dependency. You can install it using your package manager:
# - On Ubuntu/Debian: sudo apt-get install ffmpeg
# - On macOS: brew install ffmpeg
# - On Windows: Download and install from https://ffmpeg.org/download.html