File size: 1,783 Bytes
e698260
 
3179a73
e698260
 
 
3179a73
 
 
 
 
 
 
 
e698260
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3179a73
 
 
 
 
 
 
 
e698260
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
import json
import file_name
import os


def load_groups_json():
    sample_groups_list = []
    speaker_groups_dict = []
    if os.path.exists(file_name.sample_groups_json):
        with open(file_name.sample_groups_json, "r", encoding="utf-8") as json_file_sample:
            sample_groups_list: list = json.load(json_file_sample)
    if os.path.exists(file_name.speaker_groups_json):
        with open(file_name.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 = file_name.transcribe_file
    subtitle = file_name.subtitle_file
    if adjustment:
        transcribe = file_name.transcribe_adjusted_file
        subtitle = file_name.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 = file_name.transcribe_file
    subtitle = file_name.subtitle_file
    if adjustment:
        transcribe = file_name.transcribe_adjusted_file
        subtitle = file_name.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