求一个可用的suno-v3的项目,可以对接one-api使用openai接口的那种。
2 个赞
这家有,没试过
https://gptgod.online/#/register?invite_code=6ub95cltf7cy4sy42uhryq4oo
带aff,送的积分你可以对接一下看看
2 个赞
论坛搜一搜,很多的。
1 个赞
始皇 改完代码 忘了上传了 然后pip的时候覆盖了 现在正在搞回来,但是我无法适配newapi这些现有的项目,这是我的代码,看看有啥意见能指导一下不
async def generate_data():
try:
_return_image_url = False
_return_video_url = False
chat_id = generate_random_string_async(32)
timeStamp = generate_timestamp_async()
cookie = ""
token, sid = SongsGen(cookie)._get_auth_token(w=1)
suno_auth.set_session_id(sid)
suno_auth.load_cookie(cookie)
data = {
"token": "",
"cookie": "",
"session_id": "",
"gpt_description_prompt": "写一首rap",
"prompt": "",
"mv": "chirp-v3-0",
"title": "",
"tags": ""
}
yield f"""data:{json.dumps({"id": f"chatcmpl-{chat_id}", "object": "chat.completion.chunk", "model": "suno-v3", "created": timeStamp, "choices": [{"index": 0, "delta": {"role":"assistant","content":""}, "finish_reason": None}]})}"""
while True:
try:
response = await generate_music(data=data, token=token)
clip_ids = [clip["id"] for clip in response["clips"]]
if not clip_ids:
yield json.dumps({"state": 400, "message": "No clips generated"})
return
break
except:
pass
# 使用 clip_ids 查询音频链接
for clip_id in clip_ids:
attempts = 0
while attempts < 30: # 限制尝试次数以避免无限循环
now_data = await get_feed(ids=clip_id, token=token)
print(now_data)
if type(now_data) == dict:
if now_data.get('detail') == 'Unauthorized':
link = f'https://audiopipe.suno.ai/?item_id={clip_id}'
yield f"""data:{json.dumps({"id": f"chatcmpl-{chat_id}", "object": "chat.completion.chunk", "model": "suno-v3", "created": timeStamp, "choices": [{"index": 0, "delta": {"content": link}, "finish_reason": None}]})}"""
break
elif 'audio_url' in now_data:
yield f"""data:{json.dumps({"id": f"chatcmpl-{chat_id}", "object": "chat.completion.chunk", "model": "suno-v3", "created": timeStamp, "choices": [{"index": 0, "delta": {"content": now_data["audio_url"]}, "finish_reason": None}]})}"""
yield f"""data:{json.dumps({"id": f"chatcmpl-{chat_id}", "object": "chat.completion.chunk", "model": "suno-v3", "created": timeStamp, "choices": [{"index": 0, "delta": {"content": now_data["audio_large_url"]}, "finish_reason": None}]})}"""
break
elif not _return_image_url:
if now_data[0].get('image_url') is not None:
yield f"""data:{json.dumps({"id": f"chatcmpl-{chat_id}", "object": "chat.completion.chunk", "model": "suno-v3", "created": timeStamp, "choices": [{"index": 0, "delta": {"content": now_data[0]["image_url"]}, "finish_reason": None}]})}"""
yield f"""data:{json.dumps({"id": f"chatcmpl-{chat_id}", "object": "chat.completion.chunk", "model": "suno-v3", "created": timeStamp, "choices": [{"index": 0, "delta": {"content": now_data[0]["image_large_url"]}, "finish_reason": None}]})}"""
# yield f'data:{json.dumps({"state": 200, "message": now_data[0]["image_url"]})}'
# yield f'data:{json.dumps({"state": 200, "message": now_data[0]["image_large_url"]})}'
_return_image_url = True
else:
# yield f'data:{json.dumps({"state": 200, "message": "Waiting for audio URL..."})}'
yield f"""data:{json.dumps({"id":f"chatcmpl-{chat_id}","object":"chat.completion.chunk","model":"suno-v3","created":timeStamp,"choices":[{"index":0,"delta":{"content":"Waiting for audio URL..."},"finish_reason":None}]})}"""
await asyncio.sleep(5) # 等待5秒再次尝试
attempts += 1
yield f"""data:{[str('DONE')]}"""
except Exception as e:
yield f'data:{json.dumps({"state": 500, "message": str(e)})}'
@app.post("/v1/chat/completions")
async def kkkk():
return StreamingResponse(generate_data(), media_type="text/plain")
这么好的项目,怎么没人讨论一下 ~~~
最后更新 4.3
1 个赞