Spaces:
				
			
			
	
			
			
		Build error
		
	
	
	
			
			
	
	
	
	
		
		
		Build error
		
	Commit 
							
							·
						
						0f1b90d
	
1
								Parent(s):
							
							c879373
								
QOL UI improvements
Browse files- Swapping the output from audio to waveform video 
- Shrink the text on the top session, move some of that under the application and leave just the essential on top
- Bug-fix: the duplicate badge was referencing the old Space
- app_batched.py +22 -22
    	
        app_batched.py
    CHANGED
    
    | @@ -58,7 +58,9 @@ def predict(texts, melodies): | |
| 58 | 
             
                for output in outputs:
         | 
| 59 | 
             
                    with NamedTemporaryFile("wb", suffix=".wav", delete=False) as file:
         | 
| 60 | 
             
                        audio_write(file.name, output, MODEL.sample_rate, strategy="loudness", add_suffix=False)
         | 
| 61 | 
            -
                         | 
|  | |
|  | |
| 62 | 
             
                return [out_files]
         | 
| 63 |  | 
| 64 |  | 
| @@ -67,35 +69,23 @@ with gr.Blocks() as demo: | |
| 67 | 
             
                    """
         | 
| 68 | 
             
                    # MusicGen
         | 
| 69 |  | 
| 70 | 
            -
                    This is the demo for MusicGen, a simple and controllable model for music generation
         | 
| 71 | 
            -
                    presented at: "Simple and Controllable Music Generation".
         | 
| 72 | 
            -
             | 
| 73 | 
            -
                    Enter the description of the music you want and an optional audio used for melody conditioning.
         | 
| 74 | 
            -
                    The model will extract the broad melody from the uploaded wav if provided.
         | 
| 75 | 
            -
                    This will generate a 12s extract with the `melody` model.
         | 
| 76 | 
            -
             | 
| 77 | 
            -
                    For generating longer sequences (up to 30 seconds) and skipping queue, you can duplicate
         | 
| 78 | 
            -
                    to full demo space, which contains more control and upgrade to GPU in the settings.
         | 
| 79 | 
             
                    <br/>
         | 
| 80 | 
            -
                    <a href="https://huggingface.co/spaces/ | 
| 81 | 
            -
                    <img style="margin- | 
| 82 | 
            -
                    </p>
         | 
| 83 | 
            -
             | 
| 84 | 
            -
                    You can also use your own GPU or a Google Colab by following the instructions on our repo.
         | 
| 85 | 
            -
             | 
| 86 | 
            -
                    See [github.com/facebookresearch/audiocraft](https://github.com/facebookresearch/audiocraft)
         | 
| 87 | 
            -
                    for more details.
         | 
| 88 | 
             
                    """
         | 
| 89 | 
             
                )
         | 
| 90 | 
             
                with gr.Row():
         | 
| 91 | 
             
                    with gr.Column():
         | 
| 92 | 
             
                        with gr.Row():
         | 
| 93 | 
            -
                            text = gr.Text(label=" | 
| 94 | 
            -
                            melody = gr.Audio(source="upload", type="numpy", label=" | 
| 95 | 
             
                        with gr.Row():
         | 
| 96 | 
            -
                            submit = gr.Button(" | 
| 97 | 
             
                    with gr.Column():
         | 
| 98 | 
            -
                        output = gr. | 
| 99 | 
             
                submit.click(predict, inputs=[text, melody], outputs=[output], batch=True, max_batch_size=12)
         | 
| 100 | 
             
                gr.Examples(
         | 
| 101 | 
             
                    fn=predict,
         | 
| @@ -124,5 +114,15 @@ with gr.Blocks() as demo: | |
| 124 | 
             
                    inputs=[text, melody],
         | 
| 125 | 
             
                    outputs=[output]
         | 
| 126 | 
             
                )
         | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 127 |  | 
| 128 | 
             
            demo.queue(max_size=15).launch()
         | 
|  | |
| 58 | 
             
                for output in outputs:
         | 
| 59 | 
             
                    with NamedTemporaryFile("wb", suffix=".wav", delete=False) as file:
         | 
| 60 | 
             
                        audio_write(file.name, output, MODEL.sample_rate, strategy="loudness", add_suffix=False)
         | 
| 61 | 
            +
                        waveform_video = gr.make_waveform(file.name)
         | 
| 62 | 
            +
                        out_files.append(waveform_video)
         | 
| 63 | 
            +
                print(out_files)
         | 
| 64 | 
             
                return [out_files]
         | 
| 65 |  | 
| 66 |  | 
|  | |
| 69 | 
             
                    """
         | 
| 70 | 
             
                    # MusicGen
         | 
| 71 |  | 
| 72 | 
            +
                    This is the demo for [MusicGen](https://github.com/facebookresearch/audiocraft), a simple and controllable model for music generation
         | 
| 73 | 
            +
                    presented at: ["Simple and Controllable Music Generation"](https://huggingface.co/papers/2306.05284).
         | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 74 | 
             
                    <br/>
         | 
| 75 | 
            +
                    <a href="https://huggingface.co/spaces/facebook/MusicGen?duplicate=true" style="display: inline-block;margin-top: .5em;margin-right: .25em;" target="_blank">
         | 
| 76 | 
            +
                    <img style="margin-bottom: 0em;display: inline;margin-top: -.25em;" src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a>
         | 
| 77 | 
            +
                    for longer sequences, more control and no queue</p>
         | 
|  | |
|  | |
|  | |
|  | |
|  | |
| 78 | 
             
                    """
         | 
| 79 | 
             
                )
         | 
| 80 | 
             
                with gr.Row():
         | 
| 81 | 
             
                    with gr.Column():
         | 
| 82 | 
             
                        with gr.Row():
         | 
| 83 | 
            +
                            text = gr.Text(label="Describe your music", lines=2, interactive=True)
         | 
| 84 | 
            +
                            melody = gr.Audio(source="upload", type="numpy", label="Condition on a melody (optional)", interactive=True)
         | 
| 85 | 
             
                        with gr.Row():
         | 
| 86 | 
            +
                            submit = gr.Button("Generate")
         | 
| 87 | 
             
                    with gr.Column():
         | 
| 88 | 
            +
                        output = gr.Video(label="Generated Music")
         | 
| 89 | 
             
                submit.click(predict, inputs=[text, melody], outputs=[output], batch=True, max_batch_size=12)
         | 
| 90 | 
             
                gr.Examples(
         | 
| 91 | 
             
                    fn=predict,
         | 
|  | |
| 114 | 
             
                    inputs=[text, melody],
         | 
| 115 | 
             
                    outputs=[output]
         | 
| 116 | 
             
                )
         | 
| 117 | 
            +
                gr.Markdown("""
         | 
| 118 | 
            +
                ### More details
         | 
| 119 | 
            +
                By typing a description of the music you want and an optional audio used for melody conditioning,
         | 
| 120 | 
            +
                the model will extract the broad melody from the uploaded wav if provided and generate a 12s extract with the `melody` model.
         | 
| 121 | 
            +
              
         | 
| 122 | 
            +
                You can also use your own GPU or a Google Colab by following the instructions on our repo.
         | 
| 123 | 
            +
             | 
| 124 | 
            +
                See [github.com/facebookresearch/audiocraft](https://github.com/facebookresearch/audiocraft)
         | 
| 125 | 
            +
                for more details.
         | 
| 126 | 
            +
                """)
         | 
| 127 |  | 
| 128 | 
             
            demo.queue(max_size=15).launch()
         | 
 
			

