Bagda commited on
Commit
ee9377a
·
verified ·
1 Parent(s): 8dda41d

Upload 2 files

Browse files
Files changed (2) hide show
  1. App.tsx +347 -0
  2. environment.js +0 -0
App.tsx ADDED
@@ -0,0 +1,347 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { useState } from 'react';
2
+ import { Youtube, Download, Play, Pause, Volume2, FileAudio, FileVideo, Loader2, CheckCircle, AlertCircle, Globe, Mic, Languages, Speaker } from 'lucide-react';
3
+
4
+ interface ProcessingStep {
5
+ id: string;
6
+ title: string;
7
+ description: string;
8
+ status: 'pending' | 'processing' | 'completed' | 'error';
9
+ icon: React.ReactNode;
10
+ }
11
+
12
+ function App() {
13
+ const [youtubeUrl, setYoutubeUrl] = useState('');
14
+ const [isProcessing, setIsProcessing] = useState(false);
15
+ const [currentStep, setCurrentStep] = useState(0);
16
+ const [isPlaying, setIsPlaying] = useState(false);
17
+ const [showResults, setShowResults] = useState(false);
18
+
19
+ const processingSteps: ProcessingStep[] = [
20
+ {
21
+ id: 'extract',
22
+ title: 'Extract Audio',
23
+ description: 'Downloading video and extracting high-quality audio',
24
+ status: 'pending',
25
+ icon: <FileAudio className="w-5 h-5" />
26
+ },
27
+ {
28
+ id: 'transcribe',
29
+ title: 'Transcribe Speech',
30
+ description: 'Converting English audio to accurate text',
31
+ status: 'pending',
32
+ icon: <Mic className="w-5 h-5" />
33
+ },
34
+ {
35
+ id: 'translate',
36
+ title: 'Translate Content',
37
+ description: 'Translating English text to natural Hindi',
38
+ status: 'pending',
39
+ icon: <Languages className="w-5 h-5" />
40
+ },
41
+ {
42
+ id: 'synthesize',
43
+ title: 'Generate Audio',
44
+ description: 'Creating Hindi speech with natural voice',
45
+ status: 'pending',
46
+ icon: <Speaker className="w-5 h-5" />
47
+ },
48
+ {
49
+ id: 'sync',
50
+ title: 'Synchronize Video',
51
+ description: 'Matching audio timing with original video',
52
+ status: 'pending',
53
+ icon: <FileVideo className="w-5 h-5" />
54
+ }
55
+ ];
56
+
57
+ const [steps, setSteps] = useState(processingSteps);
58
+
59
+ const isValidYouTubeUrl = (url: string) => {
60
+ const youtubeRegex = /^(https?:\/\/)?(www\.)?(youtube\.com|youtu\.be)\/.+/;
61
+ return youtubeRegex.test(url);
62
+ };
63
+
64
+ const handleSubmit = async (e: React.FormEvent) => {
65
+ e.preventDefault();
66
+ if (!isValidYouTubeUrl(youtubeUrl)) return;
67
+
68
+ setIsProcessing(true);
69
+ setCurrentStep(0);
70
+ setShowResults(false);
71
+
72
+ // Simulate processing steps
73
+ for (let i = 0; i < steps.length; i++) {
74
+ setCurrentStep(i);
75
+
76
+ // Update step to processing
77
+ setSteps(prev => prev.map((step, index) =>
78
+ index === i ? { ...step, status: 'processing' } : step
79
+ ));
80
+
81
+ // Simulate processing time
82
+ await new Promise(resolve => setTimeout(resolve, 2000 + Math.random() * 1000));
83
+
84
+ // Update step to completed
85
+ setSteps(prev => prev.map((step, index) =>
86
+ index === i ? { ...step, status: 'completed' } : step
87
+ ));
88
+ }
89
+
90
+ setIsProcessing(false);
91
+ setShowResults(true);
92
+ };
93
+
94
+ const getStepStatusIcon = (step: ProcessingStep, index: number) => {
95
+ if (step.status === 'completed') {
96
+ return <CheckCircle className="w-5 h-5 text-emerald-500" />;
97
+ } else if (step.status === 'processing') {
98
+ return <Loader2 className="w-5 h-5 text-indigo-500 animate-spin" />;
99
+ } else if (step.status === 'error') {
100
+ return <AlertCircle className="w-5 h-5 text-red-500" />;
101
+ } else {
102
+ return <div className="w-5 h-5 rounded-full border-2 border-gray-300 flex items-center justify-center">
103
+ <div className="w-2 h-2 rounded-full bg-gray-300"></div>
104
+ </div>;
105
+ }
106
+ };
107
+
108
+ return (
109
+ <div className="min-h-screen bg-gradient-to-br from-indigo-50 via-white to-purple-50">
110
+ {/* Header */}
111
+ <header className="bg-white/80 backdrop-blur-sm border-b border-gray-100 sticky top-0 z-50">
112
+ <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-4">
113
+ <div className="flex items-center space-x-3">
114
+ <div className="bg-gradient-to-r from-indigo-500 to-purple-600 p-2 rounded-xl">
115
+ <Globe className="w-6 h-6 text-white" />
116
+ </div>
117
+ <div>
118
+ <h1 className="text-xl font-bold text-gray-900">YouTube Translator</h1>
119
+ <p className="text-sm text-gray-600">English to Hindi Video Dubbing</p>
120
+ </div>
121
+ </div>
122
+ </div>
123
+ </header>
124
+
125
+ <div className="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
126
+ {/* Hero Section */}
127
+ <div className="text-center mb-12">
128
+ <div className="inline-flex items-center space-x-2 bg-indigo-100 text-indigo-700 px-4 py-2 rounded-full text-sm font-medium mb-6">
129
+ <Youtube className="w-4 h-4" />
130
+ <span>Powered by Advanced AI Translation</span>
131
+ </div>
132
+ <h2 className="text-4xl font-bold text-gray-900 mb-4">
133
+ Transform English Videos to
134
+ <span className="bg-gradient-to-r from-indigo-600 to-purple-600 bg-clip-text text-transparent"> Hindi</span>
135
+ </h2>
136
+ <p className="text-xl text-gray-600 max-w-2xl mx-auto">
137
+ Automatically extract, transcribe, translate, and dub YouTube videos with natural-sounding Hindi voiceovers
138
+ </p>
139
+ </div>
140
+
141
+ {/* Input Form */}
142
+ <div className="bg-white rounded-2xl shadow-xl border border-gray-100 p-8 mb-8">
143
+ <form onSubmit={handleSubmit} className="space-y-6">
144
+ <div>
145
+ <label htmlFor="youtube-url" className="block text-sm font-semibold text-gray-700 mb-3">
146
+ YouTube Video URL
147
+ </label>
148
+ <div className="relative">
149
+ <Youtube className="absolute left-4 top-1/2 transform -translate-y-1/2 text-gray-400 w-5 h-5" />
150
+ <input
151
+ type="url"
152
+ id="youtube-url"
153
+ value={youtubeUrl}
154
+ onChange={(e) => setYoutubeUrl(e.target.value)}
155
+ placeholder="https://www.youtube.com/watch?v=..."
156
+ className="w-full pl-12 pr-4 py-4 border border-gray-200 rounded-xl focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition-all duration-200 text-lg"
157
+ required
158
+ />
159
+ </div>
160
+ {youtubeUrl && !isValidYouTubeUrl(youtubeUrl) && (
161
+ <p className="mt-2 text-sm text-red-600 flex items-center space-x-1">
162
+ <AlertCircle className="w-4 h-4" />
163
+ <span>Please enter a valid YouTube URL</span>
164
+ </p>
165
+ )}
166
+ </div>
167
+
168
+ <button
169
+ type="submit"
170
+ disabled={!isValidYouTubeUrl(youtubeUrl) || isProcessing}
171
+ className="w-full bg-gradient-to-r from-indigo-500 to-purple-600 text-white py-4 px-6 rounded-xl font-semibold text-lg hover:from-indigo-600 hover:to-purple-700 disabled:opacity-50 disabled:cursor-not-allowed transition-all duration-200 flex items-center justify-center space-x-2"
172
+ >
173
+ {isProcessing ? (
174
+ <>
175
+ <Loader2 className="w-5 h-5 animate-spin" />
176
+ <span>Processing...</span>
177
+ </>
178
+ ) : (
179
+ <>
180
+ <Languages className="w-5 h-5" />
181
+ <span>Start Translation</span>
182
+ </>
183
+ )}
184
+ </button>
185
+ </form>
186
+ </div>
187
+
188
+ {/* Processing Steps */}
189
+ {(isProcessing || showResults) && (
190
+ <div className="bg-white rounded-2xl shadow-xl border border-gray-100 p-8 mb-8">
191
+ <h3 className="text-2xl font-bold text-gray-900 mb-6">Processing Pipeline</h3>
192
+ <div className="space-y-4">
193
+ {steps.map((step, index) => (
194
+ <div key={step.id} className="flex items-center space-x-4 p-4 rounded-xl bg-gray-50 hover:bg-gray-100 transition-colors duration-200">
195
+ <div className="flex-shrink-0">
196
+ {getStepStatusIcon(step, index)}
197
+ </div>
198
+ <div className="flex-1">
199
+ <div className="flex items-center space-x-2">
200
+ {step.icon}
201
+ <h4 className="font-semibold text-gray-900">{step.title}</h4>
202
+ </div>
203
+ <p className="text-gray-600 text-sm mt-1">{step.description}</p>
204
+ </div>
205
+ {step.status === 'processing' && (
206
+ <div className="flex-shrink-0">
207
+ <div className="w-32 bg-gray-200 rounded-full h-2">
208
+ <div className="bg-indigo-500 h-2 rounded-full animate-pulse" style={{ width: '60%' }}></div>
209
+ </div>
210
+ </div>
211
+ )}
212
+ </div>
213
+ ))}
214
+ </div>
215
+ </div>
216
+ )}
217
+
218
+ {/* Results Section */}
219
+ {showResults && (
220
+ <div className="bg-white rounded-2xl shadow-xl border border-gray-100 p-8">
221
+ <div className="flex items-center space-x-3 mb-6">
222
+ <CheckCircle className="w-8 h-8 text-emerald-500" />
223
+ <div>
224
+ <h3 className="text-2xl font-bold text-gray-900">Translation Complete!</h3>
225
+ <p className="text-gray-600">Your Hindi dubbed video is ready</p>
226
+ </div>
227
+ </div>
228
+
229
+ {/* Audio Player */}
230
+ <div className="bg-gradient-to-r from-gray-50 to-gray-100 rounded-xl p-6 mb-6">
231
+ <div className="flex items-center justify-between mb-4">
232
+ <h4 className="font-semibold text-gray-900">Hindi Audio Preview</h4>
233
+ <div className="flex items-center space-x-2 text-sm text-gray-600">
234
+ <Volume2 className="w-4 h-4" />
235
+ <span>2:34 duration</span>
236
+ </div>
237
+ </div>
238
+
239
+ {/* Waveform Visualization */}
240
+ <div className="bg-white rounded-lg p-4 mb-4">
241
+ <div className="flex items-center justify-center space-x-1 h-16">
242
+ {Array.from({ length: 50 }).map((_, i) => (
243
+ <div
244
+ key={i}
245
+ className="bg-indigo-400 rounded-full animate-pulse"
246
+ style={{
247
+ width: '3px',
248
+ height: `${Math.random() * 40 + 10}px`,
249
+ animationDelay: `${i * 0.1}s`
250
+ }}
251
+ ></div>
252
+ ))}
253
+ </div>
254
+ </div>
255
+
256
+ {/* Audio Controls */}
257
+ <div className="flex items-center justify-center space-x-4">
258
+ <button
259
+ onClick={() => setIsPlaying(!isPlaying)}
260
+ className="bg-indigo-500 hover:bg-indigo-600 text-white p-3 rounded-full transition-colors duration-200"
261
+ >
262
+ {isPlaying ? <Pause className="w-6 h-6" /> : <Play className="w-6 h-6" />}
263
+ </button>
264
+ <div className="flex-1 bg-gray-200 rounded-full h-2 max-w-md">
265
+ <div className="bg-indigo-500 h-2 rounded-full" style={{ width: '30%' }}></div>
266
+ </div>
267
+ <span className="text-sm text-gray-600">0:45 / 2:34</span>
268
+ </div>
269
+ </div>
270
+
271
+ {/* Download Options */}
272
+ <div className="grid md:grid-cols-2 gap-4">
273
+ <button className="flex items-center justify-center space-x-3 bg-emerald-50 hover:bg-emerald-100 text-emerald-700 border border-emerald-200 p-4 rounded-xl transition-colors duration-200">
274
+ <Download className="w-5 h-5" />
275
+ <div className="text-left">
276
+ <div className="font-semibold">Download Hindi Audio</div>
277
+ <div className="text-sm opacity-75">MP3 • 3.2 MB</div>
278
+ </div>
279
+ </button>
280
+ <button className="flex items-center justify-center space-x-3 bg-purple-50 hover:bg-purple-100 text-purple-700 border border-purple-200 p-4 rounded-xl transition-colors duration-200">
281
+ <Download className="w-5 h-5" />
282
+ <div className="text-left">
283
+ <div className="font-semibold">Download Dubbed Video</div>
284
+ <div className="text-sm opacity-75">MP4 • 15.7 MB</div>
285
+ </div>
286
+ </button>
287
+ </div>
288
+
289
+ {/* Quality Metrics */}
290
+ <div className="mt-6 p-4 bg-gray-50 rounded-xl">
291
+ <h5 className="font-semibold text-gray-900 mb-3">Translation Quality</h5>
292
+ <div className="grid grid-cols-2 md:grid-cols-4 gap-4">
293
+ <div className="text-center">
294
+ <div className="text-2xl font-bold text-emerald-600">98%</div>
295
+ <div className="text-sm text-gray-600">Accuracy</div>
296
+ </div>
297
+ <div className="text-center">
298
+ <div className="text-2xl font-bold text-indigo-600">Natural</div>
299
+ <div className="text-sm text-gray-600">Voice Quality</div>
300
+ </div>
301
+ <div className="text-center">
302
+ <div className="text-2xl font-bold text-purple-600">+99%</div>
303
+ <div className="text-sm text-gray-600">Sync Match</div>
304
+ </div>
305
+ <div className="text-center">
306
+ <div className="text-2xl font-bold text-orange-600">2:34</div>
307
+ <div className="text-sm text-gray-600">Duration</div>
308
+ </div>
309
+ </div>
310
+ </div>
311
+ </div>
312
+ )}
313
+
314
+ {/* Feature Highlights */}
315
+ {!isProcessing && !showResults && (
316
+ <div className="grid md:grid-cols-3 gap-6 mt-12">
317
+ <div className="bg-white rounded-xl p-6 shadow-lg border border-gray-100 hover:shadow-xl transition-shadow duration-200">
318
+ <div className="bg-indigo-100 w-12 h-12 rounded-lg flex items-center justify-center mb-4">
319
+ <Mic className="w-6 h-6 text-indigo-600" />
320
+ </div>
321
+ <h3 className="font-semibold text-gray-900 mb-2">High-Quality Transcription</h3>
322
+ <p className="text-gray-600 text-sm">Advanced AI accurately converts speech to text with 99%+ accuracy</p>
323
+ </div>
324
+
325
+ <div className="bg-white rounded-xl p-6 shadow-lg border border-gray-100 hover:shadow-xl transition-shadow duration-200">
326
+ <div className="bg-emerald-100 w-12 h-12 rounded-lg flex items-center justify-center mb-4">
327
+ <Languages className="w-6 h-6 text-emerald-600" />
328
+ </div>
329
+ <h3 className="font-semibold text-gray-900 mb-2">Natural Translation</h3>
330
+ <p className="text-gray-600 text-sm">Context-aware translation that preserves meaning and cultural nuances</p>
331
+ </div>
332
+
333
+ <div className="bg-white rounded-xl p-6 shadow-lg border border-gray-100 hover:shadow-xl transition-shadow duration-200">
334
+ <div className="bg-purple-100 w-12 h-12 rounded-lg flex items-center justify-center mb-4">
335
+ <Speaker className="w-6 h-6 text-purple-600" />
336
+ </div>
337
+ <h3 className="font-semibold text-gray-900 mb-2">Realistic Voice Synthesis</h3>
338
+ <p className="text-gray-600 text-sm">Natural-sounding Hindi voices with proper intonation and emotion</p>
339
+ </div>
340
+ </div>
341
+ )}
342
+ </div>
343
+ </div>
344
+ );
345
+ }
346
+
347
+ export default App;
environment.js ADDED
File without changes