29 Star 277 Fork 123

modstart-lib/aigcpanel

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

AigcPanel

star star star star star

软件介绍

AigcPanel 是一个简单易用的一站式AI数字人系统,小白也可使用。 支持视频合成、声音合成、声音克隆,简化本地模型管理、一键导入和使用AI模型。

禁止使用本产品进行违法违规业务,使用本软件请遵守中华人民共和国法律法规。

功能特性

  • 支持视频数字人合成,支持视频画面和声音换口型匹配
  • 支持语音合成、语音克隆,多种声音参数可设置
  • 支持多模型导入、一键启动、模型设置、模型日志查看
  • 支持国际化,支持简体中文、英语
  • 支持多种模型一键启动包
    • 声音模型 CosyVoice-300M
    • 声音模型 CosyVoice-300M-Instruct
    • 声音模型 CosyVoice2-0.5b
    • 声音模型 FishSpeech
    • 声音模型 SparkTTS
    • 视频模型 MuseTalk
    • 视频模型 LatentSync
    • 视频模型 Wav2Lip

效果预览

参考 demo 中的视频文件。

功能预览

视频合成

我的形象

语音克隆

语音合成

模型管理

安装使用

Windows

安装完成后,打开软件,下载模型一键启动包,即可使用。

模型自定义接入

一个模型即是一个文件夹,至少包含 config.json 和 server.js 两个文件。

|- 模型文件夹/
|-|- config.json - 模型配置文件
|-|- server.js   - 模型对接文件
|-|- xxx       - 其他模型文件,推荐将模型文件放在 model 文件夹下

简易接入

需要掌握 python 开发能力

首先需要将python环境打包到同一个目录,比如 _aienv ,然后可以通过 python run.py ./config.json 的方式运行模型。

模型运行之后,通过标准输入输出的方式运行模型,通过标准输入传递参数,通过标准输出返回结果。

# 输出格式为 AigcPanelRunResult[id][base64(json(data))]
import json, base64

# 解析输入配置文件
config = json.loads(open(sys.argv[1], 'r').read())
modelConfig = config['modelConfig']

def printResult(key,value):
    global config
    print(f'AigcPanelRunResult[{config['id']}][' + base64.b64encode(json.dumps({key: value}).encode()).decode()+']')

# 公共输出
## 输出给前端的是否是以 CUDA 运行
printResult('UseCuda', True)

## 语音合成输出结果
printResult('url', '/path/to/result.wav')

## 语音克隆输出结果
printResult('url', '/path/to/result.wav')

## 视频对口型输出结果
printResult('url', '/path/to/result.mp4')

config.json 文件示例

{
    "name": "server-xxx",          // 模型名称
    "version": "0.1.0",            // 模型版本
    "title": "语音模型",            // 模型标题
    "description": "模型描述",      // 模型描述
    "deviceDescription":"设备描述",
    "platformName": "win",         // 支持系统,win, osx, linux
    "platformArch": "x86",         // 支持架构,x86, arm64
    "serverRequire": ">=0.5.0",    // 对 AigcPanel 版本的要求,如 >=0.5.0
    "entry": "__EasyServer__",     // 固定值,不需要修改
    "easyServer": {
        // python 运行入口
        "entry": "./_aienv/bin/python",
        "entryArgs": [
            "run.py",
            "${CONFIG}"
        ],
        // 环境变量
        "envs": [
            "AAA=1"
        ]
    },
    "functions": [
        "videoGen",                // 支持视频生成
        "soundTTS",                // 支持语音合成
        "soundClone"               // 支持语音克隆
    ],
    "settings": [                  // 模型配置项,可以显示在模型配置页面
        {
            "name": "port",
            "type": "text",
            "title": "服务端口",
            "default": "",
            "placeholder": "留空会检测使用随机端口"
        }
    ]
}

测试导入

完成两个文件的开发之后,在软件中尝试选择模型文件夹中的config.json导入。

高级接入

需要掌握 js 开发能力

config.json 文件示例

{
    "name": "server-xxx",          // 模型名称
    "version": "0.1.0",            // 模型版本
    "title": "语音模型",            // 模型标题
    "description": "模型描述",      // 模型描述
    "deviceDescription":"设备描述",
    "platformName": "win",         // 支持系统,win, osx, linux
    "platformArch": "x86",         // 支持架构,x86, arm64
    "serverRequire": ">=0.5.0",    // 对AigcPanel版本的要求,如 >=0.5.0
    "entry": "main.exe",           // 入口文件
    "functions": [
        "videoGen",                // 支持视频生成
        "soundTTS",                // 支持语音合成
        "soundClone"               // 支持语音克隆
    ],
    "settings": [                  // 模型配置项,可以显示在模型配置页面
        {
            "name": "port",
            "type": "text",
            "title": "服务端口",
            "default": "",
            "placeholder": "留空会检测使用随机端口"
        }
    ]
}

server.js 文件示例

const serverRuntime = {
    port: 0,
}

let shellController = null
let isRunning = false

module.exports = {
    ServerApi: null,
    ServerInfo: null,
    url() {
        return `http://localhost:${serverRuntime.port}/`
    },
    // 模型启动
    async start() {
        // 发送一个启动中的消息
        this.send('starting', this.ServerInfo)
        // 获取一个可用端口,如果用户设置了端口,则使用用户设置的端口
        if (this.ServerInfo.setting && this.ServerInfo.setting.port) {
            serverRuntime.port = this.ServerInfo.setting.port
        } else if (!serverRuntime.port || !await this.ServerApi.app.isPortAvailable(serverRuntime.port)) {
            serverRuntime.port = await this.ServerApi.app.availablePort(50617)
        }
        // 模型启动命令,这里假设需要运行的命令是 python main.py
        let command = []
        command.push(`"${this.ServerInfo.localPath}/_aienv/python.exe"`)
        command.push(`main.py`)
        // 环境变量,这里需要定义一下环境变量,比如python路径,二进制文件路径等,以下环境变量是绝大多数环境需要添加的
        const envMap = {}
        const dep = process.platform === 'win32' ? ';' : ':'
        envMap['PATH'] = process.env['PATH'] || ''
        envMap['PATH'] = `${this.ServerInfo.localPath}{dep}${envMap['PATH']}`
        envMap['PYTHONIOENCODING'] = 'utf-8'
        // 这里开始启动命令,启动命令会返回一个控制器,可以用来停止命令
        shellController = await this.ServerApi.app.spawnShell(command, {
            stdout: (data) => {
                this.sendLog(data)
            },
            stderr: (data) => {
                this.sendLog(data)
            },
            success: (data) => {
                this.send('success', this.ServerInfo)
            },
            error: (data, code) => {
                this.sendLog(data)
                this.send('error', this.ServerInfo)
            },
            env: envMap,
            cwd: this.ServerInfo.localPath,
        })
    },
    // 模型测试是否可用
    async ping() {
        try {
            // 这里假设模型的ping接口是 /ping ,正确返回 ping,错误返回 false
            const res = await this.ServerApi.request(`${this.url()}ping`)
            return true
        } catch (e) {
            return false
        }
    },
    // 模型停止
    async stop() {
        this.send('stopping', this.ServerInfo)
        try {
            shellController.stop()
            shellController = null
        } catch (e) {
            console.log('stop error', e)
        }
        this.send('stopped', this.ServerInfo)
    },
    // 获取模型配置信息
    async config() {
        return {
            code: 0,
            msg: "ok",
            data: {
                // 模型的地址信息
                httpUrl: shellController ? this.url() : null,
                // 模型说明信息
                content: '模型说明',
                functions: {
                    // 声音合成
                    soundTts: {
                        param:[]
                    },
                    // 声音克隆
                    soundClone: {
                        param: []
                    },
                    // 视频对口型
                    videoGen: {
                        param: []
                    }
                }
            }
        }
    },
    // 执行调用:视频对口型
    async videoGen(data) {
        // data = { id: '任务ID', videoFile: '视频文件路径', soundFile: '声音文件路径' }
        const resultData = {
            // success, querying, retry
            type: 'success', 
            start: 0, 
            end: 0, 
            data: {
                filePath: null
            }
        }
        if (isRunning) {
            resultData.type = 'retry'
            return { code: 0, msg: 'ok', data: resultData }
        }
        isRunning = true
        const param = data.param || {}
        resultData.start = Date.now()
        try {
            this.send('taskRunning', {id: data.id})
            // 模型调用请求,完成调用逻辑
            // 视频文件路径 data.videoFile
            // 声音文件路径 data.soundFile
            resultData.data.filePath = '合成之后的本地mp4路径'
            resultData.end = result.endTime
            return { code: 0, msg: 'ok', data: resultData }
        } catch (e) {
            throw e
        } finally {
            isRunning = false
        }
    },
    // 执行调用:声音合成
    async soundTts(data) {
        // data = { id: '任务ID', text: '合成文本' }
        const resultData = {
            // success, querying, retry
            type: 'success',
            start: 0,
            end: 0,
            data: {
                filePath: null
            }
        }
        if (isRunning) {
            resultData.type = 'retry'
            return { code: 0, msg: 'ok', data: resultData }
        }
        isRunning = true
        const param = data.param || {}
        resultData.start = Date.now()
        try {
            this.send('taskRunning', {id: data.id})
            // 模型调用请求,完成调用逻辑
            // 合成文本 data.text
            resultData.data.filePath = '合成之后的本地wav路径'
            resultData.end = result.endTime
            return { code: 0, msg: 'ok', data: resultData }
        } catch (e) {
            throw e
        } finally {
            isRunning = false
        }
    },
    // 执行调用:声音克隆
    async soundClone(data) {
        // data = { id: '任务ID', text: '合成文本', promptAudio: '参考音频路径', promptText: '参考音频文字' }
        const resultData = {
            // success, querying, retry
            type: 'success',
            start: 0,
            end: 0,
            data: {
                filePath: null
            }
        }
        if (isRunning) {
            resultData.type = 'retry'
            return { code: 0, msg: 'ok', data: resultData }
        }
        isRunning = true
        const param = data.param || {}
        resultData.start = Date.now()
        try {
            this.send('taskRunning', {id: data.id})
            // 模型调用请求,完成调用逻辑
            // 合成文本 data.text
            resultData.data.filePath = '合成之后的本地wav路径'
            resultData.end = result.endTime
            return { code: 0, msg: 'ok', data: resultData }
        } catch (e) {
            throw e
        } finally {
            isRunning = false
        }
    },
}

测试导入

完成两个文件的开发之后,在软件中尝试选择模型文件夹中的config.json导入。

技术栈

  • electron
  • vue3
  • typescript

本地运行开发

仅在 node 20 测试过

# 安装依赖
npm install
# 调试运行
npm run dev
# 打包
npm run build

加入交流群

添加好友请备注 AigcPanel

微信交流群 QQ交流群

License

Apache-2.0

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: You must give any other recipients of the Work or Derivative Works a copy of this License; and You must cause any modified files to carry prominent notices stating that You changed the files; and You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS

简介

AigcPanel 是一个简单易用的一站式AI数字人系统,支持视频合成、声音合成、声音克隆,简化本地模型管理、一键导入和使用AI模型。 展开 收起
Apache-2.0
取消

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/modstart-lib/aigcpanel.git
git@gitee.com:modstart-lib/aigcpanel.git
modstart-lib
aigcpanel
aigcpanel
main

搜索帮助