UdioWrapper

repository·main·Indexed 41 days ago

https://github.com/flowese/udiowrapper

A Python package providing a wrapper around Udio's API to generate, extend, and sequence music tracks using textual prompts and custom lyrics. It includes functionality to create short songs, add outros, and generate complete song sequences via the UdioWrapper class.

Tokens
1.8K
Snippets
6
Records
7
Agent score
2%

What's inside UdioWrapper

  1. Install udio_wrapper

    main

    You can install the udio_wrapper package via PyPI or directly from the GitHub repository.

    From PyPI

    pip install udio_wrapper

    To upgrade to the latest version:

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

    From GitHub

    pip install git+https://github.com/flowese/UdioWrapper.git
  2. Obtain the Udio Authorization Token

    main

    To use the wrapper, you must provide an authentication token obtained from your Udio session:

    1. Sign up/log in at Udio.
    2. Open your browser's developer tools (Inspector):
      • Chrome/Windows: Ctrl+Shift+I or F12
      • Chrome/Mac: Cmd+Option+I
    3. Navigate to the Application tab.
    4. In the left panel, under Cookies, select the Udio website.
    5. Locate the cookie named sb-api-auth-token.
    6. Copy the value from the Value field. This is your auth_token.
  3. Generate a complete song sequence with create_complete_song()

    main

    Generate a full sequence including an initial short song, multiple extensions, and an outro in one call.

    Parameters:

    • short_prompt (str): Prompt for the initial track.
    • extend_prompts (list of str, optional): A list of prompts for each extension.
    • outro_prompt (str, optional): Prompt for the final outro.
    • num_extensions (int, optional): Number of extensions to generate. Default is 1.
    • custom_lyrics_short (str, optional): Lyrics for the first track.
    • custom_lyrics_extend (list of str, optional): A list of lyrics for each extension.
    • custom_lyrics_outro (str, optional): Lyrics for the outro.
    sequence = udio_wrapper.create_complete_song(
        short_prompt="On a full moon night",
        extend_prompts=["soft saxophone", "mystery atmosphere"],
        outro_prompt="The end",
        num_extensions=2,
        custom_lyrics_short="Lyrics 1",
        custom_lyrics_extend=["Lyrics 2", "Lyrics 3"],
        custom_lyrics_outro="Lyrics Outro"
    )
    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)
  4. Initialize the UdioWrapper class

    main

    To start using the library, import UdioWrapper and instantiate it with your auth_token.

    from udio_wrapper import UdioWrapper
    
    auth_token = "your-auth-token-here"  # Replace with your actual token
    udio_wrapper = UdioWrapper(auth_token)
    auth_token = "your-auth-token-here"
    udio_wrapper = UdioWrapper(auth_token)
  5. Create a short song with create_song()

    main

    Use create_song to generate a new track from a text prompt. You can optionally provide a seed for reproducibility and custom_lyrics for specific vocal content.

    Parameters:

    • prompt (str): Theme or emotion of the song.
    • seed (int, optional): Seed for reproducibility. Default is -1 (random).
    • custom_lyrics (str, optional): User-provided lyrics.
    short_song = udio_wrapper.create_song(
        prompt="Relaxing jazz and soulful music",
        seed=-1,
        custom_lyrics="Short song lyrics here"
    )
    print(short_song)
    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)
  6. Add an outro with add_outro()

    main

    Generate a concluding section for a musical sequence using a previous song as a base.

    Parameters:

    • prompt (str): Prompt for the finale.
    • seed (int, optional): Seed for reproducibility.
    • audio_conditioning_path (str, optional): URL/path to the base audio.
    • audio_conditioning_song_id (str, optional): ID of the song to follow.
    • custom_lyrics (str, optional): Outro lyrics.
    outro_song = udio_wrapper.add_outro(
        prompt="A smooth ending",
        seed=-1,
        audio_conditioning_path="url-generated-song",
        audio_conditioning_song_id="last-song-id",
        custom_lyrics="Outro lyrics here"
    )
    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)
  7. Extend a song with extend()

    main

    Extend an existing track by conditioning the new generation on a previous song's audio and ID.

    Parameters:

    • prompt (str): Description of the extension.
    • seed (int, optional): Seed for reproducibility.
    • audio_conditioning_path (str, optional): URL or path to the base audio file.
    • audio_conditioning_song_id (str, optional): The ID of the previous song.
    • custom_lyrics (str, optional): Lyrics for the extension.
    extend_song = udio_wrapper.extend(
        prompt="A dynamic version of relaxing jazz",
        seed=-1,
        audio_conditioning_path="url-generated-song",
        audio_conditioning_song_id="previous-song-id",
        custom_lyrics="Extended version lyrics"
    )
    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)