Skip to content

Commit

Permalink
Fix passing wrong type of parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
BreezeWhite committed May 10, 2021
1 parent 9c774d8 commit fe459f4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions omnizart/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import jsonschema
import pretty_midi
import numpy as np
import scipy.io.wavfile as wave

from omnizart.constants.midi import SOUNDFONT_PATH
Expand Down Expand Up @@ -363,7 +364,7 @@ def aggregate_f0_info(pred, t_unit):
start_idx = 0
last_hz = pred[0]
eps = 1e-6
pred.append(0) # Append an additional zero to the end temporarily.
pred = np.append(pred, 0) # Append an additional zero to the end temporarily.
while cur_idx < len(pred):
cur_hz = pred[cur_idx]
if abs(cur_hz - last_hz) < eps:
Expand All @@ -390,5 +391,5 @@ def aggregate_f0_info(pred, t_unit):
cur_idx += 1
last_hz = cur_hz

del pred[-1] # Remove the additional ending zero.
pred = pred[:-1] # Remove the additional ending zero.
return results
3 changes: 2 additions & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import shutil

import pytest
import numpy as np
from jsonschema import ValidationError

from omnizart import utils
Expand Down Expand Up @@ -187,7 +188,7 @@ def test_serializable_recursive_value_path():

def test_aggregate_f0_info():
t_unit = 0.01
data = [0, 0, 0, 440, 440, 440, 440, 0, 0, 0, 220, 220]
data = np.array([0, 0, 0, 440, 440, 440, 440, 0, 0, 0, 220, 220])
expected = [
{"start_time": 0.03, "end_time": 0.07, "frequency": 440, "pitch": 69},
{"start_time": 0.1, "end_time": 0.12, "frequency": 220, "pitch": 57}
Expand Down

0 comments on commit fe459f4

Please sign in to comment.