Update app.py
Browse files
app.py
CHANGED
|
@@ -15,17 +15,16 @@ def generate_music(description):
|
|
| 15 |
# Generate music based on the provided description
|
| 16 |
wav = model.generate([description])
|
| 17 |
|
| 18 |
-
#
|
| 19 |
-
|
| 20 |
|
| 21 |
-
# Return the
|
| 22 |
-
return wav[0].cpu().numpy()
|
| 23 |
|
| 24 |
# Define a Gradio interface
|
| 25 |
iface = gr.Interface(
|
| 26 |
fn=generate_music, # Use the generate_music function for processing input
|
| 27 |
inputs="text", # Accept text input from the user
|
| 28 |
-
outputs="
|
| 29 |
title="Music Generation from Descriptions", # Set the title of the web interface
|
| 30 |
description="Generate music based on descriptions.", # Provide a description
|
| 31 |
live=False # Set to False if you don't want real-time updates (for beginner-friendly interaction)
|
|
|
|
| 15 |
# Generate music based on the provided description
|
| 16 |
wav = model.generate([description])
|
| 17 |
|
| 18 |
+
# Convert the audio waveform to a format that Gradio can display
|
| 19 |
+
audio_data = wav[0].cpu().numpy().tobytes()
|
| 20 |
|
| 21 |
+
return audio_data # Return the audio data
|
|
|
|
| 22 |
|
| 23 |
# Define a Gradio interface
|
| 24 |
iface = gr.Interface(
|
| 25 |
fn=generate_music, # Use the generate_music function for processing input
|
| 26 |
inputs="text", # Accept text input from the user
|
| 27 |
+
outputs=gr.Audio(type="numpy", label="Audio"), # Display the generated audio as output
|
| 28 |
title="Music Generation from Descriptions", # Set the title of the web interface
|
| 29 |
description="Generate music based on descriptions.", # Provide a description
|
| 30 |
live=False # Set to False if you don't want real-time updates (for beginner-friendly interaction)
|