bdc-divya commited on
Commit
8b1f069
·
1 Parent(s): 2b03e6f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
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
- # # Save the generated audio as "output.wav" with loudness normalization at -14 dB LUFS.
19
- # audio_write("output.wav", wav[0].cpu(), model.sample_rate, strategy="loudness")
20
 
21
- # Return the generated audio for playback
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="audio", # Specify "audio" to indicate streaming audio output
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)