Spaces:
Runtime error
Runtime error
| print("=" * 60) | |
| print("HinglishCaps - Clean Version") | |
| print("=" * 60) | |
| import gradio as gr | |
| print("Gradio imported successfully") | |
| with gr.Blocks(title="HinglishCaps - Auto Captions", css=""" | |
| .gradio-container { max-width: 900px !important; margin: auto; } | |
| .tab-nav { background: #f5f5f5; border-radius: 8px; padding: 10px; } | |
| """) as app: | |
| gr.Markdown(""" | |
| # 🎬 HinglishCaps - Auto Captions for Hindi/English Videos | |
| This is a demo interface for the HinglishCaps captioning tool. | |
| **Full AI transcription requires running the app locally** due to memory | |
| constraints on Hugging Face Spaces free tier. | |
| """) | |
| with gr.Tabs(): | |
| with gr.TabItem("Single Video"): | |
| gr.Markdown("### Process a single video") | |
| video = gr.Video(label="Upload Video") | |
| btn = gr.Button("Generate Demo Captions", variant="primary") | |
| output = gr.File(label="Download Demo File") | |
| def create_demo(video_path): | |
| # Create a simple demo file | |
| import tempfile | |
| import os | |
| content = """1 | |
| 00:00:00,000 --> 00:00:05,000 | |
| Demo caption file for HinglishCaps. | |
| 2 | |
| 00:00:05,000 --> 00:00:10,000 | |
| To use the full AI transcription feature: | |
| 3 | |
| 00:00:10,000 --> 00:00:15,000 | |
| Run the app locally on your machine.""" | |
| temp_dir = tempfile.gettempdir() | |
| filepath = os.path.join(temp_dir, "demo_captions.srt") | |
| with open(filepath, "w", encoding="utf-8") as f: | |
| f.write(content) | |
| return filepath | |
| btn.click(create_demo, inputs=[video], outputs=[output]) | |
| with gr.TabItem("Batch Processing"): | |
| gr.Markdown("### Process multiple videos") | |
| videos = gr.File(label="Upload Videos", file_count="multiple") | |
| batch_btn = gr.Button("Generate Demo Batch", variant="primary") | |
| zip_output = gr.File(label="Download Demo ZIP") | |
| def create_batch(files): | |
| import tempfile | |
| import os | |
| import zipfile | |
| temp_dir = tempfile.gettempdir() | |
| zip_path = os.path.join(temp_dir, "demo_batch.zip") | |
| with zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED) as zipf: | |
| for i in range(min(3, len(files) if files else 0)): | |
| filename = f"video_{i+1}_captions.srt" | |
| content = f"""1 | |
| 00:00:00,000 --> 00:00:05,000 | |
| Demo captions for video {i+1} | |
| 2 | |
| 00:00:05,000 --> 00:00:10,000 | |
| Batch processing demo | |
| 3 | |
| 00:00:10,000 --> 00:00:15,000 | |
| Run locally for AI transcription""" | |
| zipf.writestr(filename, content) | |
| return zip_path | |
| batch_btn.click(create_batch, inputs=[videos], outputs=[zip_output]) | |
| gr.Markdown("---") | |
| gr.Markdown(""" | |
| ### Getting the Full Version | |
| The full HinglishCaps app with AI transcription is available in the | |
| repository files. To use it: | |
| 1. **Clone the repository** to your local machine | |
| 2. **Install dependencies** from `requirements_full.txt` | |
| 3. **Run `python app_full.py`** | |
| The full app uses the Oriserve/Whisper-Hindi2Hinglish-Apex model for | |
| accurate Hindi-English transcription. | |
| """) | |
| print("Launching app...") | |
| app.launch(share=True, server_name="0.0.0.0") |