code refactor
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { useState, useEffect } from "react";
|
||||
import { useNavigate,useLocation } from "react-router-dom";
|
||||
import { useNavigate} from "react-router-dom";
|
||||
import { Typography, Container, Paper, Box, LinearProgress } from "@mui/material";
|
||||
import StepperComponent from "../components/StepperComponent";
|
||||
import { useMediaContext } from "../contexts/MediaContext";
|
||||
@@ -17,7 +17,10 @@ function ProcessingPage() {
|
||||
try {
|
||||
const formData = new FormData();
|
||||
formData.append("file_uuid", response.file_uuid);
|
||||
Object.entries(extraData).forEach(([key, value]) => formData.append(key, value));
|
||||
Object.entries(extraData).forEach(([key, value]) =>
|
||||
formData.append(key, String(value))
|
||||
);
|
||||
|
||||
|
||||
setStatusText(status);
|
||||
const startTime = Date.now();
|
||||
@@ -35,8 +38,6 @@ function ProcessingPage() {
|
||||
console.error(`Error in step: ${url}`, error);
|
||||
}
|
||||
};
|
||||
const location = useLocation();
|
||||
const { audioClass } = location.state || {};
|
||||
|
||||
useEffect(() => {
|
||||
if (!mediaFile) {
|
||||
@@ -51,7 +52,7 @@ function ProcessingPage() {
|
||||
if (response.audio_class === "Music") {
|
||||
processStep("http://127.0.0.1:8000/api/resample", () => {
|
||||
processStep("http://127.0.0.1:8000/api/separate", () => setProgress(100), 100, "Separating sources into vocals, bass, drums and other...");
|
||||
}, 75, "Resampling audio to 44100Hz...", { sr: response.sr?.toString() || "44100" });
|
||||
}, 75, "Resampling audio to 44100Hz...", { sr: "44100" });
|
||||
} else {
|
||||
processStep("http://127.0.0.1:8000/api/noisereduce", () => setProgress(100), 100, "Reducing background noise from the audio...");
|
||||
}
|
||||
@@ -62,7 +63,7 @@ function ProcessingPage() {
|
||||
useEffect(() => {
|
||||
if (progress === 100) {
|
||||
|
||||
navigate('/results', { state: { audioClass}})
|
||||
navigate('/results')
|
||||
|
||||
}
|
||||
}, [progress]);
|
||||
|
||||
Reference in New Issue
Block a user