From 61e7b4bef6ba66a17a059ff7ace5730e6d8e1f12 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sun, 14 Jan 2024 17:31:03 -0600 Subject: [PATCH] torbi --- penn/decode.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/penn/decode.py b/penn/decode.py index 16dbf6d..f9e22b3 100644 --- a/penn/decode.py +++ b/penn/decode.py @@ -104,6 +104,8 @@ def initial(self): initial = torch.zeros(2 * penn.PITCH_BINS) initial[penn.PITCH_BINS:] = 1 / penn.PITCH_BINS + return initial + @functools.cached_property def transition(self): """Create the Viterbi transition matrix for PYIN""" @@ -114,6 +116,8 @@ def transition(self): torch.tensor([[.99, .01], [.01, .99]]), transition) + return transition + class Viterbi(Decoder): @@ -129,11 +133,11 @@ def __call__(self, logits): gpu = ( None if distributions.device.type == 'cpu' else distributions.device.index) - bins = torbi.decode( - distributions[0].T, - self.transition(), - self.initial(), - gpu) + bins = torbi.from_probabilities( + observation=distributions[0].T.unsqueeze(dim=0), + transition=self.transition, + initial=self.initial, + gpu=gpu) # Convert to frequency in Hz if self.local_expected_value: @@ -149,7 +153,7 @@ def __call__(self, logits): return bins.T, pitch.T @functools.cached_property - def transition(self): + def initial(self): """Create uniform initial probabilities""" return torch.full((penn.PITCH_BINS,), 1 / penn.PITCH_BINS)