Video Caption
Generate captions from video content.
Please install dependencies using:.
1"""2Video Caption3=============================45Please install dependencies using:.6"""78from kern.agent import Agent9from kern.models.openai import OpenAIResponses10from kern.tools.moviepy_video import MoviePyVideoTools11from kern.tools.openai import OpenAITools1213video_tools = MoviePyVideoTools(14 process_video=True, generate_captions=True, embed_captions=True15)1617openai_tools = OpenAITools()1819# ---------------------------------------------------------------------------20# Create Agent21# ---------------------------------------------------------------------------22video_caption_agent = Agent(23 name="Video Caption Generator Agent",24 model=OpenAIResponses(25 id="gpt-4o",26 ),27 tools=[video_tools, openai_tools],28 description="You are an AI agent that can generate and embed captions for videos.",29 instructions=[30 "When a user provides a video, process it to generate captions.",31 "Use the video processing tools in this sequence:",32 "1. Extract audio from the video using extract_audio",33 "2. Transcribe the audio using transcribe_audio",34 "3. Generate SRT captions using create_srt",35 "4. Embed captions into the video using embed_captions",36 ],37 markdown=True,38)3940# ---------------------------------------------------------------------------41# Run Agent42# ---------------------------------------------------------------------------43if __name__ == "__main__":44 video_caption_agent.print_response(45 "Generate captions for {video with location} and embed them in the video"46 )Run the Example
1# Clone and setup repo2git clone https://github.com/kern-ai/kern.git3cd kern/cookbook/02_agents/12_multimodal45# Create and activate virtual environment6./scripts/demo_setup.sh7source .venvs/demo/bin/activate89python video_caption.py