Skip to content

Commit

Permalink
fix(GUI): the GUI config is not used by the backend
Browse files Browse the repository at this point in the history
  • Loading branch information
jersou committed Oct 6, 2024
1 parent 2421902 commit 9a41b26
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 30 deletions.
1 change: 0 additions & 1 deletion gui/frontend/src/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export function Config({
? "coqui"
: "os";
const onTtsChange = (event: any) => {
console.log(event.target.value);
switch (event.target.value) {
case "os":
setOpt({
Expand Down
35 changes: 6 additions & 29 deletions gui/gui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { throttle } from "@es-toolkit/es-toolkit";
import type { ModOptions } from "../types.ts";
import { contentType } from "@std/media-types";
import { red } from "@std/fmt/colors";
import { cleanOption } from "../utils/utils.ts";

type Assets = {
[k: string]: { type: string; content: Uint8Array; route: URLPattern };
Expand Down Expand Up @@ -132,42 +133,18 @@ class StudioPackGeneratorGui {
route: new URLPattern({ pathname: "/api/runSpg" }),
exec: async (_match: URLPatternResult, request: Request) => {
const opt = await request.json();
const optFiltered = {
addDelay: opt.addDelay,
autoNextStoryTransition: opt.autoNextStoryTransition,
selectNextStoryAtEnd: opt.selectNextStoryAtEnd,
nightMode: opt.nightMode,
skipAudioConvert: opt.skipAudioConvert,
skipImageConvert: opt.skipImageConvert,
skipAudioItemGen: opt.skipAudioItemGen,
skipExtractImageFromMp3: opt.skipExtractImageFromMp3,
skipImageItemGen: opt.skipImageItemGen,
skipNotRss: opt.skipNotRss,
skipRssImageDl: opt.skipRssImageDl,
skipWsl: opt.skipWsl,
skipZipGeneration: opt.skipZipGeneration,
useOpenAiTts: opt.useOpenAiTts,
lang: opt.lang,
outputFolder: opt.outputFolder,
seekStory: opt.seekStory,
openAiApiKey: opt.openAiApiKey,
openAiModel: opt.openAiModel,
openAiVoice: opt.openAiVoice,
};
const configPath = `${this.#opt!.storyPath}/config.json`;
console.log(`Write config to ${configPath}`);
await Deno.writeTextFile(
configPath,
JSON.stringify(optFiltered, null, " "),
);
const optFiltered = cleanOption(opt);
console.log(`Run SPG on ${this.#opt!.storyPath}`);

(async () => {
console.log("SPG start");
this.#sendWs(JSON.stringify({ type: "SPG-start" }));

try {
const res = await runSpg(this.#opt!);
const res = await runSpg({
...optFiltered,
storyPath: this.#opt!.storyPath,
});
console.log("SPG end");
this.#sendWs(JSON.stringify({ type: "SPG-end", ok: res }));
} catch (error) {
Expand Down

0 comments on commit 9a41b26

Please sign in to comment.