speaker_verification_task#

(s3prl.task.speaker_verification_task)

Speaker Verification with Softmax-based loss

Authors
  • Po-Han Chi 2021

  • Haibin Wu 2022

SpeakerClassifier#

class s3prl.task.speaker_verification_task.SpeakerClassifier(input_size=3, output_size=4)[source][source]#

Bases: Module

input_size[source]#

int

output_size[source]#

int

property input_size[source]#
property output_size[source]#
forward(x, x_len)[source][source]#
Parameters:
  • x (torch.Tensor) – (batch_size, timestemps, input_size)

  • x_len (torch.LongTensor) – (batch_size, )

Returns:

(batch_size, output_size)

Return type:

output (torch.Tensor)

call_super_init: bool = False[source]#
dump_patches: bool = False[source]#
training: bool[source]#

SpeakerVerification#

class s3prl.task.speaker_verification_task.SpeakerVerification(model: SpeakerClassifier, category: CategoryEncoder, test_trials: Optional[List[Tuple[int, str, str]]] = None, loss_type: str = 'amsoftmax', loss_conf: Optional[dict] = None)[source][source]#

Bases: Task

model.output_size should match len(categories)

Parameters:
  • model (SpeakerClassifier) – actual model or a callable config for the model

  • categories (dict[str]) – each key in the Dictionary is the final prediction content in str. use categories[key] to encode as numeric label

  • test_trials (List[Tuple[int, str, str]]) – each tuple in the list consists of (label, enroll_utt, test_utt)

  • loss_type (str) – softmax or amsoftmax

  • loss_conf (dict) – arguments for the loss_type class

loss: torch.nn.Module[source]#
get_state()[source][source]#
set_state(state: dict)[source][source]#
predict(x: Tensor, x_len: LongTensor)[source][source]#
Parameters:
  • x (torch.Tensor) – (batch_size, timestamps, input_size)

  • x_len (torch.LongTensor) – (batch_size, )

Returns:

torch.Tensor

(batch_size, output_size)

train_step(x: Tensor, x_len: LongTensor, class_id: LongTensor, unique_name: List[str], _dump_dir: Optional[str] = None)[source][source]#
train_reduction(cached_results: list, _dump_dir: Optional[str] = None)[source][source]#
test_step(x: Tensor, x_len: LongTensor, unique_name: List[str], _dump_dir: str)[source][source]#
Parameters:
  • x (torch.Tensor) – (batch_size, timestamps, input_size)

  • x_len – torch.LongTensor

  • unique_name (List[str]) –

Returns:

unique_name (List[str]) output (torch.Tensor):

speaker embeddings corresponding to unique_name

test_reduction(cached_results: List[dict], _dump_dir: str)[source][source]#
call_super_init: bool = False[source]#
dump_patches: bool = False[source]#
forward(mode: str, *args, **kwargs)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

parse_cached_results(cached_results: List[dict])[source]#
reduction(mode: str, *args, **kwargs)[source]#
abstract valid_reduction()[source]#
abstract valid_step()[source]#
training: bool[source]#