Update app.py
Browse files
app.py
CHANGED
|
@@ -18,8 +18,12 @@ try:
|
|
| 18 |
except Exception as e:
|
| 19 |
st.error(f"Failed to load audio: {e}")
|
| 20 |
|
| 21 |
-
# Step 2:
|
| 22 |
-
st.subheader("Step 2:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
prompt = st.text_input("Enter music description (e.g. energetic trap beat with dark mood)",
|
| 24 |
"emotional trap beat with dark pads and heavy drums")
|
| 25 |
|
|
@@ -33,15 +37,18 @@ if st.button("Generate Music"):
|
|
| 33 |
st.audio(output_path, format="audio/wav")
|
| 34 |
st.success("Music generation complete!")
|
| 35 |
|
| 36 |
-
# Step
|
| 37 |
-
st.subheader("Step
|
| 38 |
|
| 39 |
if os.path.exists("musicgen_output.wav"):
|
| 40 |
-
if st.button("Combine Voice +
|
| 41 |
try:
|
| 42 |
-
#
|
| 43 |
beat = AudioSegment.from_wav("musicgen_output.wav")
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
# Adjust volumes and overlay (to avoid distortion)
|
| 47 |
voice = voice - 4 # Reduce the voice volume
|
|
@@ -52,10 +59,13 @@ if os.path.exists("musicgen_output.wav"):
|
|
| 52 |
combined_path = "combined_output.mp3"
|
| 53 |
combined.export(combined_path, format="mp3")
|
| 54 |
|
| 55 |
-
# Play the combined audio
|
| 56 |
st.audio(combined_path, format="audio/mp3")
|
| 57 |
st.success("Combined output ready!")
|
| 58 |
except Exception as e:
|
| 59 |
st.error(f"Error while combining: {e}")
|
| 60 |
else:
|
| 61 |
st.info("Generate the music first to combine it with the voice.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
except Exception as e:
|
| 19 |
st.error(f"Failed to load audio: {e}")
|
| 20 |
|
| 21 |
+
# Step 2: User Input for Lyrics
|
| 22 |
+
st.subheader("Step 2: Enter Lyrics for AI Voice")
|
| 23 |
+
lyrics = st.text_area("Enter the lyrics you want to generate in the voice:", "Enter your lyrics here...")
|
| 24 |
+
|
| 25 |
+
# Generate Instrumental with MusicGen
|
| 26 |
+
st.subheader("Step 3: Generate Instrumental with MusicGen")
|
| 27 |
prompt = st.text_input("Enter music description (e.g. energetic trap beat with dark mood)",
|
| 28 |
"emotional trap beat with dark pads and heavy drums")
|
| 29 |
|
|
|
|
| 37 |
st.audio(output_path, format="audio/wav")
|
| 38 |
st.success("Music generation complete!")
|
| 39 |
|
| 40 |
+
# Step 4: Combine Lyrics with AI Voice and Instrumental (Simulated)
|
| 41 |
+
st.subheader("Step 4: Simulated Combination of Lyrics, Voice, and Instrumental")
|
| 42 |
|
| 43 |
if os.path.exists("musicgen_output.wav"):
|
| 44 |
+
if st.button("Generate and Combine Voice + Music with Lyrics"):
|
| 45 |
try:
|
| 46 |
+
# Here we will use a voice sample and overlay the lyrics onto the instrumental
|
| 47 |
beat = AudioSegment.from_wav("musicgen_output.wav")
|
| 48 |
+
|
| 49 |
+
# For this example, we will use a male voice sample and overlay the lyrics
|
| 50 |
+
# Simulating the AI voice generation for the lyrics
|
| 51 |
+
voice = AudioSegment.from_wav("StarWars60.wav") # Replace with real AI voice generation logic
|
| 52 |
|
| 53 |
# Adjust volumes and overlay (to avoid distortion)
|
| 54 |
voice = voice - 4 # Reduce the voice volume
|
|
|
|
| 59 |
combined_path = "combined_output.mp3"
|
| 60 |
combined.export(combined_path, format="mp3")
|
| 61 |
|
|
|
|
| 62 |
st.audio(combined_path, format="audio/mp3")
|
| 63 |
st.success("Combined output ready!")
|
| 64 |
except Exception as e:
|
| 65 |
st.error(f"Error while combining: {e}")
|
| 66 |
else:
|
| 67 |
st.info("Generate the music first to combine it with the voice.")
|
| 68 |
+
|
| 69 |
+
# Step 5: Show Lyrics Input (Optional for View)
|
| 70 |
+
if lyrics:
|
| 71 |
+
st.write(f"**Lyrics Entered**:\n{lyrics}")
|