Git Product home page Git Product logo

musiclm's Introduction

Working 09/06/23

MusicLM

Unofficial API for Google's MusicLM on the AI Test Kitchen

Dependencies

  • Google Chrome
  • Python >= 3.6
  • Selenium
  • undetected_chromedriver
  • python-dotenv
  • requests

Installation

  1. Install Python 3 from the official website: https://www.python.org/downloads/
  2. Run the following command in your terminal to install the required libraries:
pip install selenium undetected-chromedriver python-dotenv requests

Usage

  1. Before running the script, make sure you have a Google account that has access to the AI Test Kitchen. Join the waitlist here.
  2. Clone the repository and navigate to the directory containing the script.
  3. Rename the file example.env to .env
  4. Store Google sign-in details in the .env file (necessary to obtain OAuth2.0 token that is used to generate music)
  5. Create a new Python file and import the Music class from the MusicLM.py file.
from MusicLM import Music
  1. Create an instance of the Music class.
music = Music()
  1. Call the get_tracks method on the instance and provide a string input and an integer generationCount argument (8 max).
input = "Ambient, soft sounding music I can study to"
tracks = music.get_tracks(input, 2)
  1. Call the base64toMP3 method on the instance and provide the returned tracks from the get_tracks method and a filename.
music.base64toMP3(tracks, input)
  1. The generated tracks will be saved to a new directory with the same name as the input string.

How it works

The Music class handles authentication using a headless Chrome browser that obtains the OAuth 2.0 authentication token. The get_token method logs the user in to the AI Test Kitchen website and retrieves the OAuth 2.0 token from the browser's cookies. The token is saved to a .env file. The token expires every hour and is refreshed automatically using the token_refresh method.

The Music class uses the requests library to make a POST request to an API with the input string and the number of tracks to generate. The API returns a JSON object containing the base64-encoded audio data for each track. The base64-encoded audio data is decoded with the base64toMP3 method and each track is saved as an MP3 file.

Filter Bypass ("Oops, can't generate audio for that.")

Normally if you input popular media references, it returns an error inferring that it can't generate it (presumably due to copyright issues)

But simply enclosing the references <> bypasses it for some reason and works as expected, like here the output music is an unmistakable combination of Attack on Titan's OST's time signature & instruments and the dramatic undertone of Dark Souls OST.

Video.mp4

This bypass was discovered and shared by ArpanTripathi on Twitter

https://twitter.com/ArpanTripathi20/status/1661292475892285441

Disclaimer

This tool is for educational purposes only and should not be used for any commercial or illegal activities. The author is not responsible for any misuse of this tool.

Errors

OsError: [WinError 6] The handle is invalid - refer to this issue: ultrafunkamsterdam/undetected-chromedriver#1256

musiclm's People

Contributors

plon avatar thegamebegins25 avatar

Stargazers

Simon Dai avatar Daniel Bashir avatar Martynka Adamski avatar  avatar Jorge Rivera avatar Chris DSilva avatar Kiki avatar  avatar  avatar Shravan Vadeghar avatar  avatar  avatar Ben Johnston avatar Adam avatar Gil Perez avatar  avatar  avatar Andrew avatar  avatar Gabriel Parca avatar Fabio M. avatar  avatar ChungHa avatar Zhiqiang ZHOU avatar BaeSooMin avatar Csaba Toth avatar Shashank Bhat  avatar Yashraj Singh Chouhan avatar Ronny avatar  avatar Eugene Chung avatar dengfenglai avatar Felix Luciano Salomon avatar Nick Jiang avatar Jagdish Patil avatar Daniel Shemesh avatar  avatar Kota Nakamura avatar Takato Honda avatar S.A. Hinzey avatar  avatar Max Hager avatar  avatar

Watchers

 avatar  avatar

musiclm's Issues

Unable to retrieve Auth 2.0 token after login

There seems to be an issue where you are unable to retrieve the token after a successful login.

Traceback (most recent call last):
  File "c:/Users/Felix/Documents/MusicLM/example.py", line 4, in <module>
    music = Music()
  File "c:\Users\Felix\Documents\MusicLM\MusicLM.py", line 29, in __init__
    self.token = self.get_token()
  File "c:\Users\Felix\Documents\MusicLM\MusicLM.py", line 123, in get_token
    raise Exception("Unable to obtain token")
Exception: Unable to obtain token

Not sure if there was a change in the way MusicLM does authentication

Unable to obtain OAuth 2.0 token

image
I am unable to obtain the OAuth 2.0 token when I run the code. I set the .env file with my credentials, and it is logging in, however it is not getting the token?

Token Cookie

The musiclm website has undergone changes since this API was written. I was able to change the script such that I could successfully log in, but I'm having trouble obtaining the token. I don't see the token in the list of cookies. Have they changed the way that token information is stored?

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.