| | |
| | | # -*- encoding: utf-8 -*- |
| | | #!/usr/bin/env python3 |
| | | # -*- encoding: utf-8 -*- |
| | | # Copyright FunASR (https://github.com/alibaba-damo-academy/FunASR). All Rights Reserved. |
| | | # MIT License (https://opensource.org/licenses/MIT) |
| | | |
| | |
| | | import logging |
| | | import os |
| | | import sys |
| | | from typing import Union, Dict, Any |
| | | |
| | | from funasr.utils import config_argparse |
| | | from funasr.utils.cli_utils import get_commandline_args |
| | | from funasr.utils.types import str2bool |
| | | from funasr.utils.types import str2triple_str |
| | | from funasr.utils.types import str_or_none |
| | | import argparse |
| | | import logging |
| | | import os |
| | | import sys |
| | | from pathlib import Path |
| | | from typing import Any |
| | | from typing import List |
| | | from typing import Optional |
| | | from typing import Sequence |
| | | from typing import Tuple |
| | |
| | | import torch |
| | | from kaldiio import WriteHelper |
| | | from typeguard import check_argument_types |
| | | from typeguard import check_return_type |
| | | |
| | | from funasr.utils.cli_utils import get_commandline_args |
| | | from funasr.tasks.sv import SVTask |
| | | from funasr.torch_utils.device_funcs import to_device |
| | | from funasr.bin.sv_infer import Speech2Xvector |
| | | from funasr.build_utils.build_streaming_iterator import build_streaming_iterator |
| | | from funasr.torch_utils.set_all_random_seed import set_all_random_seed |
| | | from funasr.utils import config_argparse |
| | | from funasr.utils.cli_utils import get_commandline_args |
| | | from funasr.utils.types import str2bool |
| | | from funasr.utils.types import str2triple_str |
| | | from funasr.utils.types import str_or_none |
| | | from funasr.utils.misc import statistic_model_parameters |
| | | from funasr.bin.sv_infer import Speech2Xvector |
| | | |
| | | |
| | | def inference_sv( |
| | | output_dir: Optional[str] = None, |
| | |
| | | data_path_and_name_and_type = [raw_inputs, "speech", "waveform"] |
| | | |
| | | # 3. Build data-iterator |
| | | loader = SVTask.build_streaming_iterator( |
| | | data_path_and_name_and_type, |
| | | loader = build_streaming_iterator( |
| | | task_name="sv", |
| | | preprocess_args=None, |
| | | data_path_and_name_and_type=data_path_and_name_and_type, |
| | | dtype=dtype, |
| | | batch_size=batch_size, |
| | | key_file=key_file, |
| | | num_workers=num_workers, |
| | | preprocess_fn=None, |
| | | collate_fn=None, |
| | | allow_variable_data_keys=allow_variable_data_keys, |
| | | inference=True, |
| | | use_collate_fn=False, |
| | | ) |
| | | |
| | | # 7 .Start for-loop |
| | |
| | | return _forward |
| | | |
| | | |
| | | |
| | | |
| | | def inference_launch(mode, **kwargs): |
| | | if mode == "sv": |
| | | return inference_sv(**kwargs) |
| | |
| | | logging.info("Unknown decoding mode: {}".format(mode)) |
| | | return None |
| | | |
| | | |
| | | def get_parser(): |
| | | parser = config_argparse.ArgumentParser( |
| | | description="Speaker Verification", |