Spaces:
Running
Running
Upload 37 files
Browse files
src/components/MultiSourceCaptioningView.tsx
CHANGED
@@ -112,67 +112,52 @@ export default function MultiSourceCaptioningView() {
|
|
112 |
};
|
113 |
}, [mode]);
|
114 |
|
115 |
-
//
|
116 |
-
// Example for webcam mode:
|
117 |
useEffect(() => {
|
118 |
if (mode !== "Webcam" || !isLoaded || !webcamActive) return;
|
119 |
-
let
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
}
|
127 |
-
}
|
128 |
-
processLoop();
|
129 |
-
return () => { running = false; };
|
130 |
}, [mode, isLoaded, prompt, runInference, webcamActive]);
|
131 |
|
132 |
-
//
|
133 |
useEffect(() => {
|
134 |
if (mode !== "URL" || !isLoaded || !urlProcessing) return;
|
135 |
-
let
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
}
|
143 |
-
}
|
144 |
-
processLoop();
|
145 |
-
return () => { running = false; };
|
146 |
}, [mode, isLoaded, prompt, runInference, urlProcessing]);
|
147 |
|
|
|
148 |
useEffect(() => {
|
149 |
if (mode !== "File" || !isLoaded || !uploadedFile || !isVideoFile(uploadedFile) || !videoProcessing) return;
|
150 |
-
let
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
}
|
158 |
-
}
|
159 |
-
processLoop();
|
160 |
-
return () => { running = false; };
|
161 |
}, [mode, isLoaded, prompt, runInference, uploadedFile, videoProcessing]);
|
162 |
|
|
|
163 |
useEffect(() => {
|
164 |
if (mode !== "File" || uploadedFile || !isLoaded || !exampleProcessing) return;
|
165 |
-
let
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
}
|
173 |
-
}
|
174 |
-
processLoop();
|
175 |
-
return () => { running = false; };
|
176 |
}, [mode, isLoaded, prompt, runInference, uploadedFile, exampleProcessing]);
|
177 |
|
178 |
// File mode: process uploaded image (only on button click)
|
|
|
112 |
};
|
113 |
}, [mode]);
|
114 |
|
115 |
+
// Webcam mode: process frames with setInterval
|
|
|
116 |
useEffect(() => {
|
117 |
if (mode !== "Webcam" || !isLoaded || !webcamActive) return;
|
118 |
+
let interval: ReturnType<typeof setInterval> | null = null;
|
119 |
+
interval = setInterval(() => {
|
120 |
+
processVideoFrame();
|
121 |
+
}, 1000);
|
122 |
+
return () => {
|
123 |
+
if (interval) clearInterval(interval);
|
124 |
+
};
|
|
|
|
|
|
|
|
|
125 |
}, [mode, isLoaded, prompt, runInference, webcamActive]);
|
126 |
|
127 |
+
// URL mode: process frames with setInterval
|
128 |
useEffect(() => {
|
129 |
if (mode !== "URL" || !isLoaded || !urlProcessing) return;
|
130 |
+
let interval: ReturnType<typeof setInterval> | null = null;
|
131 |
+
interval = setInterval(() => {
|
132 |
+
processVideoFrame();
|
133 |
+
}, 1000);
|
134 |
+
return () => {
|
135 |
+
if (interval) clearInterval(interval);
|
136 |
+
};
|
|
|
|
|
|
|
|
|
137 |
}, [mode, isLoaded, prompt, runInference, urlProcessing]);
|
138 |
|
139 |
+
// File video mode: process frames with setInterval
|
140 |
useEffect(() => {
|
141 |
if (mode !== "File" || !isLoaded || !uploadedFile || !isVideoFile(uploadedFile) || !videoProcessing) return;
|
142 |
+
let interval: ReturnType<typeof setInterval> | null = null;
|
143 |
+
interval = setInterval(() => {
|
144 |
+
processVideoFrame();
|
145 |
+
}, 1000);
|
146 |
+
return () => {
|
147 |
+
if (interval) clearInterval(interval);
|
148 |
+
};
|
|
|
|
|
|
|
|
|
149 |
}, [mode, isLoaded, prompt, runInference, uploadedFile, videoProcessing]);
|
150 |
|
151 |
+
// Example video mode: process frames with setInterval
|
152 |
useEffect(() => {
|
153 |
if (mode !== "File" || uploadedFile || !isLoaded || !exampleProcessing) return;
|
154 |
+
let interval: ReturnType<typeof setInterval> | null = null;
|
155 |
+
interval = setInterval(() => {
|
156 |
+
processVideoFrame();
|
157 |
+
}, 1000);
|
158 |
+
return () => {
|
159 |
+
if (interval) clearInterval(interval);
|
160 |
+
};
|
|
|
|
|
|
|
|
|
161 |
}, [mode, isLoaded, prompt, runInference, uploadedFile, exampleProcessing]);
|
162 |
|
163 |
// File mode: process uploaded image (only on button click)
|