Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat remove extra settings when setup #328

Merged
merged 3 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions enjoy/e2e/main.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,8 @@ test("valid ffmpeg command", async () => {
});
expect(res).toBeTruthy();
});

test("should setup default library path", async () => {
const settings = fs.readJsonSync(path.join(resultDir, "settings.json"));
expect(settings.library).not.toBeNull();
});
42 changes: 42 additions & 0 deletions enjoy/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,74 @@ export const REPO_URL = "https://github.com/xiaolai/everyone-can-use-english";
export const WHISPER_MODELS_OPTIONS = [
{
type: "tiny",
name: "ggml-tiny.bin",
size: "75 MB",
sha: "bd577a113a864445d4c299885e0cb97d4ba92b5f",
url: "https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-tiny.bin",
},
{
type: "tiny.en",
name: "ggml-tiny.en.bin",
size: "75 MB",
sha: "c78c86eb1a8faa21b369bcd33207cc90d64ae9df",
url: "https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-tiny.en.bin",
},
{
type: "base",
name: "ggml-base.bin",
size: "142 MB",
sha: "465707469ff3a37a2b9b8d8f89f2f99de7299dac",
url: "https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-base.bin",
},
{
type: "base.en",
name: "ggml-base.en.bin",
size: "142 MB",
sha: "137c40403d78fd54d454da0f9bd998f78703390c",
url: "https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-base.en.bin",
},
{
type: "small",
name: "ggml-small.bin",
size: "466 MB",
sha: "55356645c2b361a969dfd0ef2c5a50d530afd8d5",
url: "https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-small.bin",
},
{
type: "small.en",
name: "ggml-small.en.bin",
size: "466 MB",
sha: "db8a495a91d927739e50b3fc1cc4c6b8f6c2d022",
url: "https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-small.en.bin",
},
{
type: "medium",
name: "ggml-medium.bin",
size: "1.5 GB",
sha: "fd9727b6e1217c2f614f9b698455c4ffd82463b4",
url: "https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-medium.bin",
},
{
type: "medium.en",
name: "ggml-medium.en.bin",
size: "1.5 GB",
sha: "8c30f0e44ce9560643ebd10bbe50cd20eafd3723",
url: "https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-medium.en.bin",
},
{
type: "large-v1",
name: "ggml-large-v1.bin",
size: "2.9 GB",
sha: "b1caaf735c4cc1429223d5a74f0f4d0b9b59a299",
url: "https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-large-v1.bin",
},
{
type: "large-v2",
name: "ggml-large-v2.bin",
size: "2.9 GB",
sha: "0f4c8e34f21cf1a914c59d8b3ce882345ad349d6",
url: "https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-large-v2.bin",
},
{
type: "large",
name: "ggml-large-v3.bin",
Expand Down
105 changes: 10 additions & 95 deletions enjoy/src/renderer/pages/landing.tsx
Original file line number Diff line number Diff line change
@@ -1,115 +1,30 @@
import { t } from "i18next";
import { useState, useContext, useEffect } from "react";
import { Button, Progress } from "@renderer/components/ui";
import { useContext } from "react";
import { Button } from "@renderer/components/ui";
import { Link } from "react-router-dom";
import { LoginForm, ChooseLibraryPathInput } from "@renderer/components";
import {
AppSettingsProviderContext,
AISettingsProviderContext,
} from "@renderer/context";
import { CheckCircle2Icon } from "lucide-react";
import { LoginForm } from "@renderer/components";
import { AppSettingsProviderContext } from "@renderer/context";

export default () => {
const [currentStep, setCurrentStep] = useState<number>(1);
const [currentStepValid, setCurrentStepValid] = useState<boolean>(false);

const { user, libraryPath, initialized } = useContext(
AppSettingsProviderContext
);
const { whisperConfig } = useContext(AISettingsProviderContext);
const totalSteps = 3;

useEffect(() => {
validateCurrentStep();
}, [currentStep, user, whisperConfig]);

const validateCurrentStep = async () => {
switch (currentStep) {
case 1:
setCurrentStepValid(!!user);
break;
case 2:
setCurrentStepValid(!!libraryPath);
break;
case 3:
setCurrentStepValid(initialized);
break;
default:
setCurrentStepValid(false);
}
};

const nextStep = () => {
if (currentStepValid && currentStep < totalSteps) {
setCurrentStep(currentStep + 1);
}
};

const prevStep = () => {
if (currentStep > 1) {
setCurrentStep(currentStep - 1);
}
};

const stepTitles: any = {
1: {
title: t("login"),
subtitle: t("loginBeforeYouStart"),
},
2: {
title: t("libraryPath"),
subtitle: t("whereYourResourcesAreStored"),
},
3: {
title: t("finish"),
subtitle: t("youAreReadyToGo"),
},
};
const { initialized } = useContext(AppSettingsProviderContext);

return (
<div className="h-screen w-full px-4 py-6 lg:px-8 flex flex-col">
<div className="text-center">
<div className="text-lg font-mono py-6">
{t("nthStep", { current: currentStep, totalSteps })}:{" "}
{stepTitles[currentStep].title}
</div>
<div className="text-sm opacity-70">
{stepTitles[currentStep].subtitle}
</div>
<div className="text-lg font-mono py-6">{t("login")}</div>
<div className="text-sm opacity-70">{t("loginBeforeYouStart")}</div>
</div>
<div className="flex-1 flex justify-center items-center">
{currentStep == 1 && <LoginForm />}
{currentStep == 2 && <ChooseLibraryPathInput />}
{currentStep == 3 && (
<div className="flex justify-center items-center">
<CheckCircle2Icon className="text-green-500 w-24 h-24" />
</div>
)}
<LoginForm />
</div>
<div className="mt-auto">
<div className="flex mb-4 justify-end space-x-4">
{currentStep > 1 && (
<Button className="w-24" variant="ghost" onClick={prevStep}>
{t("previousStep")}
</Button>
)}
{totalSteps == currentStep ? (
{initialized && (
<Link to="/" replace>
<Button className="w-24">{t("finish")}</Button>
<Button className="w-24">{t("startToUse")}</Button>
</Link>
) : (
<Button
disabled={!currentStepValid}
className="w-24"
onClick={nextStep}
>
{t("nextStep")}
</Button>
)}
</div>
<div className="mb-4">
<Progress value={(currentStep / totalSteps) * 100} />
</div>
</div>
</div>
);
Expand Down
Loading