from sentence_transformers import SentenceTransformer, util import json from datetime import datetime # Function to read and parse the JSON file def find_next_step(data, current_context): try: # Read the JSON file # with open(file_path, 'r') as file: # data = json.load(file) # Initialize counters total_videos = len(data) total_scenes = 0 max_score=0.0 step={ "path" :"", "start":"", "end": "", } # Iterate through each video entry print(f"Processing {total_videos} videos...\n") for index, video in enumerate(data, 1): video_type = video.get('type', 'Unknown') video_path = video.get('path', 'No path provided') scenes = video.get('scenes', []) scene_count = len(scenes) total_scenes += scene_count # Iterate through each scene in the video for scene_index, scene in enumerate(scenes, 1): timestamp = scene.get('timestamp', 'No timestamp') description = scene.get('description', 'No description') time_obj = datetime.strptime(timestamp, "%M:%S.%f") start = time_obj.minute * 60 + time_obj.second + time_obj.microsecond / 1_000_000 score=compare_phrases(description,current_context) if score > max_score: if scene_index+1