Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,8 @@
|
|
4 |
|
5 |
import gradio as gr
|
6 |
from pydub import AudioSegment
|
|
|
|
|
7 |
|
8 |
def convert_audio(file_path, volume_increase, bitrate):
|
9 |
# Load the AAC file
|
@@ -13,7 +15,10 @@ def convert_audio(file_path, volume_increase, bitrate):
|
|
13 |
audio = audio + volume_increase
|
14 |
|
15 |
# Set the bitrate
|
16 |
-
|
|
|
|
|
|
|
17 |
audio.export(output_path, format="mp3", bitrate=f"{bitrate}k")
|
18 |
|
19 |
return output_path
|
|
|
4 |
|
5 |
import gradio as gr
|
6 |
from pydub import AudioSegment
|
7 |
+
import os
|
8 |
+
from datetime import datetime
|
9 |
|
10 |
def convert_audio(file_path, volume_increase, bitrate):
|
11 |
# Load the AAC file
|
|
|
15 |
audio = audio + volume_increase
|
16 |
|
17 |
# Set the bitrate
|
18 |
+
# Generate a unique filename to avoid overwriting
|
19 |
+
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
20 |
+
output_filename = f"converted_{timestamp}.mp3"
|
21 |
+
output_path = os.path.join(os.path.dirname(file_path), output_filename)
|
22 |
audio.export(output_path, format="mp3", bitrate=f"{bitrate}k")
|
23 |
|
24 |
return output_path
|