Feat remove extra settings when setup (#328)

* required login only when setup

* add default library path test

* add more whisper model options
This commit is contained in:
an-lee
2024-02-19 16:06:47 +08:00
committed by GitHub
parent f75912ff8b
commit 0aae7bcdd9
3 changed files with 57 additions and 95 deletions

View File

@@ -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();
});

View File

@@ -11,6 +11,13 @@ 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",
@@ -18,6 +25,13 @@ export const WHISPER_MODELS_OPTIONS = [
},
{
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",
@@ -25,6 +39,13 @@ export const WHISPER_MODELS_OPTIONS = [
},
{
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",
@@ -32,11 +53,32 @@ export const WHISPER_MODELS_OPTIONS = [
},
{
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",

View File

@@ -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>
);