openvinotoolkit / openvino_notebooks

📚 Jupyter notebook tutorials for OpenVINO™
Apache License 2.0
2.3k stars 791 forks source link

Sangeet Guru #2257

Closed TABREZ-96 closed 3 weeks ago

TABREZ-96 commented 1 month ago

The Sangeet Guru app is a music generation tool that allows users to input a description of their desired music style and receive a generated audio clip based on their prompt. The app features a streamlined interface with a small logo, title, input field, and example prompts for user convenience.

File Breakdown main.py:

Imports: The script imports necessary libraries and modules including streamlit for the web interface, fastapi for creating an API, pydantic for request validation, and uvicorn for running the FastAPI server. FastAPI Setup: Defines an API endpoint /generate-audio/ that accepts a TextPrompt containing a music style description. It uses the generate_adu module to process the request and return generated audio. Streamlit Interface: Logo: Loads and displays a small logo image before the title. Title & Input: Displays the app's title "Sangeet Guru" and a text input field for users to enter their music style description. Generate Button: On clicking the "Generate" button, the app calls the generate_adu.generate function to produce audio based on the entered prompt. Example Prompts: Provides several example music styles as clickable buttons. Clicking on any example automatically generates and plays the corresponding audio. Run Function: Depending on the uncommented line, the script can run either the FastAPI server or the Streamlit app. generate_adu.py:

Imports: Includes libraries such as transformers for model and processor, torch for tensor operations, and BytesIO and scipy for handling audio data. Model & Processor Initialization: Loads the MusicgenForConditionalGeneration model and AutoProcessor from the facebook/musicgen-small pre-trained model. generate Function: Processing Input: Uses the processor to convert the text prompt into tensors. Generating Audio: Passes the tensors to the model to generate audio based on the input prompt. Audio Conversion: Converts the generated audio from a numpy array to a BytesIO object, which is then returned. music_logo.png:

Logo Image: A small image file representing the app’s logo. This image should be placed in the same directory as main.py and is displayed at the top of the Streamlit interface. Usage Instructions Running the App: To run the FastAPI server, uncomment the run_fastapi() line and comment out the run_streamlit() line. To run the Streamlit interface, uncomment the run_streamlit() line and comment out the run_fastapi() line. Generating Music: Users can input a description of their desired music style or click on one of the example prompts to generate and play a corresponding music track. This setup provides a user-friendly interface for generating music based on textual descriptions and demonstrates the integration of FastAPI and Streamlit for a seamless user experience.

brmarkus commented 1 month ago

Do you want to add a Jupyter notebook for an interactive way to use the suggested application (as part of the "openvino notebooks")? Within the notbook you could also add sample input prompts and showing an example output? You could even use an audio player within the Jupyter notebook, so that a user can listen to the results. Can you provide a README.md as well, with screenshots, and/or animated GIFs?

TABREZ-96 commented 1 month ago

@brmarkus I have created a webapp which users can try it out directtly without the need of notebook here is an intervative image : image

github-actions[bot] commented 1 month ago

This PR will be closed in a week because of 2 weeks of no activity.

github-actions[bot] commented 3 weeks ago

This PR was closed because it has been stalled for 2 week with no activity.