Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
lhoestq committed Feb 2, 2022
1 parent d9e7618 commit e8ebbaa
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Binary file added tests/features/data/test_audio_16000.mp3
Binary file not shown.
19 changes: 19 additions & 0 deletions tests/features/test_audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,25 @@ def test_audio_decode_example_mp3(shared_datadir):
assert decoded_example["path"] == audio_path
assert decoded_example["array"].shape == (109440,)
assert decoded_example["sampling_rate"] == 44100

@require_sox
@require_torchaudio
def test_audio_resampling_mp3_different_sampling_rates(shared_datadir):
audio_path = str(shared_datadir / "test_audio_44100.mp3")
audio_path2 = str(shared_datadir / "test_audio_16000.mp3")
audio = Audio(sampling_rate=48000)

decoded_example = audio.decode_example(audio.encode_example(audio_path))
assert decoded_example.keys() == {"path", "array", "sampling_rate"}
assert decoded_example["path"] == audio_path
assert decoded_example["array"].shape == (119119,)
assert decoded_example["sampling_rate"] == 48000

decoded_example = audio.decode_example(audio.encode_example(audio_path2))
assert decoded_example.keys() == {"path", "array", "sampling_rate"}
assert decoded_example["path"] == audio_path
assert decoded_example["array"].shape == (120960,)
assert decoded_example["sampling_rate"] == 48000


@require_sndfile
Expand Down

1 comment on commit e8ebbaa

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Show benchmarks

PyArrow==3.0.0

Show updated benchmarks!

Benchmark: benchmark_array_xd.json

metric read_batch_formatted_as_numpy after write_array2d read_batch_formatted_as_numpy after write_flattened_sequence read_batch_formatted_as_numpy after write_nested_sequence read_batch_unformated after write_array2d read_batch_unformated after write_flattened_sequence read_batch_unformated after write_nested_sequence read_col_formatted_as_numpy after write_array2d read_col_formatted_as_numpy after write_flattened_sequence read_col_formatted_as_numpy after write_nested_sequence read_col_unformated after write_array2d read_col_unformated after write_flattened_sequence read_col_unformated after write_nested_sequence read_formatted_as_numpy after write_array2d read_formatted_as_numpy after write_flattened_sequence read_formatted_as_numpy after write_nested_sequence read_unformated after write_array2d read_unformated after write_flattened_sequence read_unformated after write_nested_sequence write_array2d write_flattened_sequence write_nested_sequence
new / old (diff) 0.008732 / 0.011353 (-0.002621) 0.003678 / 0.011008 (-0.007330) 0.027503 / 0.038508 (-0.011005) 0.031631 / 0.023109 (0.008522) 0.255107 / 0.275898 (-0.020791) 0.279778 / 0.323480 (-0.043702) 0.007217 / 0.007986 (-0.000768) 0.003369 / 0.004328 (-0.000960) 0.008053 / 0.004250 (0.003802) 0.041350 / 0.037052 (0.004298) 0.257106 / 0.258489 (-0.001383) 0.291026 / 0.293841 (-0.002814) 0.028604 / 0.128546 (-0.099943) 0.009009 / 0.075646 (-0.066638) 0.224865 / 0.419271 (-0.194407) 0.045411 / 0.043533 (0.001879) 0.257863 / 0.255139 (0.002724) 0.278545 / 0.283200 (-0.004654) 0.098107 / 0.141683 (-0.043576) 1.610394 / 1.452155 (0.158240) 1.682854 / 1.492716 (0.190137)

Benchmark: benchmark_getitem_100B.json

metric get_batch_of_1024_random_rows get_batch_of_1024_rows get_first_row get_last_row
new / old (diff) 0.326403 / 0.018006 (0.308397) 0.531175 / 0.000490 (0.530685) 0.016864 / 0.000200 (0.016664) 0.000223 / 0.000054 (0.000168)

Benchmark: benchmark_indices_mapping.json

metric select shard shuffle sort train_test_split
new / old (diff) 0.031665 / 0.037411 (-0.005746) 0.019867 / 0.014526 (0.005341) 0.028318 / 0.176557 (-0.148238) 0.067400 / 0.737135 (-0.669736) 0.029146 / 0.296338 (-0.267192)

Benchmark: benchmark_iterating.json

metric read 5000 read 50000 read_batch 50000 10 read_batch 50000 100 read_batch 50000 1000 read_formatted numpy 5000 read_formatted pandas 5000 read_formatted tensorflow 5000 read_formatted torch 5000 read_formatted_batch numpy 5000 10 read_formatted_batch numpy 5000 1000 shuffled read 5000 shuffled read 50000 shuffled read_batch 50000 10 shuffled read_batch 50000 100 shuffled read_batch 50000 1000 shuffled read_formatted numpy 5000 shuffled read_formatted_batch numpy 5000 10 shuffled read_formatted_batch numpy 5000 1000
new / old (diff) 0.379080 / 0.215209 (0.163871) 3.789786 / 2.077655 (1.712132) 1.794521 / 1.504120 (0.290401) 1.620520 / 1.541195 (0.079325) 1.696820 / 1.468490 (0.228330) 0.387876 / 4.584777 (-4.196901) 4.144510 / 3.745712 (0.398798) 3.279406 / 5.269862 (-1.990456) 0.837430 / 4.565676 (-3.728246) 0.050374 / 0.424275 (-0.373901) 0.012858 / 0.007607 (0.005251) 0.481841 / 0.226044 (0.255796) 4.723688 / 2.268929 (2.454760) 2.132696 / 55.444624 (-53.311928) 1.815188 / 6.876477 (-5.061289) 1.853216 / 2.142072 (-0.288856) 0.494353 / 4.805227 (-4.310875) 0.109229 / 6.500664 (-6.391435) 0.055096 / 0.075469 (-0.020373)

Benchmark: benchmark_map_filter.json

metric filter map fast-tokenizer batched map identity map identity batched map no-op batched map no-op batched numpy map no-op batched pandas map no-op batched pytorch map no-op batched tensorflow
new / old (diff) 1.412288 / 1.841788 (-0.429499) 13.387166 / 8.074308 (5.312858) 23.946836 / 10.191392 (13.755444) 0.771750 / 0.680424 (0.091326) 0.449142 / 0.534201 (-0.085059) 0.435219 / 0.579283 (-0.144064) 0.451932 / 0.434364 (0.017568) 0.279399 / 0.540337 (-0.260938) 0.295741 / 1.386936 (-1.091195)
PyArrow==latest
Show updated benchmarks!

Benchmark: benchmark_array_xd.json

metric read_batch_formatted_as_numpy after write_array2d read_batch_formatted_as_numpy after write_flattened_sequence read_batch_formatted_as_numpy after write_nested_sequence read_batch_unformated after write_array2d read_batch_unformated after write_flattened_sequence read_batch_unformated after write_nested_sequence read_col_formatted_as_numpy after write_array2d read_col_formatted_as_numpy after write_flattened_sequence read_col_formatted_as_numpy after write_nested_sequence read_col_unformated after write_array2d read_col_unformated after write_flattened_sequence read_col_unformated after write_nested_sequence read_formatted_as_numpy after write_array2d read_formatted_as_numpy after write_flattened_sequence read_formatted_as_numpy after write_nested_sequence read_unformated after write_array2d read_unformated after write_flattened_sequence read_unformated after write_nested_sequence write_array2d write_flattened_sequence write_nested_sequence
new / old (diff) 0.007253 / 0.011353 (-0.004100) 0.003651 / 0.011008 (-0.007357) 0.025970 / 0.038508 (-0.012538) 0.030361 / 0.023109 (0.007252) 0.267036 / 0.275898 (-0.008862) 0.288705 / 0.323480 (-0.034775) 0.005768 / 0.007986 (-0.002217) 0.003388 / 0.004328 (-0.000940) 0.006664 / 0.004250 (0.002413) 0.036250 / 0.037052 (-0.000802) 0.262830 / 0.258489 (0.004341) 0.291359 / 0.293841 (-0.002482) 0.028026 / 0.128546 (-0.100520) 0.008838 / 0.075646 (-0.066809) 0.222014 / 0.419271 (-0.197257) 0.045846 / 0.043533 (0.002313) 0.256440 / 0.255139 (0.001301) 0.280407 / 0.283200 (-0.002793) 0.087499 / 0.141683 (-0.054184) 1.540036 / 1.452155 (0.087881) 1.608573 / 1.492716 (0.115857)

Benchmark: benchmark_getitem_100B.json

metric get_batch_of_1024_random_rows get_batch_of_1024_rows get_first_row get_last_row
new / old (diff) 0.335123 / 0.018006 (0.317117) 0.529205 / 0.000490 (0.528715) 0.009313 / 0.000200 (0.009113) 0.000428 / 0.000054 (0.000373)

Benchmark: benchmark_indices_mapping.json

metric select shard shuffle sort train_test_split
new / old (diff) 0.029914 / 0.037411 (-0.007497) 0.019067 / 0.014526 (0.004541) 0.026781 / 0.176557 (-0.149775) 0.064252 / 0.737135 (-0.672883) 0.028361 / 0.296338 (-0.267977)

Benchmark: benchmark_iterating.json

metric read 5000 read 50000 read_batch 50000 10 read_batch 50000 100 read_batch 50000 1000 read_formatted numpy 5000 read_formatted pandas 5000 read_formatted tensorflow 5000 read_formatted torch 5000 read_formatted_batch numpy 5000 10 read_formatted_batch numpy 5000 1000 shuffled read 5000 shuffled read 50000 shuffled read_batch 50000 10 shuffled read_batch 50000 100 shuffled read_batch 50000 1000 shuffled read_formatted numpy 5000 shuffled read_formatted_batch numpy 5000 10 shuffled read_formatted_batch numpy 5000 1000
new / old (diff) 0.384211 / 0.215209 (0.169002) 3.836811 / 2.077655 (1.759156) 1.697095 / 1.504120 (0.192975) 1.527840 / 1.541195 (-0.013354) 1.606253 / 1.468490 (0.137763) 0.385578 / 4.584777 (-4.199199) 4.130986 / 3.745712 (0.385273) 3.146530 / 5.269862 (-2.123332) 0.887561 / 4.565676 (-3.678115) 0.047308 / 0.424275 (-0.376967) 0.010974 / 0.007607 (0.003367) 0.481477 / 0.226044 (0.255433) 4.729560 / 2.268929 (2.460631) 2.108893 / 55.444624 (-53.335731) 1.779112 / 6.876477 (-5.097365) 1.901504 / 2.142072 (-0.240569) 0.494854 / 4.805227 (-4.310374) 0.109049 / 6.500664 (-6.391615) 0.054213 / 0.075469 (-0.021257)

Benchmark: benchmark_map_filter.json

metric filter map fast-tokenizer batched map identity map identity batched map no-op batched map no-op batched numpy map no-op batched pandas map no-op batched pytorch map no-op batched tensorflow
new / old (diff) 1.421517 / 1.841788 (-0.420271) 12.392075 / 8.074308 (4.317766) 23.640773 / 10.191392 (13.449381) 0.772778 / 0.680424 (0.092354) 0.453692 / 0.534201 (-0.080509) 0.452780 / 0.579283 (-0.126503) 0.450879 / 0.434364 (0.016515) 0.287066 / 0.540337 (-0.253271) 0.296607 / 1.386936 (-1.090329)

CML watermark

Please sign in to comment.