Create suno.py
Browse files- TextGen/suno.py +64 -0
TextGen/suno.py
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import time
|
2 |
+
import requests
|
3 |
+
import os
|
4 |
+
|
5 |
+
base_url = os.environ["VERCEL_API"]
|
6 |
+
|
7 |
+
def custom_generate_audio(payload):
|
8 |
+
url = f"{base_url}/api/custom_generate"
|
9 |
+
response = requests.post(url, json=payload, headers={'Content-Type': 'application/json'})
|
10 |
+
return response.json()
|
11 |
+
|
12 |
+
|
13 |
+
def extend_audio(payload):
|
14 |
+
url = f"{base_url}/api/extend_audio"
|
15 |
+
response = requests.post(url, json=payload, headers={'Content-Type': 'application/json'})
|
16 |
+
return response.json()
|
17 |
+
|
18 |
+
def generate_audio_by_prompt(payload):
|
19 |
+
url = f"{base_url}/api/generate"
|
20 |
+
response = requests.post(url, json=payload, headers={'Content-Type': 'application/json'})
|
21 |
+
return response.json()
|
22 |
+
|
23 |
+
|
24 |
+
def get_audio_information(audio_ids):
|
25 |
+
url = f"{base_url}/api/get?ids={audio_ids}"
|
26 |
+
response = requests.get(url)
|
27 |
+
return response.json()
|
28 |
+
|
29 |
+
|
30 |
+
def get_quota_information():
|
31 |
+
url = f"{base_url}/api/get_limit"
|
32 |
+
response = requests.get(url)
|
33 |
+
return response.json()
|
34 |
+
|
35 |
+
def get_clip(clip_id):
|
36 |
+
url = f"{base_url}/api/clip?id={clip_id}"
|
37 |
+
response = requests.get(url)
|
38 |
+
return response.json()
|
39 |
+
|
40 |
+
def generate_whole_song(clip_id):
|
41 |
+
payloyd = {"clip_id": clip_id}
|
42 |
+
url = f"{base_url}/api/concat"
|
43 |
+
response = requests.post(url, json=payload)
|
44 |
+
return response.json()
|
45 |
+
|
46 |
+
|
47 |
+
if __name__ == '__main__':
|
48 |
+
data = generate_audio_by_prompt({
|
49 |
+
"prompt": "A popular heavy metal song about war, sung by a deep-voiced male singer, slowly and melodiously. The lyrics depict the sorrow of people after the war.",
|
50 |
+
"make_instrumental": False,
|
51 |
+
"wait_audio": False
|
52 |
+
})
|
53 |
+
|
54 |
+
ids = f"{data[0]['id']},{data[1]['id']}"
|
55 |
+
print(f"ids: {ids}")
|
56 |
+
|
57 |
+
for _ in range(60):
|
58 |
+
data = get_audio_information(ids)
|
59 |
+
if data[0]["status"] == 'streaming':
|
60 |
+
print(f"{data[0]['id']} ==> {data[0]['audio_url']}")
|
61 |
+
print(f"{data[1]['id']} ==> {data[1]['audio_url']}")
|
62 |
+
break
|
63 |
+
# sleep 5s
|
64 |
+
time.sleep(5)
|