diff --git a/client/index.html b/client/index.html index e4b78ea..cccac0e 100644 --- a/client/index.html +++ b/client/index.html @@ -2,9 +2,8 @@ - - Vite + React + TS + FreqSplit
diff --git a/client/src/App.tsx b/client/src/App.tsx index 3bd3413..49f1eb3 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -28,7 +28,7 @@ const App: React.FC = () => { - Freq Split + FreqSplit @@ -40,7 +40,7 @@ const App: React.FC = () => { } /> } /> } /> - }/> + }/> diff --git a/client/src/Pages/LandingPage.tsx b/client/src/Pages/LandingPage.tsx index c932c5f..fdfbb2a 100644 --- a/client/src/Pages/LandingPage.tsx +++ b/client/src/Pages/LandingPage.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import { useNavigate } from 'react-router-dom'; import { Typography, @@ -43,7 +42,7 @@ function LandingPage() { }} > - Welcome to Freq Split + Welcome to FreqSplit Upload, preview, and process your audio and video files with ease diff --git a/client/src/Pages/PreviewPage.tsx b/client/src/Pages/PreviewPage.tsx index 545c0b7..b8d976b 100644 --- a/client/src/Pages/PreviewPage.tsx +++ b/client/src/Pages/PreviewPage.tsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect, useRef } from 'react'; +import { useState, useEffect, useRef } from 'react'; import { useNavigate } from 'react-router-dom'; import { Typography, @@ -7,7 +7,6 @@ import { Paper, Box, LinearProgress, - useTheme } from '@mui/material'; import { VolumeUp as VolumeUpIcon, ErrorOutline as ErrorIcon } from '@mui/icons-material'; import StepperComponent from '../components/StepperComponent'; @@ -15,12 +14,10 @@ import { useMediaContext } from '../contexts/MediaContext'; function PreviewPage() { const navigate = useNavigate(); - const theme = useTheme(); - const { mediaFile } = useMediaContext(); - const [isPlaying, setIsPlaying] = useState(false); + const { mediaFile, response } = useMediaContext(); const [error, setError] = useState(false); const videoRef = useRef(null); - + const audioClass = response.audio_class // Supported video formats const supportedFormats = ['video/mp4', 'video/webm', 'video/ogg']; const isVideo = mediaFile && supportedFormats.includes(mediaFile.type); @@ -31,17 +28,6 @@ function PreviewPage() { } }, [mediaFile, navigate]); - const togglePlay = () => { - if (videoRef.current) { - if (isPlaying) { - videoRef.current.pause(); - } else { - videoRef.current.play(); - } - setIsPlaying(!isPlaying); - } - }; - if (!mediaFile) return ; return ( @@ -74,8 +60,6 @@ function PreviewPage() { style={{ width: '100%', borderRadius: 8 }} controls onError={() => setError(true)} - onPlay={() => setIsPlaying(true)} - onPause={() => setIsPlaying(false)} /> {error && ( @@ -105,10 +89,9 @@ function PreviewPage() { src={mediaFile.url} style={{ width: '100%' }} controls - onPlay={() => setIsPlaying(true)} - onPause={() => setIsPlaying(false)} /> +

Audio Classification: {audioClass || "No data received"}

) : ( @@ -129,12 +112,18 @@ function PreviewPage() { + ); } diff --git a/client/src/Pages/ProcessingPage.tsx b/client/src/Pages/ProcessingPage.tsx index 0e9392b..5ee8734 100644 --- a/client/src/Pages/ProcessingPage.tsx +++ b/client/src/Pages/ProcessingPage.tsx @@ -1,5 +1,5 @@ import { useState, useEffect } from "react"; -import { useNavigate } 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(); @@ -44,14 +47,14 @@ function ProcessingPage() { console.log("Starting processing..."); - processStep("http://127.0.0.1:8000/api/normalize", () => { - processStep("http://127.0.0.1:8000/api/trim", () => { + processStep("/api/normalize", () => { + processStep("/api/trim", () => { 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" }); + processStep("/api/resample", () => { + processStep("/api/separate", () => setProgress(100), 100, "Separating music into vocals, bass, drums and other..."); + }, 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..."); + processStep("/api/noisereduce", () => setProgress(100), 100, "Reducing background noise from the audio..."); } }, 50, "Trimming silent parts from the audio..."); }, 25, "Normalizing audio frequency..."); @@ -59,7 +62,9 @@ function ProcessingPage() { useEffect(() => { if (progress === 100) { - navigate("/results"); + + navigate('/results') + } }, [progress]); @@ -92,6 +97,12 @@ function ProcessingPage() { + ); } diff --git a/client/src/Pages/ResultsPage.tsx b/client/src/Pages/ResultsPage.tsx index 46b4fb1..031328f 100644 --- a/client/src/Pages/ResultsPage.tsx +++ b/client/src/Pages/ResultsPage.tsx @@ -1,6 +1,6 @@ -import React, { useState, useEffect, useRef } from 'react'; +import { useEffect, useRef } from 'react'; import { useNavigate } from 'react-router-dom'; -import axios from 'axios'; +//import axios from 'axios'; import { Typography, Container, @@ -11,7 +11,6 @@ import { CardContent, Grid, LinearProgress, - useTheme } from '@mui/material'; import { Check as CheckIcon, @@ -22,46 +21,11 @@ import { useMediaContext } from '../contexts/MediaContext'; function ResultsPage() { const navigate = useNavigate(); - const theme = useTheme(); - const { mediaFile, clearMedia,response } = useMediaContext(); - const [isPlaying, setIsPlaying] = useState(false); - const videoRef = useRef(null); - - const processDownload = async() => { - try { - console.log('download started..') - const res = await axios.get("http://127.0.0.1:8000/api/download", { - params: { file_uuid: response.file_uuid }, // Attach file_uuid as a query param - responseType: "blob", // Treat response as a file - }); - - if (res.status === 200) { - const blob = new Blob([res.data]); - const url = window.URL.createObjectURL(blob); - - // Extract filename from headers or use default - const contentDisposition = res.headers["content-disposition"]; - const filename = contentDisposition - ? contentDisposition.split("filename=")[1] - : "downloaded_file"; - - // Auto-download the file (no user interaction needed) - const link = document.createElement("a"); - link.href = url; - link.setAttribute("download", filename); - document.body.appendChild(link); - link.click(); - - // Cleanup - document.body.removeChild(link); - window.URL.revokeObjectURL(url); - } else { - console.error("Download failed, server responded with:", res); - } - } catch (error) { - console.error("Download error:", error); - } - }; + const { mediaFile, response } = useMediaContext(); +// const [isPlaying, setIsPlaying] = useState(false); + const audioRefs = [useRef(null), useRef(null), useRef(null),useRef(null)]; + const audioClass = response.audio_class + const isVideo = mediaFile?.type.includes('video'); useEffect(() => { if (!mediaFile) { @@ -69,26 +33,19 @@ function ResultsPage() { } }, [mediaFile, navigate]); - const togglePlay = () => { - if (videoRef.current) { - if (isPlaying) { - videoRef.current.pause(); - } else { - videoRef.current.play(); - } - setIsPlaying(!isPlaying); - } - }; +// const togglePlay = (index) => { +// if (audioRefs[index].current) { +// if (isPlaying) { +// audioRefs[index].current.pause(); +// } else { +// audioRefs[index].current.play(); +// } +// setIsPlaying(!isPlaying); +// } +// }; - const handleProcessAnother = () => { - clearMedia(); - navigate('/upload'); - }; - if (!mediaFile) return ; - const isVideo = mediaFile.type.includes('video'); - return ( @@ -107,50 +64,38 @@ function ResultsPage() { {isVideo ? ( - - +