mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-17 07:04:36 +00:00
lots of voice designer updates
This commit is contained in:
1 parent
7edab2f336
commit
a0b61389aa
12 files changed
+241
-124
No files matched your search
@@ -0,0 +1,29 @@
|
||||
import React from "react";
|
||||
import Button from "../Button";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import { faArrowLeft } from "@fortawesome/pro-solid-svg-icons";
|
||||
|
||||
interface BackButtonProps {
|
||||
onClick?: () => void;
|
||||
}
|
||||
|
||||
const BackButton: React.FC<BackButtonProps> = ({ onClick }) => {
|
||||
const handleBack = () => {
|
||||
if (onClick) {
|
||||
onClick();
|
||||
} else {
|
||||
window.history.back();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Button
|
||||
icon={faArrowLeft}
|
||||
label="Back"
|
||||
variant="link"
|
||||
onClick={handleBack}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default BackButton;
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from "./BackButton";
|
||||
@@ -6,6 +6,7 @@ interface PanelProps {
|
||||
mb?: boolean;
|
||||
mt?: boolean;
|
||||
className?: string;
|
||||
clear?: boolean;
|
||||
}
|
||||
|
||||
export default function Panel({
|
||||
@@ -14,10 +15,13 @@ export default function Panel({
|
||||
mb,
|
||||
mt,
|
||||
className,
|
||||
clear,
|
||||
}: PanelProps) {
|
||||
return (
|
||||
<div
|
||||
className={`panel ${padding ? "p-3 py-4 p-md-4" : ""}
|
||||
className={`panel ${clear && "panel-clear"} ${
|
||||
padding ? "p-3 py-4 p-md-4" : ""
|
||||
}
|
||||
${mb ? "mb-4" : ""} ${mt ? "mt-4" : ""} overflow-hidden ${
|
||||
className || ""
|
||||
}`}
|
||||
|
||||
@@ -16,6 +16,8 @@ interface PageHeaderProps {
|
||||
buttonTo?: string;
|
||||
buttonIcon?: IconDefinition;
|
||||
buttonOnClick?: () => void;
|
||||
withImage?: boolean;
|
||||
imageUrl?: string;
|
||||
}
|
||||
|
||||
export default function PageHeader({
|
||||
@@ -30,21 +32,61 @@ export default function PageHeader({
|
||||
buttonTo,
|
||||
buttonIcon,
|
||||
buttonOnClick,
|
||||
withImage,
|
||||
imageUrl,
|
||||
}: PageHeaderProps) {
|
||||
const icon = (
|
||||
<>{titleIcon && <FontAwesomeIcon icon={titleIcon} className="me-3" />}</>
|
||||
);
|
||||
|
||||
if (withImage) {
|
||||
return (
|
||||
<div className="pt-3 pb-4 pt-lg-4">
|
||||
<Panel clear={true}>
|
||||
<div className="row">
|
||||
<div className="d-flex flex-column col-lg-7 justify-content-center gap-4">
|
||||
<div>
|
||||
<h1 className="fw-bold">
|
||||
{/* {icon} */}
|
||||
{title}
|
||||
</h1>
|
||||
<p className="opacity-75">{subText}</p>
|
||||
</div>
|
||||
{showButton && (
|
||||
<div className="d-md-flex">
|
||||
<Button
|
||||
icon={buttonIcon}
|
||||
variant={buttonVariant}
|
||||
label={buttonLabel}
|
||||
to={buttonTo}
|
||||
onClick={buttonOnClick}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="d-none d-lg-block col-lg-5">
|
||||
{imageUrl && (
|
||||
<img src={imageUrl} alt="Header" className="img-fluid my-3" />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
{extension && <div>{extension}</div>}
|
||||
</Panel>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// Default view without image.
|
||||
return (
|
||||
<div className="pt-3 pb-4 pt-lg-4">
|
||||
<Panel padding>
|
||||
<div className="d-flex flex-column gap-4">
|
||||
<div>
|
||||
<div className="d-flex">
|
||||
<h2 className="fw-bold flex-grow-1">
|
||||
<h1 className="fw-bold flex-grow-1">
|
||||
{icon}
|
||||
{title}
|
||||
</h2>
|
||||
</h1>
|
||||
<div className="d-none d-md-block">
|
||||
{showButton && (
|
||||
<Button
|
||||
|
||||
@@ -1613,8 +1613,8 @@ textarea {
|
||||
.fakeyou-refresh {
|
||||
.container-panel {
|
||||
width: 100%;
|
||||
padding-right: var(--bs-gutter-x, 1rem);
|
||||
padding-left: var(--bs-gutter-x, 1rem);
|
||||
padding-right: var(--bs-gutter-x, 1.75rem);
|
||||
padding-left: var(--bs-gutter-x, 1.75rem);
|
||||
margin-right: auto;
|
||||
margin-left: auto;
|
||||
max-width: 1200px;
|
||||
|
||||
@@ -81,7 +81,7 @@ import { UploadVoiceConversionModel } from "./pages/upload/UploadVoiceConversion
|
||||
import { VoiceConversionModelListItem } from "@storyteller/components/src/api/voice_conversion/ListVoiceConversionModels";
|
||||
import { CommunityCommissionsPage } from "./pages/contest/CommunityCommissionsPage";
|
||||
import { ProductUsageInfoPage } from "./pages/product_usage_info/ProductUsageInfoPage";
|
||||
import { VoiceDesignerCreatePage } from "./pages/voice_designer/VoiceDesignerCreatePage";
|
||||
import { VoiceDesignerFormPage } from "./pages/voice_designer/VoiceDesignerFormPage";
|
||||
import { GenerateSpeechPage } from "./pages/generate_speech/GenerateSpeechPage";
|
||||
import VcModelViewPage from "./pages/vc/vc_model_view/VcModelViewPage";
|
||||
import VcModelEditPage from "./pages/vc/vc_model_edit/VcModelEditPage";
|
||||
@@ -618,11 +618,28 @@ class PageContainer extends React.Component<
|
||||
<VocodesPage />
|
||||
</Route>
|
||||
|
||||
<Route path="/voice-designer/create">
|
||||
<VoiceDesignerCreatePage />
|
||||
</Route>
|
||||
{/* Route for initial voice creation */}
|
||||
<Route
|
||||
exact
|
||||
path="/voice-designer/create"
|
||||
component={VoiceDesignerFormPage}
|
||||
/>
|
||||
|
||||
<Route path="/voice-designer/">
|
||||
{/* Route for editing the dataset details */}
|
||||
<Route
|
||||
exact
|
||||
path="/voice-designer/dataset/:dataset_token/edit"
|
||||
component={VoiceDesignerFormPage}
|
||||
/>
|
||||
|
||||
{/* Route for handling dataset token for uploading samples */}
|
||||
<Route
|
||||
exact
|
||||
path="/voice-designer/dataset/:dataset_token/upload"
|
||||
component={VoiceDesignerFormPage}
|
||||
/>
|
||||
|
||||
<Route path="/voice-designer">
|
||||
<VoiceDesignerMainPage />
|
||||
</Route>
|
||||
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
import React, { useState } from "react";
|
||||
import { faWaveform } from "@fortawesome/pro-solid-svg-icons";
|
||||
import { usePrefixedDocumentTitle } from "common/UsePrefixedDocumentTitle";
|
||||
import Panel from "components/common/Panel";
|
||||
import { Stepper } from "./components/Stepper";
|
||||
import { StepperControls } from "./components/StepperControls";
|
||||
import { UploadSamples } from "./components/steps/UploadSamples";
|
||||
import { VoiceDetails } from "./components/steps/VoiceDetails";
|
||||
import { Complete } from "./components/steps/Complete";
|
||||
import { Processing } from "./components/steps/Processing";
|
||||
import PageHeader from "components/layout/PageHeader";
|
||||
import Container from "components/common/Container";
|
||||
|
||||
function VoiceDesignerCreatePage() {
|
||||
usePrefixedDocumentTitle("Voice Designer");
|
||||
|
||||
const [currentStep, setCurrentStep] = useState(0);
|
||||
const steps = ["Voice Details", "Upload Samples", "Processing", "Complete"];
|
||||
|
||||
const displayStep = (step: any) => {
|
||||
switch (step) {
|
||||
case 0:
|
||||
return <VoiceDetails />;
|
||||
case 1:
|
||||
return <UploadSamples />;
|
||||
case 2:
|
||||
return <Processing />;
|
||||
case 3:
|
||||
return <Complete />;
|
||||
default:
|
||||
}
|
||||
};
|
||||
|
||||
const handleBack = () => {
|
||||
if (currentStep > 0) {
|
||||
setCurrentStep(currentStep - 1);
|
||||
}
|
||||
};
|
||||
|
||||
const handleNext = async () => {
|
||||
if (currentStep === 1) {
|
||||
// When moving from Upload Samples to Processing
|
||||
setCurrentStep(2); // Move to processing step immediately
|
||||
|
||||
// Simulating a 3-second delay to mimic API call
|
||||
setTimeout(() => {
|
||||
setCurrentStep(3);
|
||||
}, 3000);
|
||||
} else if (currentStep < steps.length - 1) {
|
||||
setCurrentStep(currentStep + 1);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Container type="panel">
|
||||
<PageHeader
|
||||
title="Create New Voice"
|
||||
titleIcon={faWaveform}
|
||||
subText="Add voice details and upload audio samples to clone your voice!"
|
||||
/>
|
||||
|
||||
<Panel>
|
||||
{/* Stepper */}
|
||||
<div className="p-3 px-lg-4 bg-stepper">
|
||||
<Stepper steps={steps} currentStep={currentStep} />
|
||||
</div>
|
||||
|
||||
<div className="p-3 py-4 p-md-4">{displayStep(currentStep)}</div>
|
||||
|
||||
{/* Navigation Controls */}
|
||||
|
||||
<StepperControls
|
||||
steps={steps}
|
||||
currentStep={currentStep}
|
||||
onBack={handleBack}
|
||||
onNext={handleNext}
|
||||
/>
|
||||
</Panel>
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
export { VoiceDesignerCreatePage };
|
||||
@@ -0,0 +1,105 @@
|
||||
import React, { useState } from "react";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { faPencil, faWaveform } from "@fortawesome/pro-solid-svg-icons";
|
||||
import { usePrefixedDocumentTitle } from "common/UsePrefixedDocumentTitle";
|
||||
import Panel from "components/common/Panel";
|
||||
import { Stepper } from "./components/Stepper";
|
||||
import { StepperControls } from "./components/StepperControls";
|
||||
import { UploadSamples } from "./components/steps/UploadSamples";
|
||||
import { VoiceDetails } from "./components/steps/VoiceDetails";
|
||||
import PageHeader from "components/layout/PageHeader";
|
||||
import Container from "components/common/Container";
|
||||
import { useHistory } from "react-router-dom";
|
||||
|
||||
interface RouteParams {
|
||||
dataset_token?: string;
|
||||
}
|
||||
|
||||
function VoiceDesignerFormPage() {
|
||||
const history = useHistory();
|
||||
const { dataset_token } = useParams<RouteParams>();
|
||||
const [isNewCreation] = useState(!dataset_token);
|
||||
const isEditMode = Boolean(dataset_token) && !isNewCreation;
|
||||
|
||||
usePrefixedDocumentTitle(isEditMode ? "Edit Dataset" : "Create New Voice");
|
||||
|
||||
const initialStep = history.location.pathname.includes("/upload") ? 1 : 0;
|
||||
const [currentStep, setCurrentStep] = useState(initialStep);
|
||||
|
||||
const steps = isEditMode
|
||||
? ["Edit Details", "Edit Samples"]
|
||||
: ["Voice Details", "Upload Samples"];
|
||||
|
||||
const displayStep = (step: any) => {
|
||||
switch (step) {
|
||||
case 0:
|
||||
return <VoiceDetails />;
|
||||
case 1:
|
||||
return <UploadSamples />;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
const handleBack = () => {
|
||||
if (currentStep === 1 && dataset_token) {
|
||||
// Set the route to /edit
|
||||
history.push(`/voice-designer/dataset/${dataset_token}/edit`);
|
||||
setCurrentStep(0);
|
||||
} else if (currentStep > 0) {
|
||||
setCurrentStep(currentStep - 1);
|
||||
}
|
||||
};
|
||||
|
||||
const handleNext = () => {
|
||||
if (currentStep === 0) {
|
||||
if (isNewCreation) {
|
||||
// It's a new creation and on the first step
|
||||
const dummyDatasetToken = "dummyToken123";
|
||||
history.push(`/voice-designer/dataset/${dummyDatasetToken}/upload`);
|
||||
} else if (dataset_token) {
|
||||
// It's edit mode and on the first step
|
||||
history.push(`/voice-designer/dataset/${dataset_token}/upload`);
|
||||
}
|
||||
setCurrentStep(currentStep + 1);
|
||||
} else if (currentStep < steps.length - 1) {
|
||||
setCurrentStep(currentStep + 1);
|
||||
}
|
||||
};
|
||||
|
||||
const handleCreateVoice = () => {
|
||||
history.push("/voice-designer");
|
||||
};
|
||||
|
||||
return (
|
||||
<Container type="panel">
|
||||
<PageHeader
|
||||
title={isEditMode ? "Edit Dataset" : "Create New Voice"}
|
||||
titleIcon={isEditMode ? faPencil : faWaveform}
|
||||
subText={
|
||||
isEditMode
|
||||
? "Edit your dataset by uploading more samples to create a new voice"
|
||||
: "Add voice details and upload audio samples to clone your voice!"
|
||||
}
|
||||
/>
|
||||
|
||||
<Panel>
|
||||
<div className="p-3 px-lg-4 bg-stepper">
|
||||
<Stepper steps={steps} currentStep={currentStep} />
|
||||
</div>
|
||||
|
||||
<div className="p-3 py-4 p-md-4">{displayStep(currentStep)}</div>
|
||||
|
||||
<StepperControls
|
||||
steps={steps}
|
||||
currentStep={currentStep}
|
||||
onBack={handleBack}
|
||||
onNext={handleNext}
|
||||
onCreate={handleCreateVoice}
|
||||
/>
|
||||
</Panel>
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
export { VoiceDesignerFormPage };
|
||||
@@ -21,7 +21,10 @@ function VoiceDesignerMainPage() {
|
||||
},
|
||||
];
|
||||
const datasetList = [
|
||||
{ name: "Donald Trump (45th US President)", edit: "/", delete: "/" },
|
||||
{
|
||||
name: "Donald Trump (45th US President)",
|
||||
modelToken: "dummyToken",
|
||||
},
|
||||
];
|
||||
const emptyList = [] as any[];
|
||||
|
||||
@@ -44,6 +47,8 @@ function VoiceDesignerMainPage() {
|
||||
buttonVariant="primary"
|
||||
buttonIcon={faPlus}
|
||||
buttonTo="/voice-designer/create"
|
||||
withImage={true}
|
||||
imageUrl="https://app.kits.ai/_next/static/media/vocals-gated-graphic.eb866911.svg"
|
||||
/>
|
||||
|
||||
<Panel>
|
||||
|
||||
+6
-13
@@ -28,7 +28,9 @@ export default function ListItems({ data, type }: ListItemsProps) {
|
||||
)}
|
||||
{type === "datasets" && (
|
||||
<>
|
||||
<h5 className="fw-semibold mb-3">No existing datasets yet.</h5>
|
||||
<h5 className="fw-semibold mb-3">
|
||||
Datasets will appear after creating voices.
|
||||
</h5>
|
||||
<Button
|
||||
icon={faPlus}
|
||||
label="Create New Voice"
|
||||
@@ -43,15 +45,6 @@ export default function ListItems({ data, type }: ListItemsProps) {
|
||||
|
||||
return (
|
||||
<div className="d-flex flex-column gap-3">
|
||||
<div className="d-flex flex-column flex-lg-row py-2 d-md-none">
|
||||
<div>
|
||||
<Button
|
||||
icon={faPlus}
|
||||
label="Create New Voice"
|
||||
to="/voice-designer/create"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{data.map((item) => {
|
||||
return (
|
||||
<div className="d-flex flex-column flex-lg-row gap-3 list-items p-3 align-items-lg-center">
|
||||
@@ -76,19 +69,19 @@ export default function ListItems({ data, type }: ListItemsProps) {
|
||||
label="Edit"
|
||||
small={true}
|
||||
variant="secondary"
|
||||
to={`/tts/${item.modelToken}/edit`}
|
||||
to={`/voice-designer/dataset/${item.modelToken}/edit`}
|
||||
/>
|
||||
<Button
|
||||
label="Delete"
|
||||
small={true}
|
||||
variant="danger"
|
||||
to={`/tts/${item.modelToken}/delete`}
|
||||
to={`/voice-designer/dataset/${item.modelToken}/delete`}
|
||||
/>
|
||||
{type === "voices" && (
|
||||
<Button
|
||||
label="Use Voice"
|
||||
small={true}
|
||||
to={`/tts/${item.modelToken}`}
|
||||
to={`/voice-designer/dataset/${item.modelToken}`}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
+20
-16
@@ -3,6 +3,7 @@ import React from "react";
|
||||
interface StepperControlsProps {
|
||||
onBack: () => void;
|
||||
onNext: () => void;
|
||||
onCreate: () => void;
|
||||
steps: string[];
|
||||
currentStep: number;
|
||||
}
|
||||
@@ -12,25 +13,28 @@ const StepperControls: React.FC<StepperControlsProps> = ({
|
||||
onNext,
|
||||
steps,
|
||||
currentStep,
|
||||
onCreate,
|
||||
}) => {
|
||||
return (
|
||||
<>
|
||||
{currentStep !== 3 && (
|
||||
<div className="p-3 pb-4 px-lg-4 pt-0 d-flex gap-3">
|
||||
{currentStep !== 0 && currentStep !== 2 && (
|
||||
<button className="btn btn-secondary w-100" onClick={onBack}>
|
||||
Back
|
||||
</button>
|
||||
)}
|
||||
|
||||
{currentStep < steps.length - 2 && (
|
||||
<button className="btn btn-primary w-100" onClick={onNext}>
|
||||
{currentStep !== steps.length - 3 ? "Continue" : "Create Voice"}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
<div className="p-3 pb-4 px-lg-4 pt-0 d-flex gap-3">
|
||||
{currentStep === 1 && (
|
||||
<button className="btn btn-secondary w-100" onClick={onBack}>
|
||||
Back
|
||||
</button>
|
||||
)}
|
||||
</>
|
||||
|
||||
{currentStep === 0 && (
|
||||
<button className="btn btn-primary w-100" onClick={onNext}>
|
||||
Continue
|
||||
</button>
|
||||
)}
|
||||
|
||||
{currentStep === 1 && (
|
||||
<button className="btn btn-primary w-100" onClick={onCreate}>
|
||||
Create Voice
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
+1
-1
@@ -147,7 +147,7 @@ function VoiceDesignerUploadComponent(props: Props) {
|
||||
<div className="d-flex flex-column opacity-75 h-100 justify-content-center">
|
||||
<FontAwesomeIcon icon={faWaveform} className="fs-3 mb-3" />
|
||||
<h5>No voice samples yet</h5>
|
||||
<p>Selected samples will appear here.</p>
|
||||
<p>Uploaded samples will appear here.</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
Reference in new issue
Block a user