| | |
| | | Examples: |
| | | >>> import soundfile |
| | | >>> import numpy as np |
| | | >>> speech2diar = Speech2Diarization("diar_sond_config.yml", "diar_sond.pth") |
| | | >>> speech2diar = Speech2Diarization("diar_sond_config.yml", "diar_sond.pb") |
| | | >>> profile = np.load("profiles.npy") |
| | | >>> audio, rate = soundfile.read("speech.wav") |
| | | >>> speech2diar(audio, profile) |
| | |
| | | dur_threshold: int = 10, |
| | | out_format: str = "vad", |
| | | param_dict: Optional[dict] = None, |
| | | mode: str = "sond", |
| | | **kwargs, |
| | | ): |
| | | assert check_argument_types() |
| | |
| | | set_all_random_seed(seed) |
| | | |
| | | # 2a. Build speech2xvec [Optional] |
| | | if param_dict is not None and "extract_profile" in param_dict and param_dict["extract_profile"]: |
| | | if mode == "sond_demo" and param_dict is not None and "extract_profile" in param_dict and param_dict["extract_profile"]: |
| | | assert "sv_train_config" in param_dict, "sv_train_config must be provided param_dict." |
| | | assert "sv_model_file" in param_dict, "sv_model_file must be provided in param_dict." |
| | | sv_train_config = param_dict["sv_train_config"] |
| | |
| | | logging.info("param_dict: {}".format(param_dict)) |
| | | if data_path_and_name_and_type is None and raw_inputs is not None: |
| | | if isinstance(raw_inputs, (list, tuple)): |
| | | if not isinstance(raw_inputs[0], List): |
| | | raw_inputs = [raw_inputs] |
| | | |
| | | assert all([len(example) >= 2 for example in raw_inputs]), \ |
| | | "The length of test case in raw_inputs must larger than 1 (>=2)." |
| | | if not isinstance(raw_inputs, List): |
| | | raw_inputs = [raw_inputs] |
| | | |
| | | def prepare_dataset(): |
| | | for idx, example in enumerate(raw_inputs): |