Skip to content

Commit 6ebeb31

Browse files
committed
美化UI
1 parent 051f35c commit 6ebeb31

36 files changed

Lines changed: 1487 additions & 1187 deletions

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# 默认忽略的文件
22
/shelf/
33
/workspace.xml
4-
.idea/
4+
./.idea/
5+
./build/
56
# 基于编辑器的 HTTP 客户端请求
67
/httpRequests/
78
# Datasource local storage ignored files

.idea/encodings.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

include/Configure.h

Lines changed: 178 additions & 173 deletions
Original file line numberDiff line numberDiff line change
@@ -6,197 +6,202 @@
66
#include <iostream>
77

88
struct TranslateData {
9-
std::string appId;
10-
std::string APIKey;
11-
std::string proxy = "";
9+
std::string appId;
10+
std::string APIKey;
11+
std::string proxy = "";
1212
};
1313

1414
struct OpenAIData {
15-
bool useLocalModel = false;
16-
std::string modelPath = "model/ChatGLM/";
17-
std::string api_key;
18-
std::string model = "gpt-3.5-turbo";
19-
std::string proxy = "";
15+
bool useLocalModel = false;
16+
std::string modelPath = "model/ChatGLM/";
17+
std::string api_key;
18+
std::string model = "gpt-3.5-turbo";
19+
std::string proxy = "";
2020
};
2121

2222
struct VitsTask {
23-
std::string model;
24-
std::string config;
25-
std::string text;
26-
std::string outpath = "tmp.wav";
27-
char choice = 't';
28-
int sid = 0;
29-
bool escape = false;
23+
std::string model;
24+
std::string config;
25+
std::string text;
26+
std::string outpath = "tmp.wav";
27+
char choice = 't';
28+
int sid = 0;
29+
bool escape = false;
3030
};
3131

3232
struct VITSData {
33-
std::string model;
34-
std::string config;
35-
std::string lanType = "jp";
33+
bool enable = false;
34+
std::string model;
35+
std::string config;
36+
std::string lanType = "jp";
3637
};
3738

3839
struct WhisperData {
39-
bool useLocalModel = false;
40-
std::string model = "model/Whisper/ggml-base.bin";
41-
40+
bool enable = false;
41+
bool useLocalModel = false;
42+
std::string model = "model/Whisper/ggml-base.bin";
4243
};
4344

4445
struct Configure {
45-
OpenAIData openAi;
46-
TranslateData baiDuTranslator;
47-
VITSData vits;
48-
WhisperData whisper;
46+
OpenAIData openAi;
47+
TranslateData baiDuTranslator;
48+
VITSData vits;
49+
WhisperData whisper;
4950
};
5051

5152
namespace YAML {
52-
template<>
53-
struct convert<TranslateData> {
54-
static Node encode(const TranslateData &data) {
55-
Node node;
56-
node["appId"] = data.appId;
57-
node["APIKey"] = data.APIKey;
58-
node["proxy"] = data.proxy;
59-
return node;
60-
}
61-
62-
static bool decode(const Node &node, TranslateData &data) {
63-
if (!node["appId"] || !node["APIKey"]) {
64-
return false;
65-
}
66-
data.proxy = node["proxy"].as<std::string>();
67-
data.appId = node["appId"].as<std::string>();
68-
data.APIKey = node["APIKey"].as<std::string>();
69-
return true;
70-
}
71-
};
72-
73-
template<>
74-
struct convert<OpenAIData> {
75-
static Node encode(const OpenAIData &data) {
76-
Node node;
77-
node["useLocalModel"] = data.useLocalModel;
78-
node["modelPath"] = data.modelPath;
79-
node["api_key"] = data.api_key;
80-
node["model"] = data.model;
81-
node["proxy"] = data.proxy;
82-
return node;
83-
}
84-
85-
static bool decode(const Node &node, OpenAIData &data) {
86-
if (!node["api_key"] && !node["useLocalModel"]) {
87-
return false;
88-
}
89-
data.api_key = node["api_key"].as<std::string>();
90-
data.modelPath = node["modelPath"].as<std::string>();
91-
data.useLocalModel = node["useLocalModel"].as<bool>();
92-
if (node["model"]) {
93-
data.model = node["model"].as<std::string>();
94-
}
95-
data.proxy = node["proxy"].as<std::string>();
96-
return true;
97-
}
98-
};
99-
100-
template<>
101-
struct convert<VitsTask> {
102-
static Node encode(const VitsTask &task) {
103-
Node node;
104-
node["model"] = task.model;
105-
node["config"] = task.config;
106-
node["text"] = task.text;
107-
node["outpath"] = task.outpath;
108-
node["choice"] = task.choice;
109-
node["sid"] = task.sid;
110-
node["escape"] = task.escape;
111-
return node;
112-
}
113-
114-
static bool decode(const Node &node, VitsTask &task) {
115-
if (!node["model"] || !node["config"] || !node["text"]) {
116-
return false;
117-
}
118-
task.model = node["model"].as<std::string>();
119-
task.config = node["config"].as<std::string>();
120-
task.text = node["text"].as<std::string>();
121-
if (node["choice"]) {
122-
task.choice = node["choice"].as<char>();
123-
}
124-
if (node["outpath"]) {
125-
task.outpath = node["outpath"].as<std::string>();
126-
}
127-
if (node["sid"]) {
128-
task.sid = node["sid"].as<int>();
129-
}
130-
if (node["escape"]) {
131-
task.escape = node["escape"].as<bool>();
132-
}
133-
return true;
134-
}
135-
};
136-
137-
template<>
138-
struct convert<VITSData> {
139-
static Node encode(const VITSData &data) {
140-
Node node;
141-
node["model"] = data.model;
142-
node["config"] = data.config;
143-
node["lanType"] = data.lanType;
144-
return node;
145-
}
146-
147-
static bool decode(const Node &node, VITSData &data) {
148-
if (!node["model"] || !node["config"]) {
149-
return false;
150-
}
151-
data.model = node["model"].as<std::string>();
152-
data.config = node["config"].as<std::string>();
153-
if (node["lanType"]) {
154-
data.lanType = node["lanType"].as<std::string>();
155-
}
156-
return true;
157-
}
158-
};
159-
160-
template<>
161-
struct convert<WhisperData> {
162-
static Node encode(const WhisperData &data) {
163-
Node node;
164-
node["useLocalModel"] = data.useLocalModel;
165-
node["model"] = data.model;
166-
return node;
167-
}
168-
169-
static bool decode(const Node &node, WhisperData &data) {
170-
data.useLocalModel = node["useLocalModel"].as<bool>();
171-
if (node["model"]) {
172-
data.model = node["model"].as<std::string>();
173-
}
174-
return true;
175-
}
176-
};
177-
178-
template<>
179-
struct convert<Configure> {
180-
static Node encode(const Configure &config) {
181-
Node node;
182-
node["openAi"] = config.openAi;
183-
node["baiDuTranslator"] = config.baiDuTranslator;
184-
node["vits"] = config.vits;
185-
node["whisper"] = config.whisper;
186-
return node;
187-
}
188-
189-
static bool decode(const Node &node, Configure &config) {
190-
if (!node["openAi"] || !node["baiDuTranslator"] || !node["vits"]) {
191-
return false;
192-
}
193-
config.openAi = node["openAi"].as<OpenAIData>();
194-
config.baiDuTranslator = node["baiDuTranslator"].as<TranslateData>();
195-
config.vits = node["vits"].as<VITSData>();
196-
config.whisper = node["whisper"].as<WhisperData>();
197-
return true;
198-
}
199-
};
53+
template<>
54+
struct convert<TranslateData> {
55+
static Node encode(const TranslateData& data) {
56+
Node node;
57+
node["appId"] = data.appId;
58+
node["APIKey"] = data.APIKey;
59+
node["proxy"] = data.proxy;
60+
return node;
61+
}
62+
63+
static bool decode(const Node& node, TranslateData& data) {
64+
if (!node["appId"] || !node["APIKey"]) {
65+
return false;
66+
}
67+
data.proxy = node["proxy"].as<std::string>();
68+
data.appId = node["appId"].as<std::string>();
69+
data.APIKey = node["APIKey"].as<std::string>();
70+
return true;
71+
}
72+
};
73+
74+
template<>
75+
struct convert<OpenAIData> {
76+
static Node encode(const OpenAIData& data) {
77+
Node node;
78+
node["useLocalModel"] = data.useLocalModel;
79+
node["modelPath"] = data.modelPath;
80+
node["api_key"] = data.api_key;
81+
node["model"] = data.model;
82+
node["proxy"] = data.proxy;
83+
return node;
84+
}
85+
86+
static bool decode(const Node& node, OpenAIData& data) {
87+
if (!node["api_key"] && !node["useLocalModel"]) {
88+
return false;
89+
}
90+
data.api_key = node["api_key"].as<std::string>();
91+
data.modelPath = node["modelPath"].as<std::string>();
92+
data.useLocalModel = node["useLocalModel"].as<bool>();
93+
if (node["model"]) {
94+
data.model = node["model"].as<std::string>();
95+
}
96+
data.proxy = node["proxy"].as<std::string>();
97+
return true;
98+
}
99+
};
100+
101+
template<>
102+
struct convert<VitsTask> {
103+
static Node encode(const VitsTask& task) {
104+
Node node;
105+
node["model"] = task.model;
106+
node["config"] = task.config;
107+
node["text"] = task.text;
108+
node["outpath"] = task.outpath;
109+
node["choice"] = task.choice;
110+
node["sid"] = task.sid;
111+
node["escape"] = task.escape;
112+
return node;
113+
}
114+
115+
static bool decode(const Node& node, VitsTask& task) {
116+
if (!node["model"] || !node["config"] || !node["text"]) {
117+
return false;
118+
}
119+
task.model = node["model"].as<std::string>();
120+
task.config = node["config"].as<std::string>();
121+
task.text = node["text"].as<std::string>();
122+
if (node["choice"]) {
123+
task.choice = node["choice"].as<char>();
124+
}
125+
if (node["outpath"]) {
126+
task.outpath = node["outpath"].as<std::string>();
127+
}
128+
if (node["sid"]) {
129+
task.sid = node["sid"].as<int>();
130+
}
131+
if (node["escape"]) {
132+
task.escape = node["escape"].as<bool>();
133+
}
134+
return true;
135+
}
136+
};
137+
138+
template<>
139+
struct convert<VITSData> {
140+
static Node encode(const VITSData& data) {
141+
Node node;
142+
node["model"] = data.model;
143+
node["config"] = data.config;
144+
node["lanType"] = data.lanType;
145+
node["enable"] = data.enable;
146+
return node;
147+
}
148+
149+
static bool decode(const Node& node, VITSData& data) {
150+
if (!node["model"] || !node["config"]) {
151+
return false;
152+
}
153+
data.enable = node["enable"].as<bool>();
154+
data.model = node["model"].as<std::string>();
155+
data.config = node["config"].as<std::string>();
156+
if (node["lanType"]) {
157+
data.lanType = node["lanType"].as<std::string>();
158+
}
159+
return true;
160+
}
161+
};
162+
163+
template<>
164+
struct convert<WhisperData> {
165+
static Node encode(const WhisperData& data) {
166+
Node node;
167+
node["enable"] = data.enable;
168+
node["useLocalModel"] = data.useLocalModel;
169+
node["model"] = data.model;
170+
return node;
171+
}
172+
173+
static bool decode(const Node& node, WhisperData& data) {
174+
data.useLocalModel = node["useLocalModel"].as<bool>();
175+
data.enable = node["enable"].as<bool>();
176+
if (node["model"]) {
177+
data.model = node["model"].as<std::string>();
178+
}
179+
return true;
180+
}
181+
};
182+
183+
template<>
184+
struct convert<Configure> {
185+
static Node encode(const Configure& config) {
186+
Node node;
187+
node["openAi"] = config.openAi;
188+
node["baiDuTranslator"] = config.baiDuTranslator;
189+
node["vits"] = config.vits;
190+
node["whisper"] = config.whisper;
191+
return node;
192+
}
193+
194+
static bool decode(const Node& node, Configure& config) {
195+
if (!node["openAi"] || !node["baiDuTranslator"] || !node["vits"]) {
196+
return false;
197+
}
198+
config.openAi = node["openAi"].as<OpenAIData>();
199+
config.baiDuTranslator = node["baiDuTranslator"].as<TranslateData>();
200+
config.vits = node["vits"].as<VITSData>();
201+
config.whisper = node["whisper"].as<WhisperData>();
202+
return true;
203+
}
204+
};
200205
}
201206

202207
#endif

0 commit comments

Comments
 (0)