#### 1. 项目简介
简单的将 suno.ai web转为api接口
#### 2. 部署方式
将 config.yaml.example 重命名为 config.yaml 并修改其中的配置
```yaml
Server:
Port: 3560
App:
Client: #登录 suno.ai 后的 cookie中的__client=xxxxx 的值
```
启动服务
```shell
./sunoweb2api
```
#### 3. 使用方式
下列 api 都可以增加一个Header参数
```shell
Authorization : Bearer Client
```
其中Client为登录 suno.ai 后的 cookie中的__client=xxxxx 的值
如果不填写 默认使用config.yaml中的配置中的 Client
示例:
```shell
curl --location --request POST 'localhost:3560/v1/chat/completions' \
--header 'Authorization: Bearer client' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "chirp-v3-0",
"messages": [
{
"role": "user",
"content": "制作歌曲《万能的数字》"
}
]
}'
```
创建音乐任务
```shell
curl --location --request POST 'localhost:3560/v2/generate' \
--header 'Content-Type: application/json' \
--data-raw '{
"gpt_description_prompt": "an atmospheric metal song about dancing all night long",
"mv": "chirp-v3-0",
"prompt": "",
"make_instrumental": false
}'
```
支持如下参数:
- 默认参数
- gpt_description_prompt: 生成音乐的描述
- mv: 音乐模型
- prompt: 生成音乐的提示
- make_instrumental: 是否生成无人声音乐
```json
{
"gpt_description_prompt": "an atmospheric metal song about dancing all night long",
"mv": "chirp-v3-0",
"prompt": "",
"make_instrumental": false
}
```
- 自定义
- prompt: 歌词
- tags: 音乐标签
- mv: 音乐模型
- title: 音乐标题
- continue_clip_id: 继续生成音乐的clip_id
- continue_at: 继续生成音乐的时间
```json
{
"prompt": "[Verse]\nEvery morning, when I wake up\nI stumble to the kitchen to get my cup (cup)\nThe smell, the taste, it's like a dream\nI'm addicted to that caffeinated beam\n\n[Chorus]\nI need my java fix, it's my daily high (high)\nGotta have my coffee, don't ask me why (why)\nBrew it strong, brew it black, can't get enough\nThat sweet, dark liquid, it keeps me buzzin' (buzzin')\n\n[Verse 2]\nEspresso, latte, cappuccino too\nI'll take it any way, as long as it's brew\nFrom the fancy cafes to the corner shops\nI'm on a mission to find the perfect crop (yeah)",
"tags": "epic blues",
"mv": "chirp-v3-0",
"title": "Coffee Addiction",
"continue_clip_id": null,
"continue_at": null
}
```
- 自定义纯音乐
- prompt: 歌词
- tags: 音乐标签
- mv: 音乐模型
- title: 音乐标题
- continue_clip_id: 继续生成音乐的clip_id
- continue_at: 继续生成音乐的时间
```json
{
"prompt": "",
"tags": "epic blues",
"mv": "chirp-v3-0",
"title": "Coffee Addiction",
"continue_clip_id": null,
"continue_at": null
}
```
查询音乐任务
```shell
curl --location --request POST 'localhost:3560/v2/feed' \
--header 'Content-Type: application/json' \
--data-raw '{
"ids":"id1,id2"
}'
```
其中id1,id2为创建任务返回json中的clips中的id,如
```json
{
"id": "b577cbad-18c3-49bb-a3aa-e39f9990a9c2",
"clips": [
{
"id": "id1",
"video_url": "",
"audio_url": "",
"image_url": null,
"image_large_url": null,
"major_model_version": "v3",
"model_name": "chirp-v3",
"metadata": {
"tags": null,
"prompt": "",
"gpt_description_prompt": "an atmospheric metal song about dancing all night long",
"audio_prompt_id": null,
"history": null,
"concat_history": null,
"type": "gen",
"duration": null,
"refund_credits": null,
"stream": true,
"error_type": null,
"error_message": null
},
"is_liked": false,
"user_id": "284ac3ca-a2cf-4b0c-a1b5-64d7315fbe28",
"is_trashed": false,
"reaction": null,
"created_at": "2024-03-26T07:01:44.235Z",
"status": "submitted",
"title": "",
"play_count": 0,
"upvote_count": 0,
"is_public": false
},
{
"id": "id2",
"video_url": "",
"audio_url": "",
"image_url": null,
"image_large_url": null,
"major_model_version": "v3",
"model_name": "chirp-v3",
"metadata": {
"tags": null,
"prompt": "",
"gpt_description_prompt": "an atmospheric metal song about dancing all night long",
"audio_prompt_id": null,
"history": null,
"concat_history": null,
"type": "gen",
"duration": null,
"refund_credits": null,
"stream": true,
"error_type": null,
"error_message": null
},
"is_liked": false,
"user_id": "284ac3ca-a2cf-4b0c-a1b5-64d7315fbe28",
"is_trashed": false,
"reaction": null,
"created_at": "2024-03-26T07:01:44.235Z",
"status": "submitted",
"title": "",
"play_count": 0,
"upvote_count": 0,
"is_public": false
}
],
"metadata": {
"tags": null,
"prompt": "",
"gpt_description_prompt": "an atmospheric metal song about dancing all night long",
"audio_prompt_id": null,
"history": null,
"concat_history": null,
"type": "gen",
"duration": null,
"refund_credits": null,
"stream": true,
"error_type": null,
"error_message": null
},
"major_model_version": "v3",
"status": "running",
"created_at": "2024-03-26T07:01:44.214Z",
"batch_size": 2
}
```
使用ai生成歌词
```shell
curl --location --request POST 'localhost:3560/v2/lyrics/create' \
--header 'Content-Type: application/json' \
--data-raw '{"prompt":""}'
```
响应json:
```json
{
"id": "4ad435dd-b3f1-4ed7-b316-1868ff4ffe55"
}
```
查询生成的歌词
```shell
curl --location --request POST 'localhost:3560/v2/lyrics/task' \
--header 'Content-Type: application/json' \
--data-raw '{
"ids":"4ad435dd-b3f1-4ed7-b316-1868ff4ffe55"
}'
```
响应json:
```json
{
"text": "[Verse]\nI saw you sippin' on your latte with grace\nAcross the room, I couldn't help but gaze (gazin')\nYour smile was like a sunbeam on a cloudy day\nIn that moment, I knew I had to find a way\n\n[Chorus]\nCoffee shop love affair, brewing in the air\nAin't nothin' like the feeling when we're there (when we're there)\nCoffee shop love affair, hearts are gonna dare\nTo catch a glimpse of something rare\n\n[Verse 2]\nI ordered my Americano, extra light\nAnd slowly made my way closer in sight (closer in sight)\nOur eyes met, and the world began to fade\nIn that coffee shop, our love was made (made, baby)",
"title": "The Coffee Shop Love Affair",
"status": "complete"
}
```
兼容 openai /v1/chat/completions格式
```shell
curl --location --request POST 'localhost:3560/v1/chat/completions' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "chirp-v3-0",
"messages": [
{
"role": "user",
"content": "制作歌曲《万能的mj)中文歌词 mj是-个群体的统称"
}
]
}'
```
响应json:
```json
{
"choices": [
{
"finish_reason": "stop",
"index": 0,
"logprobs": null,
"message": {
"content": "xxxx",
"role": "assistant"
}
}
],
"created": 1711612671,
"id": "chatcmpl-7QyqpwdfhqwajicIEznoc6Q47XAyW",
"model": "chirp-v3-0",
"object": "chat.completion",
"usage": {
"completion_tokens": 17,
"prompt_tokens": 57,
"total_tokens": 74
}
}
```
#### 4. 注意事项
- 本项目仅用于学习交流,不得用于商业用途
- 个人账号部分功能无法使用
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
这里为你收集整理了关于AI,机器学习,深度学习相关的资料一份,质量非常高,如果你投入时间去研究几天相信肯定对你有很大的帮助。到时候你会回来感谢我的。 本资源是经过本地编译测试、可打开、可运行的文件或源码,可以用于毕业设计、课程设计的应用、参考和学习需求,请放心下载。 祝愿你在这个毕业设计项目中取得巨大进步,顺利毕业! 但强调一下,这些项目源码仅供学习和研究之用。在使用这些资源时,请务必遵守学术诚信原则和相关法律法规,不得将其用于任何商业目的或侵犯他人权益的行为。对于任何因使用本资源而导致的问题,包括但不限于数据丢失、系统崩溃或安全漏洞,风险自担!
资源推荐
资源详情
资源评论
收起资源包目录
将 sunoAi web转成 openai 格式进行调用.zip (11个子文件)
sunotoapi-master
go.mod 1KB
go.sum 8KB
readme.md 7KB
serve
serve.go 9KB
u.go 822B
router
router.go 3KB
models
models.go 10KB
.gitignore 6B
cfg
config.go 631B
config.yaml.example 44B
main.go 282B
共 11 条
- 1
资源评论
高校毕业设计
- 粉丝: 195
- 资源: 385
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功