File size: 2,176 Bytes
8a656d1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# /Users/amogh/Documents/amogh/projects/crew-ai/script_gen/src/script_gen/tools/video_tool.py
from crewai.tools import BaseTool
from typing import Dict, Any
import logging

# Import the video generator
from script_gen.video_gen_new import SizzleReelVideoGenerator

class VideoGenerationTool(BaseTool):
    """
    Custom tool for generating sizzle reel videos
    """
    name: str = "Video Generation Tool"
    description: str = (
        "Generates a sizzle reel video from a prepared script. "
        "Takes a JSON script and an app name, and produces a video path."
    )

    def __init__(self):
        super().__init__()


    def _run(
        self, 
        script_json: Dict[str, Any], 
        app_name: str = "CleverApp"
    ) -> str:
        """
        Generate a sizzle reel video from the provided script
        
        Args:
            script_json (Dict): The script for the sizzle reel
            app_name (str, optional): Name of the app. Defaults to "CleverApp".
        
        Returns:
            str: Path to the generated video
        
        Raises:
            ValueError: If video generation fails
        """
        try:
            # Log the start of video generation
            logging.info(f"Starting video generation for {app_name}")

            self.video_generator = SizzleReelVideoGenerator()
            
            # Generate the video
            video_path = self.video_generator.generate_sizzle_reel(
                script_json=script_json, 
                app_name=app_name
            )
            
            # Validate video generation
            if not video_path:
                raise ValueError("Video generation failed: No video path returned")
            
            # Log successful generation
            logging.info(f"Video generated successfully: {video_path}")
            
            return video_path
        
        except Exception as e:
            # Log any errors during video generation
            logging.error(f"Error in video generation: {e}")
            raise ValueError(f"Video generation failed: {str(e)}")

# Create a single instance of the tool
video_tool = VideoGenerationTool()