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
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
- 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]#
- 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
- 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.