Spaces:
Sleeping
Sleeping
| from mcp.server.fastmcp import FastMCP | |
| from localizer_engine import process_video_sync | |
| import os | |
| # Initialize MCP Server | |
| mcp = FastMCP("Global Video Localizer") | |
| def localize_video_file( | |
| file_path: str, | |
| target_language: str = "es", | |
| elevenlabs_api_key: str | None = None, | |
| ) -> str: | |
| """ | |
| Localizes a video file into a target language. | |
| Args: | |
| file_path: Absolute path to the video file (.mp4) | |
| target_language: Language code (es, fr, de, it, ja, zh, hi, ar) | |
| elevenlabs_api_key: Optional API key for premium ElevenLabs voices (not persisted) | |
| Returns: | |
| Path to the localized video file and summary. | |
| """ | |
| if not os.path.exists(file_path): | |
| return f"Error: File not found at {file_path}" | |
| # Use safe synchronous wrapper | |
| try: | |
| output_path, orig, trans = process_video_sync( | |
| file_path, | |
| target_language, | |
| elevenlabs_api_key=elevenlabs_api_key, | |
| ) | |
| if output_path: | |
| return f"""β Video localization successful! | |
| Target Language: {target_language} | |
| Original Text: {orig[:100]}... | |
| Translated Text: {trans[:100]}... | |
| Output saved to: {output_path} | |
| """ | |
| else: | |
| return f"β Error processing video: {orig}" | |
| except Exception as e: | |
| return f"β Critical Error: {str(e)}" | |
| if __name__ == "__main__": | |
| print("Starting Global Video Localizer MCP Server...") | |
| print("β¨ Features: Whisper transcription + Qwen translation + Edge TTS + Audio time-stretching") | |
| mcp.run() | |