tflibrosa


Nametflibrosa JSON
Version 0.0.2 PyPI version JSON
download
home_pagehttps://github.com/Shiro-LK/tflibrosa
SummaryRe-implementation of some librosa function for tensorflow. Reproduction from torchlibrosa.
upload_time2023-08-26 13:45:35
maintainer
docs_urlNone
authorShiro-LK
requires_python
licenseMIT License
keywords tflibrosa tensorflow librosa
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # tflibrosa
re-implementation of torch librosa for tensorflow. It is usefull if you want to compute Spectrogram on GPU for faster inference instead of using librosa.

# Installation 

> pip install tflibrosa

# Example

To do some inference on single sample, you can use python script in examples/ folder or use as follows:

```
import numpy as np 
from tflibrosa import STFT, Spectrogram, LogmelFilterBank
import librosa
import tensorflow as tf 
audio = np.random.uniform(0,1 ,(32000 * 5))
print(audio.shape)

sample_rate = 32000
n_fft = 2048
hop_size = 512
window = 'hann'
pad_mode = 'reflect'
mel_bins = 64
ref = 1.0
amin = 1e-10
fmin = 20
fmax = 16000 
top_db = 80.0
center = True 
dtype=None

spectrogram_extractor = Spectrogram(n_fft=n_fft, hop_length=hop_size, 
                win_length=n_fft, window=window, center=center, pad_mode=pad_mode, 
                freeze_parameters=True, dtype="float32")

# Logmel feature extractor
logmel_extractor = LogmelFilterBank(sr=sample_rate, n_fft=n_fft, is_log=True, 
    n_mels=mel_bins, fmin=fmin, fmax=fmax, ref=ref, amin=amin, top_db=top_db, 
    freeze_parameters=True, dtype="float32")


spectrogram = spectrogram_extractor(audio[None, :])

mel_spectrogram = logmel_extractor(spectrogram)

print(mel_spectrogram) # (batch size, num_channels, timestamps)
```


# Acknowledgement

- librosa : https://librosa.org/doc/latest/index.html
- torchlibrosa : https://github.com/qiuqiangkong/torchlibrosa 

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Shiro-LK/tflibrosa",
    "name": "tflibrosa",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "tflibrosa,tensorflow,librosa",
    "author": "Shiro-LK",
    "author_email": "shirosaki94@gmail.com",
    "download_url": "https://github.com/Shiro-LK/tflibrosa.git",
    "platform": null,
    "description": "# tflibrosa\nre-implementation of torch librosa for tensorflow. It is usefull if you want to compute Spectrogram on GPU for faster inference instead of using librosa.\n\n# Installation \n\n> pip install tflibrosa\n\n# Example\n\nTo do some inference on single sample, you can use python script in examples/ folder or use as follows:\n\n```\nimport numpy as np \nfrom tflibrosa import STFT, Spectrogram, LogmelFilterBank\nimport librosa\nimport tensorflow as tf \naudio = np.random.uniform(0,1 ,(32000 * 5))\nprint(audio.shape)\n\nsample_rate = 32000\nn_fft = 2048\nhop_size = 512\nwindow = 'hann'\npad_mode = 'reflect'\nmel_bins = 64\nref = 1.0\namin = 1e-10\nfmin = 20\nfmax = 16000 \ntop_db = 80.0\ncenter = True \ndtype=None\n\nspectrogram_extractor = Spectrogram(n_fft=n_fft, hop_length=hop_size, \n                win_length=n_fft, window=window, center=center, pad_mode=pad_mode, \n                freeze_parameters=True, dtype=\"float32\")\n\n# Logmel feature extractor\nlogmel_extractor = LogmelFilterBank(sr=sample_rate, n_fft=n_fft, is_log=True, \n    n_mels=mel_bins, fmin=fmin, fmax=fmax, ref=ref, amin=amin, top_db=top_db, \n    freeze_parameters=True, dtype=\"float32\")\n\n\nspectrogram = spectrogram_extractor(audio[None, :])\n\nmel_spectrogram = logmel_extractor(spectrogram)\n\nprint(mel_spectrogram) # (batch size, num_channels, timestamps)\n```\n\n\n# Acknowledgement\n\n- librosa : https://librosa.org/doc/latest/index.html\n- torchlibrosa : https://github.com/qiuqiangkong/torchlibrosa \n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "Re-implementation of some librosa function for tensorflow. Reproduction from torchlibrosa.",
    "version": "0.0.2",
    "project_urls": {
        "Download": "https://github.com/Shiro-LK/tflibrosa.git",
        "Homepage": "https://github.com/Shiro-LK/tflibrosa"
    },
    "split_keywords": [
        "tflibrosa",
        "tensorflow",
        "librosa"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f4e0a856218c836498b59d1f99c2fb0217cc49f45d5c850b5f4b27b636cbca96",
                "md5": "93d7f78e5d1c843a0151b46af2db82b2",
                "sha256": "f4739b19c3f3340e561e32a4b14e691fd8ef95fb01b7be98421672f64993cfe6"
            },
            "downloads": -1,
            "filename": "tflibrosa-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "93d7f78e5d1c843a0151b46af2db82b2",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 8172,
            "upload_time": "2023-08-26T13:45:35",
            "upload_time_iso_8601": "2023-08-26T13:45:35.521998Z",
            "url": "https://files.pythonhosted.org/packages/f4/e0/a856218c836498b59d1f99c2fb0217cc49f45d5c850b5f4b27b636cbca96/tflibrosa-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-26 13:45:35",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Shiro-LK",
    "github_project": "tflibrosa",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "tflibrosa"
}
        
Elapsed time: 0.27985s