AI-powered music generation with just a few lines of code!
This repository contains example code for the Sonauto AI Music Generation API, showcasing how to generate music, create transitions, and even produce singing telegram videos with simple Python scripts.
Clone this repository and install the required dependencies:
git clone https://github.com/sonauto/sonauto-api-examples.git
cd api-examples
pip install -r requirements.txt
Alternatively, install the dependencies with poetry or uv.
To use these examples, you'll need:
- A Sonauto API key - Get one here
- For the singing telegram example, a Lemon Slice API key - Register here
rock_song_generator.py
- Generate a complete rock song with just a few lines of code.
First, sub in your Sonauto API key.
Second, run it with:
python rock_song_generator.py
transition_generator.py
- Create smooth transitions between any two songs downloaded from YouTube.
This script:
- Downloads two songs from YouTube video IDs
- Generates a transition between them using Sonauto's API
- Exports a combined track with the transition
Don't forget to sub in your API key.
Example: Smash Mouth to Rick Astley
python song_transition.py ec1LhrCmzwI dQw4w9WgXcQ --trim-to-start 13 --trim-from-end 0.5 --silence 20
- URL1/URL2: YouTube URLs or video IDs (required)
- --song-duration: Duration in seconds to use from each song (default: 45)
- --silence: Duration of silence between songs in seconds (default: 5)
- --trim-from-end: Seconds to trim from the end of the first song (default: 0)
- --trim-to-start: Seconds to trim from the beginning of the second song (default: 0)
- --output: Custom filename for the final transition (default: transition_[TASK_ID].ogg)
- --pre-inpaint-output: Filename for the pre-inpainting version (default: pre_inpaint_[TIMESTAMP].mp3)
singing_telegram.py
- Create a personalized singing telegram video that combines Sonauto's music generation with Lemon Slice's AI video generation.
This example:
- Generates custom lyrics about the recipient based on your input
- Creates a personalized song in the style of your choice
- Uses Lemon Slice API to generate a video of a character singing your custom song
- Combines everything into a ready-to-share singing telegram video
Don't forget to grab a Lemon Slice API key and set your .env file.
python singing_telegram.py --recipient "Sarah" --occasion "birthday" --message "she is turning 30 and loves hiking" --style "pop"
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ by the Sonauto Team