| | |
| | | def __iter__(self) -> Iterator[Tuple[Union[str, int], Dict[str, np.ndarray]]]: |
| | | count = 0 |
| | | if len(self.path_name_type_list) != 0 and (self.path_name_type_list[0][2] == "bytes" or self.path_name_type_list[0][2] == "waveform"): |
| | | linenum = len(self.path_name_type_list) |
| | | data = {} |
| | | value = self.path_name_type_list[0][0] |
| | | for i in range(linenum): |
| | | value = self.path_name_type_list[i][0] |
| | | uid = 'utt_id' |
| | | name = self.path_name_type_list[0][1] |
| | | _type = self.path_name_type_list[0][2] |
| | | name = self.path_name_type_list[i][1] |
| | | _type = self.path_name_type_list[i][2] |
| | | func = DATA_TYPES[_type] |
| | | array = func(value) |
| | | if self.fs is not None and name == "speech": |
| | | if self.fs is not None and (name == "speech" or name == "ref_speech"): |
| | | audio_fs = self.fs["audio_fs"] |
| | | model_fs = self.fs["model_fs"] |
| | | if audio_fs is not None and model_fs is not None: |
| | |
| | | yield uid, data |
| | | |
| | | elif len(self.path_name_type_list) != 0 and self.path_name_type_list[0][2] == "sound" and not self.path_name_type_list[0][0].lower().endswith(".scp"): |
| | | linenum = len(self.path_name_type_list) |
| | | data = {} |
| | | value = self.path_name_type_list[0][0] |
| | | uid = os.path.basename(self.path_name_type_list[0][0]).split(".")[0] |
| | | name = self.path_name_type_list[0][1] |
| | | _type = self.path_name_type_list[0][2] |
| | | for i in range(linenum): |
| | | value = self.path_name_type_list[i][0] |
| | | uid = os.path.basename(self.path_name_type_list[i][0]).split(".")[0] |
| | | name = self.path_name_type_list[i][1] |
| | | _type = self.path_name_type_list[i][2] |
| | | if _type == "sound": |
| | | audio_type = os.path.basename(value).split(".")[1].lower() |
| | | if audio_type not in SUPPORT_AUDIO_TYPE_SETS: |
| | |
| | | |
| | | func = DATA_TYPES[_type] |
| | | array = func(value) |
| | | if self.fs is not None and name == "speech": |
| | | if self.fs is not None and (name == "speech" or name == "ref_speech"): |
| | | audio_fs = self.fs["audio_fs"] |
| | | model_fs = self.fs["model_fs"] |
| | | if audio_fs is not None and model_fs is not None: |