| | import json |
| | import os |
| | from glob import glob |
| |
|
| | import numpy as np |
| |
|
| | |
| | |
| |
|
| | transcript_path = '../../mmaction2/data/EasyComDataset_fix/Main/Speech_Transcriptions/' |
| | unified_transcript_path = 'unified_transcripts' |
| | metadata_path = '../../notebooks/results/easycom_metadata.json' |
| |
|
| | annotation_path = '/home/junhyeok/projects/turn-taking/datasets/EasyCom/target_perframe/case1' |
| | |
| | |
| | |
| | |
| |
|
| | with open(metadata_path, 'r') as f: |
| | metadata = json.load(f) |
| |
|
| | print(metadata) |
| | print(metadata.keys()) |
| |
|
| | video_fps = 20 |
| | anno_fps = 5 |
| | chunk_size = video_fps / anno_fps |
| |
|
| | if chunk_size != int(chunk_size): |
| | print("Chunk size is not an integer") |
| | exit() |
| |
|
| | chunk_size = int(chunk_size) |
| |
|
| | unified_transcripts = {} |
| |
|
| | annotation = {} |
| | for session in metadata.keys(): |
| | session_metadata = metadata[session] |
| | print(session) |
| | session_total_frames = int(session_metadata['total_frames']) // chunk_size |
| | anno = np.zeros((session_total_frames, 3)) |
| | annotation[session] = {} |
| | |
| | |
| | session_transcripts = [] |
| | |
| | frame_idx = 0 |
| | for seg in session_metadata['segments']: |
| | video_name = seg['video_name'] |
| | print(seg['video_name']) |
| | transcript_pattern = os.path.join(transcript_path, '*', session, f"{video_name}.json") |
| | transcript_file = glob(transcript_pattern) |
| | |
| | if len(transcript_file) > 1: |
| | print("something is wrong") |
| | exit() |
| | |
| | transcript_file = transcript_file[0] |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | with open(transcript_file, 'r') as tf: |
| | transcript_data = json.load(tf) |
| | for utt in transcript_data: |
| | utt['Start_Frame'] += frame_idx |
| | utt['End_Frame'] += frame_idx |
| | session_transcripts.extend(transcript_data) |
| | |
| | print(transcript_data[0]) |
| | |
| | frame_idx += seg['num_frames'] |
| | |
| | |
| | with open(os.path.join(unified_transcript_path, f"{session}.json"), 'w') as json_file: |
| | json.dump(session_transcripts, json_file, indent=4) |