{"id":13611256,"url":"https://github.com/adefossez/julius","last_synced_at":"2025-04-13T20:18:54.919Z","repository":{"id":44729948,"uuid":"307341988","full_name":"adefossez/julius","owner":"adefossez","description":"Fast PyTorch based DSP for audio and 1D signals","archived":false,"fork":false,"pushed_at":"2025-02-17T12:59:31.000Z","size":226,"stargazers_count":436,"open_issues_count":1,"forks_count":25,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-04-06T18:08:27.637Z","etag":null,"topics":["dsp","pytorch"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adefossez.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-26T10:54:21.000Z","updated_at":"2025-04-05T20:32:28.000Z","dependencies_parsed_at":"2025-03-09T14:11:06.816Z","dependency_job_id":"f0f2ac59-6494-4a9b-8769-b9b8f76bb98e","html_url":"https://github.com/adefossez/julius","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adefossez%2Fjulius","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adefossez%2Fjulius/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adefossez%2Fjulius/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adefossez%2Fjulius/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adefossez","download_url":"https://codeload.github.com/adefossez/julius/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248775148,"owners_count":21159562,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dsp","pytorch"],"created_at":"2024-08-01T19:01:53.404Z","updated_at":"2025-04-13T20:18:54.892Z","avatar_url":"https://github.com/adefossez.png","language":"Python","funding_links":[],"categories":["音频处理"],"sub_categories":[],"readme":"# Julius, fast PyTorch based DSP for audio and 1D signals\r\n\r\n![linter badge](https://github.com/adefossez/julius/workflows/linter/badge.svg)\r\n![tests badge](https://github.com/adefossez/julius/workflows/tests/badge.svg)\r\n![cov badge](https://github.com/adefossez/julius/workflows/cov%3E90%25/badge.svg)\r\n\r\nJulius contains different Digital Signal Processing algorithms implemented\r\nwith PyTorch, so that they are differentiable and available on CUDA.\r\nNote that all the modules implemented here can be used with TorchScript.\r\n\r\nFor now, I have implemented:\r\n\r\n- [julius.resample](https://adefossez.github.io/julius/julius/resample.html): fast sinc resampling.\r\n- [julius.fftconv](https://adefossez.github.io/julius/julius/fftconv.html): FFT based convolutions.\r\n- [julius.lowpass](https://adefossez.github.io/julius/julius/lowpass.html): FIR low pass filter banks.\r\n- [julius.filters](https://adefossez.github.io/julius/julius/filters.html): FIR high pass and band pass filters.\r\n- [julius.bands](https://adefossez.github.io/julius/julius/bands.html): Decomposition of a waveform signal over mel-scale frequency bands.\r\n\r\nAlong that, you might found useful utilities in:\r\n\r\n- [julius.core](https://adefossez.github.io/julius/julius/core.html): DSP related functions.\r\n- [julius.utils](https://adefossez.github.io/julius/julius/utils.html): Generic utilities.\r\n\r\n\u003cp align=\"center\"\u003e\r\n\u003cimg src=\"./logo.png\" alt=\"Representation of the convolutions filters used for the efficient resampling.\"\r\nwidth=\"500px\"\u003e\u003c/p\u003e\r\n\r\n## News\r\n\r\n- 19/09/2022: __`julius` 0.2.7 released:__: fixed ONNX compat (thanks @iver56). I know I missed the 0.2.6 one...\r\n- 28/07/2021: __`julius` 0.2.5 released:__: support for setting a custom output length when resampling.\r\n- 22/06/2021: __`julius` 0.2.4 released:__: adding highpass and band passfilters.\r\n  Extra linting and type checking of the code. New `unfold` implemention, up to\r\n  x6 faster FFT convolutions and more efficient memory usage.\r\n- 26/01/2021: __`julius` 0.2.2 released:__ fixing normalization of filters in lowpass and resample to avoid very low frequencies to be leaked.\r\n  Switch from zero padding to replicate padding (uses first/last value instead of 0) to avoid discontinuities with strong artifacts.\r\n- 20/01/2021: `julius` implementation of resampling is now officially \u003ca href=\"https://github.com/pytorch/audio/pull/1087\"\u003epart of Torchaudio.\u003c/a\u003e\r\n\r\n## Installation\r\n\r\n`julius` requires python 3.6. To install:\r\n```bash\r\npip3 install -U julius\r\n```\r\n\r\n\r\n## Usage\r\n\r\nSee the [Julius documentation][docs] for the usage of Julius. Hereafter you will find a few examples\r\nto get you quickly started:\r\n\r\n```python3\r\nimport julius\r\nimport torch\r\n\r\nsignal = torch.randn(6, 4, 1024)\r\n# Resample from a sample rate of 100 to 70. The old and new sample rate must be integers,\r\n# and resampling will be fast if they form an irreductible fraction with small numerator\r\n# and denominator (here 10 and 7). Any shape is supported, last dim is time.\r\nresampled_signal = julius.resample_frac(signal, 100, 70)\r\n\r\n# Low pass filter with a `0.1 * sample_rate` cutoff frequency.\r\nlow_freqs = julius.lowpass_filter(signal, 0.1)\r\n\r\n# Fast convolutions with FFT, useful for large kernels\r\nconv = julius.FFTConv1d(4, 10, 512)\r\nconvolved = conv(signal)\r\n\r\n# Decomposition over frequency bands in the Waveform domain\r\nbands = julius.split_bands(signal, n_bands=10, sample_rate=100)\r\n# Decomposition with n_bands frequency bands evenly spaced in mel space.\r\n# Input shape can be `[*, T]`, output will be `[n_bands, *, T]`.\r\nrandom_eq = (torch.rand(10, 1, 1, 1) * bands).sum(0)\r\n```\r\n\r\n## Algorithms\r\n\r\n### Resample\r\n\r\nThis is an implementation of the [sinc resample algorithm][resample] by Julius O. Smith.\r\nIt is the same algorithm than the one used in [resampy][resampy] but to run efficiently on GPU it\r\nis limited to fractional changes of the sample rate. It will be fast if the old and new sample rate\r\nare small after dividing them by their GCD. For instance going from a sample rate of 2000 to 3000 (2, 3 after removing the GCD)\r\nwill be extremely fast, while going from 20001 to 30001 will not.\r\nJulius resampling is faster than resampy even on CPU, and when running on GPU it makes resampling a completely negligible part of your pipeline\r\n(except of course for weird cases like going from a sample rate of 20001 to 30001).\r\n\r\n\r\n### FFTConv1d\r\n\r\nComputing convolutions with very large kernels (\u003e= 128) and a stride of 1 can be much faster\r\nusing FFT. This implements the same API as `torch.nn.Conv1d` and `torch.nn.functional.conv1d`\r\nbut with a FFT backend. Dilation and groups are not supported.\r\nFFTConv will be faster on CPU even for relatively small tensors (a few dozen channels, kernel size\r\nof 128). On CUDA, due to the higher parallelism, regular convolution can be faster in many cases,\r\nbut for kernel sizes above 128, for a large number of channels or batch size, FFTConv1d\r\nwill eventually be faster (basically when you no longer have idle cores that can hide\r\nthe true complexity of the operation).\r\n\r\n### LowPass\r\n\r\nClassical Finite Impulse Reponse windowed sinc lowpass filter. It will use FFT convolutions automatically\r\nif the filter size is large enough. This is the basic block from which you can build\r\nhigh pass and band pass filters (see `julius.filters`).\r\n\r\n### Bands\r\n\r\nDecomposition of a signal over frequency bands in the waveform domain. This can be useful for\r\ninstance to perform parametric EQ (see [Usage](#usage) above).\r\n\r\n## Benchmarks\r\n\r\nYou can find speed tests (and comparisons to reference implementations) on the\r\n[benchmark][bench]. The CPU benchmarks are run on a Mac Book Pro 2020, with a 2.4 GHz\r\n8-core intel CPU i9. The GPUs benchmark are run on Nvidia V100 with 16GB of memory.\r\nWe also compare the validity of our implementations, as compared to reference ones like `resampy`\r\nor `torch.nn.Conv1d`.\r\n\r\n\r\n\r\n## Running tests\r\n\r\nClone this repository, then\r\n```bash\r\npip3 install .[dev]'\r\npython3 tests.py\r\n```\r\n\r\nTo run the benchmarks:\r\n```\r\npip3 install .[dev]'\r\npython3 -m bench.gen\r\n```\r\n\r\n\r\n## License\r\n\r\n`julius` is released under the MIT license.\r\n\r\n## Thanks\r\n\r\nThis package is named in the honor of\r\n[Julius O. Smith](https://ccrma.stanford.edu/~jos/),\r\nwhose books and website were a gold mine of information for me to learn about DSP. Go checkout his website if you want\r\nto learn more about DSP.\r\n\r\n\r\n[resample]: https://ccrma.stanford.edu/~jos/resample/resample.html\r\n[resampy]: https://resampy.readthedocs.io/\r\n[docs]:  https://adefossez.github.io/julius/julius/index.html\r\n[bench]:  ./bench.md\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadefossez%2Fjulius","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadefossez%2Fjulius","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadefossez%2Fjulius/lists"}