Video-localizer / server.py
sammoftah's picture
Deploy Global Video Localizer
1fe9360 verified
from mcp.server.fastmcp import FastMCP
from localizer_engine import process_video_sync
import os
# Initialize MCP Server
mcp = FastMCP("Global Video Localizer")
@mcp.tool()
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()