| Name | riff-api JSON |
| Version |
0.1.4
JSON |
| download |
| home_page | None |
| Summary | Riffusion API |
| upload_time | 2024-08-26 05:27:08 |
| maintainer | None |
| docs_url | None |
| author | None |
| requires_python | >=3.8 |
| license | None |
| keywords |
|
| VCS |
 |
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
# Riffusion API

This repo contains code for crafting music using Riffusion's foundational music models via API. You can either use the typed Python client in this library or make requests directly.
Please note that this API is in a private beta and subject to change. Contact api@riffusion.com for inquiries and access.
## Getting Started
Set your API key:
```bash
export RIFFUSION_API_KEY="<your-api-key>"
```
Install the Python client:
```bash
pip install riff-api
```
Make some music:
```python
import riff_api
riff_api.create_from_topic(
"Indie pop banger about my dog Boris",
save_to="output.wav",
)
```
This will generate lyrics and music for a 30s song. Run multiple times to create variations.
Sample: [output.wav](https://storage.googleapis.com/corpusant-public/output.wav)
Have fun 💙
## `/topic` Endpoint
This endpoint creates a song from a single natural language description the desired lyrical content and/or musical style. It's the simplest way to create.
The API will generate lyrics based on your topic, as well as pick specific sound prompts. If you don't describe a musical style in your prompt, the API will choose randomly for you each time you call.
Get creative with your topics! Here are a few ideas:
* "Rap fun facts about Alaska's history"
* "Explain the concept of time in French"
* "My nephew Remi is a superhero with laser eyes. Make him a theme song with a rock orchestra"
Run via Python client, saving the audio (decoded from base64) and printing the generated lyrics:
```python
import riff_api
response = riff_api.create_from_topic(
"Rap fun facts about Alaskan history",
save_to="output.wav",
)
print(response.lyrics)
```
Alternatively, execute a request directly instead of using the Python client:
```python
import base64
import os
import requests
response = requests.post(
"https://backend.riffusion.com/v1/topic",
headers={
"Content-Type": "application/json",
"Api-Key": os.environ.get("RIFFUSION_API_KEY"),
},
json={
"topic": "Rap fun facts about Alaskan history",
},
).json()
with open("output.wav", "wb") as f:
f.write(base64.b64decode(response["audio_b64"]))
```
Or via curl:
```bash
curl -X POST \
-H "Content-Type: application/json" \
-H "Api-Key: ${RIFFUSION_API_KEY}" \
-d '{"topic": "Rap fun facts about Alaskan history"}' \
https://backend.riffusion.com/v1/topic \
| jq -r .audio_b64 | base64 -d > output.wav
```
### Examples
Check out [examples/topic](examples/topic) for runnable scripts that demonstrate this endpoint.
* [1_request.py](examples/topic/1_request.py) - Call the topic endpoint with `requests`, not using the Python client.
* [2_standard.py](examples/topic/2_standard.py) - Call the topic endpoint with the Python client.
The full schema is in [datatypes.py](riff_api/datatypes.py).
## `/riff` Endpoint
This endpoint provides a more powerful capability for music lovers to craft the exact sound they want. You can specify custom lyrics and multiple sound prompts with individually controllable strengths and time ranges.
Here's a call that creates a 10 second orchestral intro in a chillstep pop song with custom lyrics:
```python
import riff_api
lyrics = """
Hello from outer space
Can you hear me?
I'm a satellite
And I want to be by your side
""".strip()
riff_api.create(
prompts=[
riff_api.Prompt(
text="chillstep pop",
strength=4.0,
),
riff_api.Prompt(
text="orchestral cellos",
strength=3.0,
start_s=0.0,
end_s=10.0,
),
],
lyrics=lyrics,
save_to="output.wav",
)
```
### Examples
Check out [examples/riff](examples/riff) for runnable scripts that demonstrate this endpoint.
* [1_simple.py](examples/riff/1_simple.py) - Use lyrics and a sound prompt to create music.
* [2_instrumental.py](examples/riff/2_instrumental.py) - Pass no lyrics to create instrumental music.
* [3_variations.py](examples/riff/3_variations.py) - Hold a constant seed while modifying other parameters to create variations.
* [4_multiple_prompts.py](examples/riff/4_multiple_prompts.py) - Use two sound prompts with different strengths to fine tune the output.
* [5_transition.py](examples/riff/5_transition.py) - Use two sound prompts with start/end times to create a transition.
* [6_timestamped_lyrics.py](examples/riff/6_timestamped_lyrics.py) - Print the timestamp of each lyric from the generation response.
* [7_audio_formats.py](examples/riff/7_audio_formats.py) - Change the audio format of the response.
The full schema is in [datatypes.py](riff_api/datatypes.py).
## Streamlit Demo
[demo_app.py](demo_app.py) is a basic web app built with Streamlit that
demonstrates using the api.
Try it: [https://riff-api.streamlit.app](https://riff-api.streamlit.app)
Or run locally:
```bash
pip install streamlit
python -m streamlit run demo_app.py
```
<img src="https://storage.googleapis.com/corpusant-public/riffusion_demo_app.png" width="500px" />
Raw data
{
"_id": null,
"home_page": null,
"name": "riff-api",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": null,
"author": null,
"author_email": "Hayk Martiros <hayk@riffusion.com>, Naveen Iyer <naveen@riffusion.com>",
"download_url": "https://files.pythonhosted.org/packages/66/d5/b432bcf9bdf928eaa93ebe0b94688fe1191c63ac866f10ac168d7977c073/riff_api-0.1.4.tar.gz",
"platform": null,
"description": "# Riffusion API\n\n\n\nThis repo contains code for crafting music using Riffusion's foundational music models via API. You can either use the typed Python client in this library or make requests directly.\n\nPlease note that this API is in a private beta and subject to change. Contact api@riffusion.com for inquiries and access.\n\n## Getting Started\nSet your API key:\n\n```bash\nexport RIFFUSION_API_KEY=\"<your-api-key>\"\n```\n\nInstall the Python client:\n```bash\npip install riff-api\n```\n\nMake some music:\n\n```python\nimport riff_api\n\nriff_api.create_from_topic(\n \"Indie pop banger about my dog Boris\",\n save_to=\"output.wav\",\n)\n```\n\nThis will generate lyrics and music for a 30s song. Run multiple times to create variations.\n\nSample: [output.wav](https://storage.googleapis.com/corpusant-public/output.wav)\n\nHave fun \ud83d\udc99\n\n## `/topic` Endpoint\n\nThis endpoint creates a song from a single natural language description the desired lyrical content and/or musical style. It's the simplest way to create.\n\nThe API will generate lyrics based on your topic, as well as pick specific sound prompts. If you don't describe a musical style in your prompt, the API will choose randomly for you each time you call.\n\nGet creative with your topics! Here are a few ideas:\n\n * \"Rap fun facts about Alaska's history\"\n * \"Explain the concept of time in French\"\n * \"My nephew Remi is a superhero with laser eyes. Make him a theme song with a rock orchestra\"\n\nRun via Python client, saving the audio (decoded from base64) and printing the generated lyrics:\n\n```python\nimport riff_api\n\nresponse = riff_api.create_from_topic(\n \"Rap fun facts about Alaskan history\",\n save_to=\"output.wav\",\n)\nprint(response.lyrics)\n```\n\nAlternatively, execute a request directly instead of using the Python client:\n\n```python\nimport base64\nimport os\nimport requests\n\nresponse = requests.post(\n \"https://backend.riffusion.com/v1/topic\",\n headers={\n \"Content-Type\": \"application/json\",\n \"Api-Key\": os.environ.get(\"RIFFUSION_API_KEY\"),\n },\n json={\n \"topic\": \"Rap fun facts about Alaskan history\",\n },\n).json()\n\nwith open(\"output.wav\", \"wb\") as f:\n f.write(base64.b64decode(response[\"audio_b64\"]))\n```\n\nOr via curl:\n\n```bash\ncurl -X POST \\\n -H \"Content-Type: application/json\" \\\n -H \"Api-Key: ${RIFFUSION_API_KEY}\" \\\n -d '{\"topic\": \"Rap fun facts about Alaskan history\"}' \\\n https://backend.riffusion.com/v1/topic \\\n | jq -r .audio_b64 | base64 -d > output.wav\n```\n\n### Examples\n\nCheck out [examples/topic](examples/topic) for runnable scripts that demonstrate this endpoint.\n\n * [1_request.py](examples/topic/1_request.py) - Call the topic endpoint with `requests`, not using the Python client.\n\n * [2_standard.py](examples/topic/2_standard.py) - Call the topic endpoint with the Python client.\n\nThe full schema is in [datatypes.py](riff_api/datatypes.py).\n\n## `/riff` Endpoint\n\nThis endpoint provides a more powerful capability for music lovers to craft the exact sound they want. You can specify custom lyrics and multiple sound prompts with individually controllable strengths and time ranges.\n\nHere's a call that creates a 10 second orchestral intro in a chillstep pop song with custom lyrics:\n\n```python\nimport riff_api\n\nlyrics = \"\"\"\nHello from outer space\nCan you hear me?\nI'm a satellite\nAnd I want to be by your side\n\"\"\".strip()\n\nriff_api.create(\n prompts=[\n riff_api.Prompt(\n text=\"chillstep pop\",\n strength=4.0,\n ),\n riff_api.Prompt(\n text=\"orchestral cellos\",\n strength=3.0,\n start_s=0.0,\n end_s=10.0,\n ),\n ],\n lyrics=lyrics,\n save_to=\"output.wav\",\n)\n```\n\n### Examples\n\nCheck out [examples/riff](examples/riff) for runnable scripts that demonstrate this endpoint.\n\n * [1_simple.py](examples/riff/1_simple.py) - Use lyrics and a sound prompt to create music.\n\n * [2_instrumental.py](examples/riff/2_instrumental.py) - Pass no lyrics to create instrumental music.\n\n * [3_variations.py](examples/riff/3_variations.py) - Hold a constant seed while modifying other parameters to create variations.\n\n * [4_multiple_prompts.py](examples/riff/4_multiple_prompts.py) - Use two sound prompts with different strengths to fine tune the output.\n\n * [5_transition.py](examples/riff/5_transition.py) - Use two sound prompts with start/end times to create a transition.\n\n * [6_timestamped_lyrics.py](examples/riff/6_timestamped_lyrics.py) - Print the timestamp of each lyric from the generation response.\n\n * [7_audio_formats.py](examples/riff/7_audio_formats.py) - Change the audio format of the response.\n\nThe full schema is in [datatypes.py](riff_api/datatypes.py).\n\n## Streamlit Demo\n\n[demo_app.py](demo_app.py) is a basic web app built with Streamlit that\ndemonstrates using the api.\n\nTry it: [https://riff-api.streamlit.app](https://riff-api.streamlit.app)\n\nOr run locally:\n\n```bash\npip install streamlit\npython -m streamlit run demo_app.py\n```\n\n<img src=\"https://storage.googleapis.com/corpusant-public/riffusion_demo_app.png\" width=\"500px\" />\n",
"bugtrack_url": null,
"license": null,
"summary": "Riffusion API",
"version": "0.1.4",
"project_urls": {
"Homepage": "https://github.com/corpusant-ai/riff-api/",
"Issues": "https://github.com/corpusant-ai/riff-api/issues"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3f5c1cb76570335cb62671cb7047a417c14d47dd5cc338b2153c158b0488dd71",
"md5": "401ef083a73b25920dd8609650a53ab4",
"sha256": "599081bb1d0f9bbbdc482ab97d56828b43dfbd3106bc6667433718f1400a8634"
},
"downloads": -1,
"filename": "riff_api-0.1.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "401ef083a73b25920dd8609650a53ab4",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 9472,
"upload_time": "2024-08-26T05:27:06",
"upload_time_iso_8601": "2024-08-26T05:27:06.726360Z",
"url": "https://files.pythonhosted.org/packages/3f/5c/1cb76570335cb62671cb7047a417c14d47dd5cc338b2153c158b0488dd71/riff_api-0.1.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "66d5b432bcf9bdf928eaa93ebe0b94688fe1191c63ac866f10ac168d7977c073",
"md5": "439bc6bf278dc3d0121c9032faef9168",
"sha256": "41db3e9cf9d6f368699293fb4b4a1785a4b5aa6e570d08ceca96cb09f995ba38"
},
"downloads": -1,
"filename": "riff_api-0.1.4.tar.gz",
"has_sig": false,
"md5_digest": "439bc6bf278dc3d0121c9032faef9168",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 8691,
"upload_time": "2024-08-26T05:27:08",
"upload_time_iso_8601": "2024-08-26T05:27:08.253293Z",
"url": "https://files.pythonhosted.org/packages/66/d5/b432bcf9bdf928eaa93ebe0b94688fe1191c63ac866f10ac168d7977c073/riff_api-0.1.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-26 05:27:08",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "corpusant-ai",
"github_project": "riff-api",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "riff-api"
}