Skip to content

Commit

Permalink
Pending changes exported from your codespace
Browse files Browse the repository at this point in the history
  • Loading branch information
TechDecryptor committed Oct 13, 2023
1 parent 75650b3 commit ce16beb
Show file tree
Hide file tree
Showing 8 changed files with 200 additions and 372 deletions.
12 changes: 3 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[package]
name = "plugin" # 名称固定为plugin,请勿更改
version = "1.0.0"
authors = ["pot-app"]
authors = ["TechDecryptor"]
edition = "2021"

[lib]
crate-type = ["dylib"] # pot只支持dylib类型动态库,请勿修改

[dependencies]
base64 = "0.21.4"
reqwest = {version="0.11.18",features = ["blocking","json"]}
urlencoding = "2.1.3"
serde_json = "1.0"

[target.'cfg(target_os = "linux")'.dependencies]
Expand Down
89 changes: 31 additions & 58 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,43 @@
# Pot-App 语音合成插件模板仓库 (以 [Lingva](https://github.com/TheDavidDelta/lingva-translate) 为例)
# Pot-App 火山 语音合成插件 (无需配置,直接使用)

### [English](./README_EN.md) | 简体中文
## 使用方法

### 此仓库为模板仓库,编写插件时可以直接由此仓库创建插件仓库
### 安装 Pot

## 插件编写指南
此插件为 [Pot App](https://github.com/pot-app/pot-desktop) 翻译插件,必须配合 [Pot App](https://github.com/pot-app/pot-desktop) 来使用

### 1. 插件仓库创建
### 安装插件

- 以此仓库为模板创建一个新的仓库
- 仓库名为 `pot-app-tts-plugin-<插件名>`,例如 `pot-app-tts-plugin-lingva_tts`
1. 下载对应平台的插件,解压得到 `.potext` 文件
2. 打开 Pot-偏好设置-服务设置-翻译-添加外部插件-安装外部插件
3. 选择刚刚解压得到的 `.potext` 文件,安装成功
4. 将插件添加到服务列表即可使用

### 2. 插件信息配置
## Speaker

编辑 `info.json` 文件,修改以下字段:
### zh-CN

- `id`:插件唯一 id,必须以`[plugin]`开头,例如 `[plugin].com.pot-app.lingva_tts`
- `homepage`: 插件主页,填写你的仓库地址即可,例如 `https://github.com/pot-app/pot-app-tts-plugin-template`
- `display`: 插件显示名称,例如 `Lingva`
- `icon`: 插件图标,例如 `lingva.svg`
- `needs`: 插件依赖,一个数组,每个依赖为一个对象,包含以下字段:
- `key`: 依赖 key,对应该项依赖在配置文件中的名称,例如 `requestPath`
- `display`: 依赖显示名称,对应用户显示的名称,例如 `请求地址`
- `language`: 插件支持的语言映射,将 pot 的语言代码和插件发送请求时的语言代码一一对应
| Name | Value |
|------|----------------|
| 嘻哈歌手 | zh_male_rap |
| 四川女声 | zh_female_sichuan |
| 影视配音 | zh_male_xiaoming |
| 男主播 | zh_male_zhubo |
| 女主播 | zh_female_zhubo |
| 清新女声 | zh_female_qingxin |
| 少儿故事 | zh_female_story |

### 3. 插件编写/编译
### en

编辑 `src/lib.rs` 实现 `tts` 函数
| Name | Value |
|------|----------------|
| 美式男声 | en_male_adam |
| 英式男声 | en_male_bob |
| 澳洲女声 | en_female_sarah |

#### 输入参数
### jp

```rust
text: &str,
lang: &str,
needs: HashMap<String, String>, // 插件需要的其他配置信息,由info.json定义
```

#### 返回值

```rust
// 返回用Value包裹的字节数组
let result = res.to_vec();
return Ok(json!(result));
```

#### 测试/编译

```bash
cargo test --package plugin --lib -- tests --nocapture # 运行测试用例
cargo build --release # 编译
```

### 4. 打包 pot 插件

1.`target/release`目录找到`plugin.dll`(Windows)/`libplugin.dylib`(MacOS)/`libplugin.so`(Linux)文件,统一删除`lib`前缀.

2.`plugin.dll`/`libplugin.dylib`/`libplugin.so`文件和`info.json`以及图标文件压缩为 zip 文件。

3. 将文件重命名为`<插件id>.potext`,例如`[plugin].com.pot-app.lingva_tts.potext`,即可得到 pot 需要的插件。

## 自动编译打包

本仓库配置了 Github Actions,可以实现推送后自动编译打包插件。

每次将仓库推送到 GitHub 之后 actions 会自动运行,将打包好的插件上传到 artifact,在 actions 页面可以下载

每次提交 Tag 之后,actions 会自动运行,将打包好的插件上传到 release,在 release 页面可以下载打包好的插件

> 注意需要在仓库设置中添加一个名为`TOKEN`的 secret,值为一个有权限的 GitHub Token,用于上传 release
| Name | Value |
|------|----------------|
| 日语男声 | jp_male_satoshi |
| 日语女声 | jp_female_mai |
71 changes: 0 additions & 71 deletions README_EN.md

This file was deleted.

52 changes: 26 additions & 26 deletions info.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
{
"id": "[plugin].com.pot-app.lingva_tts",
"id": "[plugin].com.TechDecryptor.volcengine_tts",
"plugin_type": "tts",
"icon": "lingva.svg",
"display": "Lingva",
"homepage": "https://github.com/pot-app/pot-app-tts-plugin-template",
"needs": [{ "key": "requestPath", "display": "请求地址" }],
"icon": "volcengine.svg",
"display": "火山 TTS",
"homepage": "https://github.com/TechDecryptor/pot-app-tts-plugin-volcengine",
"needs": [{ "key": "speaker", "display": "Speaker" }],
"language": {
"zh_cn": "zh",
"zh_tw": "zh_HANT",
"en": "en",
"ja": "ja",
"ko": "ko",
"fr": "fr",
"es": "es",
"ru": "ru",
"de": "de",
"it": "it",
"tr": "tr",
"pt": "pt",
"pt_br": "pt",
"vi": "vi",
"id": "id",
"th": "th",
"ms": "ms",
"ar": "ar",
"hi": "hi",
"mn_cy": "mn",
"km": "km"
"zh_cn": "",
"zh_tw": "",
"en": "",
"ja": "",
"ko": "",
"fr": "",
"es": "",
"ru": "",
"de": "",
"it": "",
"tr": "",
"pt_pt": "",
"pt_br": "",
"vi": "",
"id": "",
"th": "",
"ms": "",
"ar": "",
"hi": "",
"mn_cy": "",
"km": ""
}
}
Loading

0 comments on commit ce16beb

Please sign in to comment.