Giter VIP home page Giter VIP logo

melody_craft_ws's Introduction

MelodyCraftWS ๐ŸŽต

PyPI version

MelodyCraftWS is a Python package that combines the power of text-based melody generation with real-time notifications using WebSockets. This project demonstrates the magic of turning lyrics or text into beautiful melodies and keeping you informed about the progress.

๐Ÿš€ Features:

  • Generate melodies from text input.
  • Estimated duration based on the number of words and average WPM.
  • Real-time progress updates via WebSockets.
  • Send success or error notifications to the client.

Implementation Details ๐Ÿ› ๏ธ

This project is built using the following tools and libraries:

  • Flask: A micro web framework for building web applications.
  • Flask-SocketIO: A Flask extension for WebSockets.
  • Audiocraft: A Python library for music and audio generation.

Usage ๐Ÿ“ฆ

  1. Install the package via pip:
pip install MelodyCraftWS
  1. Create a Flask application and integrate the package to generate melodies and send WebSocket events.
# Import the necessary components and set up the MelodyCraftServer
from melodycraftWS.server.melody_craft_server import MelodyCraftServer

server = MelodyCraftServer()
  1. Start your application, and it's ready to generate melodies from text and send notifications in real-time.
if __name__ == '__main__':
    server.run(debug=True)

How to Generate Melodies ๐ŸŽถ

Send a POST request to the /generate_melody endpoint with the text parameter containing the lyrics or text you want to transform into a melody.

The estimated duration is calculated based on the text's word count and an average words per minute (WPM) rate.

The melody is generated using the Audiocraft library, and real-time updates are sent to the client via WebSockets.

Success or error notifications are sent depending on the outcome.

Client Component

The client component, MelodyCraftClient, connects to the MelodyCraft server, sends text input for melody generation, and receives the generated melodies. It also allows custom event listeners for additional functionality.

Step 1: Preparation of the Client

Ensure you have the MelodyCraftClient class defined in a file, such as melodycraft_client.py.

# melodycraft_client.py

from melodycraftWS.client.melody_craft_client import MelodyCraftClient

if __name__ == '__main__':
    # Replace 'server_url' and 'client_id' with the actual values
    server_url = 'http://your-server-url.com'
    client_id = 'your_client_id'

    # Create an instance of the MelodyCraftClient
    client = MelodyCraftClient(server_url, client_id)

    # Define a custom event listener for 'custom_event'
    def custom_event_handler(data):
        print('Custom Event Received:', data)

    # Add the custom event listener
    client.add_event_listener('custom_event', custom_event_handler)

    # Example usage: Generate a melody
    client.generate_melody('Text input for melody generation')

    # Wait for user input to exit
    input('Press Enter to disconnect...')
    client.disconnect()
Step 2: Running the Client

Open a separate terminal and navigate to the location of the melodycraft_client.py file. Run the client by executing the following command:

python melodycraft_client.py

This will start the client and connect to the server. You can use the client to generate melodies, receive custom events, and interact with the MelodyCraft server.

Make sure the values of 'server_url' and 'client_id' in the client file (melodycraft_client.py) are configured with the actual values corresponding to your server. You can also add or remove custom events and adjust the handling logic according to your needs.

License ๐Ÿ“œ

This project is licensed under the MIT License - see the LICENSE file for details.

Feel free to contribute, report issues, and make this project even better!

๐ŸŒŸ Enjoy creating melodies with MelodyCraftWS! ๐ŸŒŸ

melody_craft_ws's People

Contributors

sergio11 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.