Spaces:
Paused
Paused
Initial setup: Add Stable Audio Gradio app with interface, requirements, and updated README
Browse filesFiles changed (3)
- README.md+51-4
- app.pyAdded+110
- requirements.txtAdded+7
123456789101112---title: Stable Audio Openemoji: πcolorFrom: greencolorTo: redsdk: gradiosdk_version: 6.2.0app_file: app.pypinned: false---Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859---title: Stable Audio Openemoji: π΅colorFrom: bluecolorTo: purplesdk: gradiosdk_version: 6.2.0app_file: app.pypinned: false---# π΅ Stable Audio OpenAn open-source web interface for generating high-quality audio from text prompts using advanced AI models. Create music, sound effects, ambient sounds, and more with simple text descriptions.## Features- πΌ **Text-to-Audio Generation**: Convert text prompts into audio- ποΈ **Customizable Duration**: Generate audio from 1-30 seconds- π² **Reproducible Results**: Use seeds for consistent generation- π§ **Real-time Playback**: Listen to generated audio instantly- π **Example Prompts**: Pre-built examples to get you started## Usage1. Enter a text description of the audio you want to generate2. Adjust the duration slider (1-30 seconds)3. Optionally set a random seed for reproducible results4. Click "Generate Audio" to create your sound## Examples- "A gentle piano melody playing in a cozy room"- "Upbeat electronic dance music with synthesizers"- "Rain falling on a tin roof with distant thunder"- "Classical violin concerto with orchestra accompaniment"## Technical DetailsThis application uses:- **Gradio** for the web interface- **PyTorch** and **Transformers** for AI model integration- **Stable Audio** technology for high-quality audio generation## ContributingThis is an open-source project. Contributions are welcome! Feel free to:- Report bugs and issues- Suggest new features- Submit pull requests- Improve documentation## LicenseThis project is open source and available under the MIT License.---*Built with β€οΈ using Hugging Face Spaces and Gradio*
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110import gradio as grimport torchimport numpy as npfrom transformers import pipelineimport scipy.io.wavfile as wavfileimport io
# Initialize the audio generation pipeline# Note: This is a placeholder - you'll need to integrate with actual Stable Audio modeldef create_audio_generation_interface(): """ Create a Gradio interface for Stable Audio generation """
def generate_audio(prompt, duration, seed): """ Generate audio based on text prompt This is a placeholder function - replace with actual Stable Audio model """ try: # Placeholder implementation # In a real implementation, you would: # 1. Load the Stable Audio model # 2. Process the text prompt # 3. Generate audio # 4. Return the audio file
# For now, return a simple sine wave as placeholder sample_rate = 44100 duration_samples = int(duration * sample_rate) frequency = 440 # A4 note
t = np.linspace(0, duration, duration_samples, endpoint=False) audio = 0.5 * np.sin(2 * np.pi * frequency * t)
# Convert to 16-bit PCM audio_int16 = (audio * 32767).astype(np.int16)
# Save to bytes buffer buffer = io.BytesIO() wavfile.write(buffer, sample_rate, audio_int16) buffer.seek(0)
return (sample_rate, audio)
except Exception as e: return f"Error generating audio: {str(e)}"
# Create the Gradio interface with gr.Blocks(title="Stable Audio Open", theme=gr.themes.Soft()) as interface: gr.Markdown(""" # π΅ Stable Audio Open Generate high-quality audio from text prompts using Stable Audio technology.
**Note:** This is a demo interface. The actual Stable Audio model integration is coming soon. """)
with gr.Row(): with gr.Column(): prompt_input = gr.Textbox( label="Text Prompt", placeholder="Describe the audio you want to generate...", lines=3, value="A gentle piano melody playing in a cozy room" )
duration_input = gr.Slider( label="Duration (seconds)", minimum=1, maximum=30, value=10, step=1 )
seed_input = gr.Number( label="Random Seed (optional)", value=None, precision=0 )
generate_btn = gr.Button("π΅ Generate Audio", variant="primary")
with gr.Column(): audio_output = gr.Audio(label="Generated Audio") status_output = gr.Textbox(label="Status", interactive=False)
# Connect the generate button to the function generate_btn.click( fn=generate_audio, inputs=[prompt_input, duration_input, seed_input], outputs=[audio_output, status_output] )
# Add some example prompts gr.Examples( examples=[ ["A calming ocean wave sound with seagulls", 15, 42], ["Upbeat electronic dance music", 20, 123], ["Classical violin concerto", 25, 999], ["Rain falling on a tin roof", 10, 777] ], inputs=[prompt_input, duration_input, seed_input] )
return interface
# Launch the interfaceif __name__ == "__main__": interface = create_audio_generation_interface() interface.launch()1234567gradio>=4.0.0torch>=2.0.0transformers>=4.30.0numpy>=1.21.0scipy>=1.7.0accelerate>=0.20.0diffusers>=0.20.0README.md+51-4
app.pyAdded+110
requirements.txtAdded+7