import json from file_name import * import os def load_groups_json(): sample_groups_list = [] speaker_groups_dict = [] if os.path.exists(sample_groups_json): with open(sample_groups_json, "r", encoding="utf-8") as json_file_sample: sample_groups_list: list = json.load(json_file_sample) if os.path.exists(speaker_groups_json): with open(speaker_groups_json, "r", encoding="utf-8") as json_file_speaker: speaker_groups_dict: dict = json.load(json_file_speaker) return sample_groups_list, speaker_groups_dict def write_transcribe_subtitle_file(transcribe_txt_list: list, subtitle_txt_list: list, adjustment: bool): transcribe = get_transcribe_file() subtitle = get_subtitle_file() if adjustment: transcribe = get_transcribe_adjusted_file() subtitle = get_subtitle_adjusted_file() with open(transcribe, "w", encoding="utf-8") as file: file.writelines(transcribe_txt_list) with open(subtitle, "w", encoding="utf-8") as file: file.writelines(subtitle_txt_list) def read_transcribe_subtitle_file(adjustment: bool): transcribe = get_transcribe_file() subtitle = get_subtitle_file() if adjustment: transcribe = get_transcribe_adjusted_file() subtitle = get_subtitle_adjusted_file() transcribe_txt_list = [] subtitle_txt_list = [] if os.path.exists(transcribe): with open(transcribe, "r", encoding="utf-8") as file: transcribe_txt_list = file.readlines() if os.path.exists(subtitle): with open(subtitle, "r", encoding="utf-8") as file: subtitle_txt_list = file.readlines() return transcribe_txt_list, subtitle_txt_list