maybthingsyouneverknow commited on
Commit
b12c126
1 Parent(s): 075c7ce

songremixer.py

Browse files

a code for remix song

Files changed (1) hide show
  1. app.py +50 -0
app.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from pydub import AudioSegment
3
+ import io
4
+ import numpy as np
5
+ import soundfile as sf
6
+
7
+ # Placeholder for actual remix transformation functions
8
+ def transform_audio(audio, genre):
9
+ # Load audio data
10
+ audio = AudioSegment.from_file(io.BytesIO(audio), format="wav")
11
+
12
+ # Here, we would apply genre-specific transformations
13
+ if genre == "Dubstep":
14
+ # Placeholder processing for Dubstep remix
15
+ audio = audio.low_pass_filter(300)
16
+ elif genre == "Drumstep":
17
+ # Placeholder processing for Drumstep remix
18
+ audio = audio.low_pass_filter(200).apply_gain(6)
19
+ elif genre == "Trap":
20
+ # Placeholder processing for Trap remix
21
+ audio = audio.low_pass_filter(400)
22
+ elif genre == "EDM":
23
+ # Placeholder processing for EDM remix
24
+ audio = audio.high_pass_filter(300)
25
+ elif genre == "DnB":
26
+ # Placeholder processing for Drum and Bass remix
27
+ audio = audio.low_pass_filter(350).apply_gain(3)
28
+ elif genre == "Colour Bass":
29
+ # Placeholder processing for Colour Bass remix
30
+ audio = audio.high_pass_filter(250).apply_gain(5)
31
+
32
+ # Convert back to wav format
33
+ buffer = io.BytesIO()
34
+ audio.export(buffer, format="wav")
35
+ return buffer.getvalue()
36
+
37
+ # Define Gradio interface
38
+ def remix_audio(file, genre):
39
+ audio_bytes = file.read()
40
+ output_audio = transform_audio(audio_bytes, genre)
41
+ return output_audio
42
+
43
+ # Setting up Gradio inputs and outputs
44
+ genre_options = ["Dubstep", "Drumstep", "Trap", "EDM", "DnB", "Colour Bass"]
45
+ inputs = [gr.Audio(source="upload", type="file"), gr.Dropdown(choices=genre_options, label="Choose Genre")]
46
+ outputs = gr.Audio(type="file")
47
+
48
+ # Launch Gradio app
49
+ gr.Interface(fn=remix_audio, inputs=inputs, outputs=outputs, title="Song Remix Tool",
50
+ description="Upload a song and choose a genre to remix it into Dubstep, Drumstep, Trap, EDM, DnB, or Colour Bass.").launch()