{ "info": { "author": "Prem Seetharaman", "author_email": "prem@u.northwestern.edu", "bugtrack_url": null, "classifiers": [ "Environment :: Plugins", "Intended Audience :: Developers", "Intended Audience :: Science/Research", "License :: OSI Approved :: BSD License", "Operating System :: MacOS :: MacOS X", "Operating System :: Microsoft :: Windows", "Operating System :: POSIX", "Programming Language :: C++", "Programming Language :: Python :: 3", "Topic :: Multimedia :: Sound/Audio", "Topic :: Scientific/Engineering :: Artificial Intelligence" ], "description": "[![Build Status](https://travis-ci.com/pseeth/pytorch-stft.svg?branch=master)](https://travis-ci.com/pseeth/pytorch-stft)\n\n# STFT/iSTFT in PyTorch\n\nAn STFT/iSTFT written up in PyTorch using 1D Convolutions. Requirements are a recent version PyTorch, numpy, and librosa (for loading audio in test_stft.py). Thanks to Shrikant Venkataramani for sharing code this was based off of and Rafael Valle for catching bugs and adding the proper windowing logic. Uses Python 3.\n\n## Installation\nInstall easily with pip:\n```\npip install torch_stft\n```\n\n## Usage\n```\nimport torch\nfrom torch_stft import STFT\nimport numpy as np\nimport librosa \nimport matplotlib.pyplot as plt\n\naudio = librosa.load(librosa.util.example_audio_file(), duration=10.0, offset=30)[0]\ndevice = 'cpu'\nfilter_length = 1024\nhop_length = 256\nwin_length = 1024 # doesn't need to be specified. if not specified, it's the same as filter_length\nwindow = 'hann'\n\naudio = torch.FloatTensor(audio)\naudio = audio.unsqueeze(0)\naudio = audio.to(device)\n\nstft = STFT(\n filter_length=filter_length, \n hop_length=hop_length, \n win_length=win_length,\n window=window\n).to(device)\n\nmagnitude, phase = stft.transform(audio)\noutput = stft.inverse(magnitude, phase)\noutput = output.cpu().data.numpy()[..., :]\naudio = audio.cpu().data.numpy()[..., :]\nprint(np.mean((output - audio) ** 2)) # on order of 1e-16\n```\n\nOutput of [`compare_stft.py`](compare_stft.py):\n\n![images/stft.png](images/stft.png)\n\n## Tests\nTest it by just cloning this repo and running\n\n```\npip install -r requirements.txt\npython -m pytest .\n```\n\nUnfortunately, since it's implemented with 1D Convolutions, some filter_length/hop_length \ncombinations can result in out of memory errors on your GPU when run on sufficiently large input.\n\n\n## Contributing\nPull requests welcome.\n\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/pseeth/torch-stft", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "torch-stft", "package_url": "https://pypi.org/project/torch-stft/", "platform": "", "project_url": "https://pypi.org/project/torch-stft/", "project_urls": { "Homepage": "https://github.com/pseeth/torch-stft" }, "release_url": "https://pypi.org/project/torch-stft/0.1.4/", "requires_dist": [ "numpy", "scipy", "librosa" ], "requires_python": "", "summary": "An STFT/iSTFT for PyTorch", "version": "0.1.4" }, "last_serial": 5347318, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "f078a2a392cf4570f580f1d17d1292f1", "sha256": "4c2634e07106d68a265baa22617e98cdefa1f76cb1829985fb0abad1a01703f0" }, "downloads": -1, "filename": "torch_stft-0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "f078a2a392cf4570f580f1d17d1292f1", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5819, "upload_time": "2019-06-01T08:33:11", "url": "https://files.pythonhosted.org/packages/d1/54/7441e451417c37fe36144e498a10d003051591f4ada4df3f64a055af9e4a/torch_stft-0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e268b81f1408a247bac4abb62af611ee", "sha256": "fff33d3a2bacc379e445e54fbd91423cc460f0d41c502b5f901bbda1db8d6f9a" }, "downloads": -1, "filename": "torch_stft-0.1.tar.gz", "has_sig": false, "md5_digest": "e268b81f1408a247bac4abb62af611ee", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4283, "upload_time": "2019-06-01T08:33:13", "url": "https://files.pythonhosted.org/packages/5d/76/11084cc4bfe27d14eaa71ecf500b14f8b590710470fa780d605cfab8502d/torch_stft-0.1.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "a2648292a885987c3d23fb3bee99720a", "sha256": "fb9dbb330101f9ef899356eb6bdcfcb8a87bf084394215d08ef5f5f8475ea595" }, "downloads": -1, "filename": "torch_stft-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "a2648292a885987c3d23fb3bee99720a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5929, "upload_time": "2019-06-01T09:30:49", "url": "https://files.pythonhosted.org/packages/98/c2/07ebe01c55262721d57c2469de59580e8a3773b366f7f7d9d5cdf47c28a7/torch_stft-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "833e448435636ba55f160636258b13c5", "sha256": "af6a9d1588c9c8f0960e056e799076d73344c324f87df6f673aa8f0f5c880108" }, "downloads": -1, "filename": "torch_stft-0.1.1.tar.gz", "has_sig": false, "md5_digest": "833e448435636ba55f160636258b13c5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4400, "upload_time": "2019-06-01T09:30:51", "url": "https://files.pythonhosted.org/packages/11/8c/4ae6c8d29d0f028bdcede115325526d5a70bbc0d56ed24995cf4ffe62f00/torch_stft-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "053deb7c331e65899aa0ddbb4201a382", "sha256": "50fb567419656a118ef820a63d02498bc66d07487d86457c35902e4cde1aa1c2" }, "downloads": -1, "filename": "torch_stft-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "053deb7c331e65899aa0ddbb4201a382", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5848, "upload_time": "2019-06-01T19:33:27", "url": "https://files.pythonhosted.org/packages/e6/c3/d4ae45ef35c176faab2290f4a8b8a8559cad9c4906bb4ff8910303cbaa97/torch_stft-0.1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fa86b3e33b7bd85bd38ca4cfc11bf6b0", "sha256": "a5fbe596acecde5fc8e993834ae5fa7cd8e39a38be9111763607d230e06fdc9e" }, "downloads": -1, "filename": "torch_stft-0.1.2.tar.gz", "has_sig": false, "md5_digest": "fa86b3e33b7bd85bd38ca4cfc11bf6b0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4322, "upload_time": "2019-06-01T19:33:28", "url": "https://files.pythonhosted.org/packages/66/c0/fab3d40f2161ef38d7ad0f2439c1c6262735f0f6b3e088eab13eba2dbb20/torch_stft-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "14113043f91efe534d7c4dfcb80dd0f7", "sha256": "22e69e8fa88dad4e0f33356c41b41016615c82efb6bedede4a19b9f7a24e0519" }, "downloads": -1, "filename": "torch_stft-0.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "14113043f91efe534d7c4dfcb80dd0f7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6245, "upload_time": "2019-06-01T20:53:05", "url": "https://files.pythonhosted.org/packages/89/e4/28ba9db521e278d570d5b3b58b5b73332b4410afb7e1ea951ae5a2965c53/torch_stft-0.1.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0f67a18c618aa029730c6ed6cd7834b1", "sha256": "2619ee97d0b8c1adf79c95f2e6bb1714b6390daae018fe85a9872f1ada92cc98" }, "downloads": -1, "filename": "torch_stft-0.1.3.tar.gz", "has_sig": false, "md5_digest": "0f67a18c618aa029730c6ed6cd7834b1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4806, "upload_time": "2019-06-01T20:53:06", "url": "https://files.pythonhosted.org/packages/e7/f7/8add3fd34d364a72ad38a5f1f5e74684262a91f6a21bd1d97a56471d99c8/torch_stft-0.1.3.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "4e57cdc6fd8208803481495f52a54b32", "sha256": "8096b0d74204b9c79439486de8b0c15f465b6dab58653b015691a2c3fef76990" }, "downloads": -1, "filename": "torch_stft-0.1.4-py3-none-any.whl", "has_sig": false, "md5_digest": "4e57cdc6fd8208803481495f52a54b32", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6231, "upload_time": "2019-06-01T20:58:09", "url": "https://files.pythonhosted.org/packages/9a/53/8a0114930b53459bdc6b090515636bbba7e080905284fb83c995a29eb709/torch_stft-0.1.4-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ddd4600243c92ef8c95c92facd636a08", "sha256": "1d7d1000da567def58de03525824fce0e40702f18555aff1b64d629bd6517217" }, "downloads": -1, "filename": "torch_stft-0.1.4.tar.gz", "has_sig": false, "md5_digest": "ddd4600243c92ef8c95c92facd636a08", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4785, "upload_time": "2019-06-01T20:58:11", "url": "https://files.pythonhosted.org/packages/c3/bd/ea6bc20ccaf1008c62c3b235eeb76649190e155ad43c0a06ed6bda2afd5f/torch_stft-0.1.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "4e57cdc6fd8208803481495f52a54b32", "sha256": "8096b0d74204b9c79439486de8b0c15f465b6dab58653b015691a2c3fef76990" }, "downloads": -1, "filename": "torch_stft-0.1.4-py3-none-any.whl", "has_sig": false, "md5_digest": "4e57cdc6fd8208803481495f52a54b32", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6231, "upload_time": "2019-06-01T20:58:09", "url": "https://files.pythonhosted.org/packages/9a/53/8a0114930b53459bdc6b090515636bbba7e080905284fb83c995a29eb709/torch_stft-0.1.4-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ddd4600243c92ef8c95c92facd636a08", "sha256": "1d7d1000da567def58de03525824fce0e40702f18555aff1b64d629bd6517217" }, "downloads": -1, "filename": "torch_stft-0.1.4.tar.gz", "has_sig": false, "md5_digest": "ddd4600243c92ef8c95c92facd636a08", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4785, "upload_time": "2019-06-01T20:58:11", "url": "https://files.pythonhosted.org/packages/c3/bd/ea6bc20ccaf1008c62c3b235eeb76649190e155ad43c0a06ed6bda2afd5f/torch_stft-0.1.4.tar.gz" } ] }