Skip to content

Commit

Permalink
feat: Update README, setup.py, and suno/suno.py files
Browse files Browse the repository at this point in the history
- Add a custom mode example to the README.md file, including code snippet and explanation
- Update the version number from "0.2.4" to "0.3.0" in setup.py
- Update the author's email address, project URL for bug reports, package dependencies, and Python version classifiers in setup.py
- Import the `random` module and add a list of music genres called `MUSIC_GENRE_LIST` in suno/suno.py
- Modify the `get_songs` method to use a random genre tag if not specified in suno/suno.py
- Modify the `save_songs` method to use the default output directory "./output" in suno/suno.py

Signed-off-by: yihong0618 <[email protected]>
  • Loading branch information
yihong0618 committed Mar 27, 2024
1 parent 5c415cc commit 963413f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ print(i.get_limit_left())
i.save_songs("a blue cyber dream song", './output')
```

Custom mode

```python
#you can use custom mode
from suno import SongsGen
i = SongsGen('cookie') # Replace 'cookie'
print(i.get_limit_left())
i.save_songs("大江东去,浪淘尽,千古风流人物。故垒西边,人道是、三国周郎赤壁。乱石穿空,惊涛拍岸,卷起千堆雪。江山如画,一时多少豪杰。遥想公瑾当年,小乔初嫁了,雄姿英发。", is_custom=True, title="custom", tags="轻松的R&B, BPM60, 小调, 电吉他、贝斯、键盘和轻鼓, 男性歌手")
```

## Thanks

- All my 爱发电 sponsors https://afdian.net/a/yihong0618?tab=sponsor
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="suno_songs",
version="0.2.4",
version="0.3.0",
author="yihong0618",
author_email="[email protected]",
description="High quality image generation by ideogram.ai. Reverse engineered API.",
Expand Down
28 changes: 26 additions & 2 deletions suno/suno.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import time
from http.cookies import SimpleCookie
from typing import Tuple
import random

from curl_cffi import requests
from curl_cffi.requests import Cookies
Expand Down Expand Up @@ -34,6 +35,26 @@
Gecko/20100101 Firefox/117.0",
}

MUSIC_GENRE_LIST = [
"African",
"Asian",
"South and southeast Asian",
"Avant-garde",
"Blues",
"Caribbean and Caribbean-influenced",
"Comedy",
"Country",
"Easy listening",
"Electronic",
"Folk",
"Hip hop",
"Jazz",
"Latin",
"Pop",
"R&B and soul",
"Rock",
]


class SongsGen:
def __init__(self, cookie: str) -> None:
Expand Down Expand Up @@ -172,7 +193,10 @@ def get_songs(
payload["gpt_description_prompt"] = ""
payload["title"] = title
if not tags:
payload["tags"] = "pop"
payload["tags"] = random.choice(MUSIC_GENRE_LIST)
else:
payload["tags"] = tags
print(payload)
response = self.session.post(
url,
data=json.dumps(payload),
Expand Down Expand Up @@ -209,7 +233,7 @@ def get_songs(
def save_songs(
self,
prompt: str,
output_dir: str,
output_dir: str = "./output",
tags: Union[str, None] = None,
title: Union[str, None] = None,
is_custom: bool = False,
Expand Down

0 comments on commit 963413f

Please sign in to comment.