Skip to content
Snippets Groups Projects
Select Git revision
  • f9bd449b06815cfba0e250bd648c4e740f8b5857
  • master default
  • object
  • develop protected
  • private_algos
  • cuisine
  • SMOTE
  • revert-76c4cca5
  • archive protected
  • no_graphviz
  • 0.0.2
  • 0.0.1
12 results

Versions.py

Blame
  • test_cli.py 1.27 KiB
    import glob
    import itertools
    import os
    
    import pytest
    
    import torch
    import torchaudio
    
    
    AUDIOS_DIR = os.path.join(os.path.dirname(__file__), "audios")
    
    
    @pytest.mark.parametrize("file, fmt, convert_to_freq",
                             itertools.product(glob.glob(AUDIOS_DIR + "/*.wav"), ["csv", "npz", "png"], [True, False]))
    def test_cli(file, fmt, convert_to_freq):
        if convert_to_freq:
            suffix = ".f0." + fmt
            option = ""
        else:
            suffix = ".semitones." + fmt
            option = " -F"
        os.system(f"pesto {file} --export_format " + fmt + option)
        out_file = file.rsplit('.', 1)[0] + suffix
        assert os.path.isfile(out_file)
        os.unlink(out_file)
    
    
    @pytest.mark.skipif(not torch.cuda.is_available(), reason="GPU not available")
    @pytest.mark.parametrize("file, fmt, convert_to_freq",
                             itertools.product(glob.glob(AUDIOS_DIR + "/*.wav"), ["csv", "npz", "png"], [True, False]))
    def test_cli_gpu(file, fmt, convert_to_freq):
        if convert_to_freq:
            suffix = ".f0." + fmt
            option = ""
        else:
            suffix = ".semitones." + fmt
            option = " -F"
        os.system(f"pesto {file} --gpu 0 --export_format " + fmt + option)
        out_file = file.rsplit('.', 1)[0] + suffix
        assert os.path.isfile(out_file)
        os.unlink(out_file)