Skip to content

Commit

Permalink
Merge pull request #161 from dorlanpabon/main
Browse files Browse the repository at this point in the history
Add i18n traductor, english, spanish, chinese, ....
  • Loading branch information
LokerL authored Nov 15, 2023
2 parents 1ba261a + 70b63d5 commit 9d2eb91
Show file tree
Hide file tree
Showing 24 changed files with 4,870 additions and 2,700 deletions.
12 changes: 9 additions & 3 deletions electron/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import api from "../utils/api";
import edgeApi from "../utils/edge-api";
import azureApi from "../utils/azure-api";
import logger from "../utils/log";
import { gptApi } from "../utils/gpt-api";

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

async function createWindow() {
win = new BrowserWindow({
width: 900,
width: 1200,
minWidth: 900,
minHeight: 650,
height: 650,
Expand Down Expand Up @@ -184,8 +185,13 @@ ipcMain.handle("edgeApi", async (event, ssml) => {
});

ipcMain.handle("azureApi", async (event, ssml, key, region) => {
const res = azureApi(ssml, key, region)
return res;
const res = azureApi(ssml, key, region)
return res;
});
// const result = await ipcRenderer.invoke("promptGPT", promptGPT, model, key);
ipcMain.handle("promptGPT", async (event, promptGPT, model, key) => {
const res = gptApi(promptGPT, model, key);
return res;
});

ipcMain.handle("openFolderSelector", async (event) => {
Expand Down
2 changes: 1 addition & 1 deletion electron/utils/azure-api.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logger from "../utils/log";
var sdk = require("microsoft-cognitiveservices-speech-sdk");
import * as sdk from "microsoft-cognitiveservices-speech-sdk";

const azureApi = (ssml: string, key: string, region: string) => {
const speechConfig = sdk.SpeechConfig.fromSubscription(key, region);
Expand Down
19 changes: 19 additions & 0 deletions electron/utils/gpt-api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import OpenAI from 'openai';
import logger from "../utils/log";

const gptApi = async (promptGPT: string, model: string, key: string) => {
logger.info(`promptGPT: ${promptGPT}`);
const openai = new OpenAI({
apiKey: key,
});
logger.info(`model: ${model}`);
const chatCompletion = await openai.chat.completions.create({
messages: [{ role: 'user', content: promptGPT }],
model: model,
});
logger.info(`chatCompletion: ${JSON.stringify(chatCompletion)}`);

return chatCompletion.choices[0].message.content;
}

export { gptApi };
4 changes: 3 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
<!-- <meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" /> -->
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline' 'unsafe-eval';">

<title>Vite App</title>
</head>
<body>
Expand Down
Loading

0 comments on commit 9d2eb91

Please sign in to comment.