Skip to content

Commit ff487dc

Browse files
authored
Merge pull request #161 from dorlanpabon/main
Add i18n traductor, english, spanish, chinese, ....
2 parents 8c6ee65 + 1c24139 commit ff487dc

File tree

24 files changed

+4870
-2700
lines changed

24 files changed

+4870
-2700
lines changed

electron/main/index.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import api from "../utils/api";
55
import edgeApi from "../utils/edge-api";
66
import azureApi from "../utils/azure-api";
77
import logger from "../utils/log";
8+
import { gptApi } from "../utils/gpt-api";
89

910
// Disable GPU Acceleration for Windows 7
1011
//if (release().startsWith("6.1")) app.disableHardwareAcceleration();
@@ -39,7 +40,7 @@ const indexHtml = join(ROOT_PATH.dist, "index.html");
3940

4041
async function createWindow() {
4142
win = new BrowserWindow({
42-
width: 900,
43+
width: 1200,
4344
minWidth: 900,
4445
minHeight: 650,
4546
height: 650,
@@ -184,8 +185,13 @@ ipcMain.handle("edgeApi", async (event, ssml) => {
184185
});
185186

186187
ipcMain.handle("azureApi", async (event, ssml, key, region) => {
187-
const res = azureApi(ssml, key, region)
188-
return res;
188+
const res = azureApi(ssml, key, region)
189+
return res;
190+
});
191+
// const result = await ipcRenderer.invoke("promptGPT", promptGPT, model, key);
192+
ipcMain.handle("promptGPT", async (event, promptGPT, model, key) => {
193+
const res = gptApi(promptGPT, model, key);
194+
return res;
189195
});
190196

191197
ipcMain.handle("openFolderSelector", async (event) => {

electron/utils/azure-api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import logger from "../utils/log";
2-
var sdk = require("microsoft-cognitiveservices-speech-sdk");
2+
import * as sdk from "microsoft-cognitiveservices-speech-sdk";
33

44
const azureApi = (ssml: string, key: string, region: string) => {
55
const speechConfig = sdk.SpeechConfig.fromSubscription(key, region);

electron/utils/gpt-api.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import OpenAI from 'openai';
2+
import logger from "../utils/log";
3+
4+
const gptApi = async (promptGPT: string, model: string, key: string) => {
5+
logger.info(`promptGPT: ${promptGPT}`);
6+
const openai = new OpenAI({
7+
apiKey: key,
8+
});
9+
logger.info(`model: ${model}`);
10+
const chatCompletion = await openai.chat.completions.create({
11+
messages: [{ role: 'user', content: promptGPT }],
12+
model: model,
13+
});
14+
logger.info(`chatCompletion: ${JSON.stringify(chatCompletion)}`);
15+
16+
return chatCompletion.choices[0].message.content;
17+
}
18+
19+
export { gptApi };

index.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
<meta charset="UTF-8" />
55
<link rel="icon" href="/favicon.ico" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7-
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
7+
<!-- <meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" /> -->
8+
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline' 'unsafe-eval';">
9+
810
<title>Vite App</title>
911
</head>
1012
<body>

0 commit comments

Comments
 (0)