-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename best_offset and its arguments. Set up a test system.
- Loading branch information
Showing
15 changed files
with
94 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
from .alignment import best_offset, align | ||
from .alignment import find_best_alignment_offset, align | ||
|
||
__version__ = "0.1.2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[pytest] | ||
python_files=test*.py | ||
norecursedirs = .git .github .idea fast_align_audio.egg-info build dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import os | ||
from pathlib import Path | ||
|
||
import librosa | ||
import numpy as np | ||
|
||
import fast_align_audio | ||
|
||
DEMO_DIR = Path(os.path.abspath(os.path.dirname(os.path.dirname(__file__)))) | ||
TEST_FIXTURES_DIR = DEMO_DIR / "test_fixtures" | ||
|
||
|
||
class TestFindBestAlignmentOffset: | ||
def test_simple_padded_array(self): | ||
reference = np.random.uniform(size=10_000).astype("float32") | ||
delayed = np.pad(reference, (121, 0)) | ||
offset = fast_align_audio.find_best_alignment_offset( | ||
reference, delayed, max_offset_samples=1000, lookahead_samples=5000 | ||
) | ||
assert offset == 121 | ||
|
||
def test_multi_mic1(self): | ||
main, sr = librosa.load(TEST_FIXTURES_DIR / "multi_mic1" / "main.flac", sr=None) | ||
other1, _ = librosa.load( | ||
TEST_FIXTURES_DIR / "multi_mic1" / "other1.flac", sr=None | ||
) | ||
other2, _ = librosa.load( | ||
TEST_FIXTURES_DIR / "multi_mic1" / "other2.flac", sr=None | ||
) | ||
other3, _ = librosa.load( | ||
TEST_FIXTURES_DIR / "multi_mic1" / "other3.flac", sr=None | ||
) | ||
|
||
max_offset_samples = int(0.05 * sr) | ||
|
||
offset1 = fast_align_audio.find_best_alignment_offset( | ||
main, other1, max_offset_samples=max_offset_samples | ||
) | ||
print(offset1, "offset1") | ||
|
||
offset2 = fast_align_audio.find_best_alignment_offset( | ||
main, other2, max_offset_samples=max_offset_samples | ||
) | ||
print(offset2, "offset2") | ||
|
||
offset3 = fast_align_audio.find_best_alignment_offset( | ||
main, other3, max_offset_samples=max_offset_samples | ||
) | ||
print(offset3, "offset3") | ||
|
||
# TODO: Assert that the offsets are sane | ||
|
||
# TODO | ||
# def test_multi_mic2(self): |