### Install and Run Pytest Source: https://github.com/maxrmorrison/torchcrepe/blob/master/README.md Install the pytest framework and then run the tests for the module. ```bash pip install pytest pytest ``` -------------------------------- ### Compute CREPE Model Output Activations Source: https://github.com/maxrmorrison/torchcrepe/blob/master/README.md Preprocesses audio data and infers the CREPE model output probabilities. ```python batch = next(torchcrepe.preprocess(audio, sr, hop_length)) probabilities = torchcrepe.infer(batch) ``` -------------------------------- ### Torchcrepe Command-Line Interface Usage Source: https://github.com/maxrmorrison/torchcrepe/blob/master/README.md The CLI allows batch processing of audio files for pitch or embedding prediction. Specify input audio files and output file paths, with options for hop length, periodicity output, and model parameters. ```bash usage: python -m torchcrepe [-h] --audio_files AUDIO_FILES [AUDIO_FILES ...] --output_files OUTPUT_FILES [OUTPUT_FILES ...] [--hop_length HOP_LENGTH] [--output_periodicity_files OUTPUT_PERIODICITY_FILES [OUTPUT_PERIODICITY_FILES ...]] [--embed] [--fmin FMIN] [--fmax FMAX] [--model MODEL] [--decoder DECODER] [--gpu GPU] [--no_pad] optional arguments: -h, --help show this help message and exit --audio_files AUDIO_FILES [AUDIO_FILES ...] The audio file to process --output_files OUTPUT_FILES [OUTPUT_FILES ...] The file to save pitch or embedding --hop_length HOP_LENGTH The hop length of the analysis window --output_periodicity_files OUTPUT_PERIODICITY_FILES [OUTPUT_PERIODICITY_FILES ...] The file to save periodicity --embed Performs embedding instead of pitch prediction --fmin FMIN The minimum frequency allowed --fmax FMAX The maximum frequency allowed --model MODEL The model capacity. One of "tiny" or "full" --decoder DECODER The decoder to use. One of "argmax", "viterbi", or "weighted_argmax" --gpu GPU The gpu to perform inference on --no_pad Whether to pad the audio ``` -------------------------------- ### Compute Pitch and Periodicity from Audio Source: https://github.com/maxrmorrison/torchcrepe/blob/master/README.md Load audio, set parameters like hop length, frequency range, model capacity, device, and batch size, then predict pitch. Periodicity can be returned by setting return_periodicity=True. ```python import torchcrepe # Load audio audio, sr = torchcrepe.load.audio( ... ) # Here we'll use a 5 millisecond hop length hop_length = int(sr / 200.) # Provide a sensible frequency range for your domain (upper limit is 2006 Hz) # This would be a reasonable range for speech fmin = 50 fmax = 550 # Select a model capacity--one of "tiny" or "full" model = 'tiny' # Choose a device to use for inference device = 'cuda:0' # Pick a batch size that doesn't cause memory errors on your gpu batch_size = 2048 # Compute pitch using first gpu pitch = torchcrepe.predict(audio, sr, hop_length, fmin, fmax, model, batch_size=batch_size, device=device) ``` -------------------------------- ### Torchcrepe Python API for File Prediction Source: https://github.com/maxrmorrison/torchcrepe/blob/master/README.md Use these functions to predict pitch directly from audio files. They support single file or batch processing and can output to specified files. ```python torchcrepe.predict_from_file(audio_file, ...) ``` ```python torchcrepe.predict_from_file_to_file( audio_file, output_pitch_file, output_periodicity_file, ...) ``` ```python torchcrepe.predict_from_files_to_files( audio_files, output_pitch_files, output_periodicity_files, ...) ``` -------------------------------- ### Decoding Options for Pitch Prediction Source: https://github.com/maxrmorrison/torchcrepe/blob/master/README.md Demonstrates different decoding strategies for pitch prediction, including Viterbi decoding (default), weighted argmax, and simple argmax. ```python # Decode using viterbi decoding (default) torchcrepe.predict(..., decoder=torchcrepe.decode.viterbi) # Decode using weighted argmax (as in the original implementation) torchcrepe.predict(..., decoder=torchcrepe.decode.weighted_argmax) # Decode using argmax torchcrepe.predict(..., decoder=torchcrepe.decode.argmax) ``` -------------------------------- ### Filter and Threshold Pitch Predictions Source: https://github.com/maxrmorrison/torchcrepe/blob/master/README.md Applies median filtering to periodicity, thresholds pitch based on periodicity, and optionally smooths pitch using a mean filter. Parameters should be tuned to the specific data. ```python # We'll use a 15 millisecond window assuming a hop length of 5 milliseconds win_length = 3 # Median filter noisy confidence value periodicity = torchcrepe.filter.median(periodicity, win_length) # Remove inharmonic regions pitch = torchcrepe.threshold.At(.21)(pitch, periodicity) # Optionally smooth pitch to remove quantization artifacts pitch = torchcrepe.filter.mean(pitch, win_length) ``` -------------------------------- ### Torchcrepe Python API for File Embedding Source: https://github.com/maxrmorrison/torchcrepe/blob/master/README.md These functions generate embeddings from audio files. Similar to pitch prediction, they handle single or batch operations and output to files. ```python torchcrepe.embed_from_file(audio_file, ...) ``` ```python torchcrepe.embed_from_file_to_file(audio_file, output_file, ...) ``` ```python torchcrepe.embed_from_files_to_files(audio_files, output_files, ...) ``` -------------------------------- ### Threshold Pitch in Silent Regions Source: https://github.com/maxrmorrison/torchcrepe/blob/master/README.md Uses the Silence threshold to manually set periodicity to zero in detected silent regions, addressing potential high confidence assignments in noise. ```python periodicity = torchcrepe.threshold.Silence(-60.)(periodicity, audio, sr, hop_length) ``` -------------------------------- ### Compute CREPE Embedding Space Source: https://github.com/maxrmorrison/torchcrepe/blob/master/README.md Extracts pitch embeddings from audio data using a pretrained pitch embedding space, similar to DDSP. ```python embeddings = torchcrepe.embed(audio, sr, hop_length) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.