Ivan000 commited on
Commit
00c92d1
·
verified ·
1 Parent(s): 9143bc9

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +47 -0
app.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py
2
+ # =============
3
+ # This is a complete app.py file for an audio conversion app using Gradio and PyDub.
4
+
5
+ import gradio as gr
6
+ from pydub import AudioSegment
7
+
8
+ def convert_audio(file_path):
9
+ # Load the AAC file
10
+ audio = AudioSegment.from_file(file_path, format="aac")
11
+
12
+ # Increase the volume by 10 dB
13
+ audio = audio + 10
14
+
15
+ # Set the bitrate to 64 kbps
16
+ output_path = file_path.replace(".aac", "_converted.mp3")
17
+ audio.export(output_path, format="mp3", bitrate="64k")
18
+
19
+ return output_path
20
+
21
+ # Create the Gradio interface
22
+ iface = gr.Interface(
23
+ fn=convert_audio,
24
+ inputs=gr.File(label="Upload AAC file"),
25
+ outputs=gr.File(label="Download converted MP3 file"),
26
+ title="AAC to MP3 Converter",
27
+ description="Upload an AAC file, and it will be converted to MP3 with increased volume and a specified bitrate."
28
+ )
29
+
30
+ # Launch the Gradio app
31
+ if __name__ == "__main__":
32
+ iface.launch()
33
+
34
+ # Dependencies
35
+ # =============
36
+ # The following dependencies are required to run this app:
37
+ # - gradio
38
+ # - pydub
39
+ # - ffmpeg (required by pydub for audio processing)
40
+ #
41
+ # You can install these dependencies using pip:
42
+ # pip install gradio pydub
43
+ #
44
+ # Note: ffmpeg is not a Python package but a system dependency. You can install it using your package manager:
45
+ # - On Ubuntu/Debian: sudo apt-get install ffmpeg
46
+ # - On macOS: brew install ffmpeg
47
+ # - On Windows: Download and install from https://ffmpeg.org/download.html