flowese / UdioWrapper

UdioWrapper is a Python package that enables the generation of music tracks using Udio's API through textual prompts. This package is based on the reverse engineering of the Udio API (https://www.udio.com/) and is not officially endorsed by Udio.
MIT License
128 stars 23 forks source link

Udio Wrapper

Udio Wrapper

Written by @Flowese

Open Demo In Colab

Description

udio_wrapper is a Python package that allows you to generate music tracks from Udio's API using textual prompts. This package is designed to interact with Udio's API and is not officially endorsed by Udio.

Advantages Over Other Models

Unlike other music generation models, Udio offers a unique feature of extending or conditioning new tracks based on existing ones, making it ideal for iterative and creative music production processes.

Legal Disclaimer

This package is created for educational and research purposes. By using this package, you agree to do so at your own risk. This package is not affiliated, endorsed, or sponsored by Udio in any way.

Requirements

Installation

From PyPI

To install the package from PyPI, run the following command:

pip install udio_wrapper

To upgrade the package from PyPI, run the following command:

pip install --upgrade --no-cache-dir udio_wrapper

From GitHub Repository

To install the package directly from the GitHub repository, run:

pip install git+https://github.com/flowese/UdioWrapper.git

Configuration

Obtaining the Authorization Token

  1. Sign up at Udio.
  2. Once registered, open your browser's inspector:
    • In Chrome: Ctrl+Shift+I or F12 on Windows, Cmd+Option+I on Mac.
  3. Go to the Application tab.
  4. On the left panel, locate and click on Cookies, then select the Ideogram website.
  5. Find the cookie named sb-api-auth-token.
  6. Click on sb-api-auth-token and copy the value in the Value field.

Udio Wrapper

Usage

To use udio_wrapper, import the UdioWrapper class and provide the necessary parameters.

Usage Examples

The following examples demonstrate various ways to use the UdioWrapper to generate music based on different scenarios:

auth_token = "your-auth-token-here"  # Replace this with your actual authentication token
udio_wrapper = UdioWrapper(auth_token)
  1. Creating a Short Song You can specify the prompt, seed, custom lyrics.

short_song_no_download = udio_wrapper.create_song( prompt="Relaxing jazz and soulful music", seed=-1, custom_lyrics="Short song lyrics here" ) print("Short song generated without downloading:", short_song_no_download)

2. Extending a Song
Extend a previously created song by providing its path and ID for conditioning. This method also allows for lyric customization.
```python

extend_song_download = udio_wrapper.extend(
    prompt="A dynamic version of relaxing jazz and soulful music",
    seed=-1,
    audio_conditioning_path="url-generated-song",
    audio_conditioning_song_id="previous-song-id",
    custom_lyrics="Extended version lyrics"
)
print("Extended song generated and downloaded:", extend_song_download)
  1. Adding an Outro Generate an outro for your music sequence using the last song as a base. This includes custom lyrics.

outro_song_download = udio_wrapper.add_outro( prompt="A smooth ending to our jazz session", seed=-1, audio_conditioning_path="url-generated-song", audio_conditioning_song_id="last-extended-song-id", custom_lyrics="Outro lyrics here" ) print("Outro song generated and downloaded:", outro_song_download)


4. Creating a Complete Song Sequence
Generate a full sequence of songs, including multiple extensions and an outro. This process involves defining prompts and lyrics for each part of the sequence.
```python
complete_song_sequence = udio_wrapper.create_complete_song(
    short_prompt="On a full moon night",
    extend_prompts=["the soft sound of the saxophone fills the air", "creating an atmosphere of mystery and romance"],
    outro_prompt="Thus ends this melody, leaving an echo of emotions in the heart",
    num_extensions=2,
    custom_lyrics_short="Short song lyrics here",
    custom_lyrics_extend=["Lyrics for first extension", "Lyrics for second extension"],
    custom_lyrics_outro="Outro lyrics here"
)
print("Complete song sequence generated and downloaded:", complete_song_sequence)

Parameters

Each method in the UdioWrapper class can take several parameters to control song generation and processing. Below is a breakdown of the parameters and their usage:

These parameters allow full customization of the music generation process, from the initial creation through extensions to the final outro, giving users the ability to tailor both the music and lyrics to fit their specific needs or artistic vision.

License

This project is licensed under the MIT License.

Contributing

If you'd like to contribute to this project, feel free to fork the repository and send a pull request, or open an issue to discuss what you'd like to change. All contributions are welcome!

TODO

Pending Tasks and Features