infer module

infer.predict(model, audio, device)[source]

Function that return the prediction of the model, i.e the argmax of the softmax of the logits.

Parameters:
  • model (nn.Module) – pytorch neural network

  • audio (torch.tensor) – audio tensor

  • device (torch.device) – Preferably cpu

Returns:

predicted label

Return type:

str

infer.record(seconds=1, sample_rate=16000)[source]

Function to record the user using the machine default microphone

Parameters:
  • seconds (int, optional) – Defaults to 1.

  • sample_rate (int, optional) – Defaults to 16000.

Yields:

torch.tensor – A 1 dimensional tensor representing the audio