#### 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. 注意事项
- 本项目仅用于学习交流,不得用于商业用途
- 个人账号部分功能无法使用
没有合适的资源?快使用搜索试试~ 我知道了~
将 sunoAi web 转成 openai 格式进行调用
共11个文件
go:6个
sum:1个
mod:1个
需积分: 5 0 下载量 28 浏览量
2024-04-13
00:01:00
上传
评论
收藏 15KB ZIP 举报
温馨提示
简单的将 suno.ai web 转为 api 接口 将 config.yaml.example 重命名为 config.yaml 并修改其中的配置
资源推荐
资源详情
资源评论
收起资源包目录
sunotoapi-master.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
资源评论
geobuins
- 粉丝: 2031
- 资源: 1208
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 几个常用的排序算法的实现
- 程序员面试自我介绍pdf
- 毕设毕设毕设毕设毕设毕设
- 高分项目,基于Unity3D开发实现的美食游戏模板-Restaurant,内含完整源码+资源+unitypackage
- 计算机组成原理,主要研究计算机系统的基本构成、工作原理和设计方法
- 高分项目,基于Unity3D开发实现的Deftly Top Down Shoote,内含完整源码+资源+unitypackage
- Clodop_Setup_for_Win32NT.zip
- 计算机科学与技术毕业实习报告pdf
- Chromev10905414120,win7系统可使用的Chrome浏览器版本
- chatgpt原理、应用与提示技巧pdf
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功