# ProcessAudio
Libreria python para hacer data augmentation en audios y/o extraer caracteristicas a audios
---
# Installation
```bash
pip install ProcessAudio
```
---
# Description
A `ProcessAudio` object should be created and use its attributes.
This library have tree main functions:
* `Features`: Extract features from audio
* `AudioAugmentation`: Augment audio in different ways
* `AllDataAugmentation`: Augment audio in different ways and extract features
* `Util`: Read audio and denoise audio
* `Split`: Split audio in n seconds or at desired cut points
* `Graph`: Graph spectrogram or log_mel_spectrogram for an audio
---
[Back To Top ↥](#ProcessAudio)
## Features methods
* `set_data(data_audio:str="<path_audio_file>)`: Set data to extract features
* `get_croma()`: Extract croma features
* `get_mfcc()`: Extract mfcc features
* `get_rmse()`: Extract rmse features
* `get_centroide_espectral()`: Extract spectral centroid features
* `get_rolloff()`: Extract spectral rolloff features
* `get_cruce_por_cero()`: Extract zero crossing rate features
* `get_ancho_banda_espectral()`: Extract spectral bandwidth features
* `get_tonnetz()`: Extract tonnetz features
* `build_basic()`: Extract a basic features in a list
---
[Back To Top ↥](#ProcessAudio)
## AudioAugmentation methods
* `loudness()`: Apply loudness to audio file creating a new data
* `add_mask()`: Apply mask to audio file creating a new data
* `pitch()`: Apply pitch to audio file creating a new data
* `get_original()`: Get original audio file
* `add_crop()`: Apply crop to audio file creating a new data
* `add_noise()`: Apply noise to audio file creating a new data
* `add_noise2()`: Apply noise to audio file creating a new data
* `shift()`: Apply shift to audio file creating a new data
* `stretch()`: Apply stretch to audio file creating a new data
* `speed()`: Apply speed to audio file creating a new data
* `normalizer()`: Apply normalizer to audio file creating a new data
* `polarizer()`: Apply polarizer to audio file creating a new data
* `write_audio_file()`: Write audio file
* `plot_time_series()`: Plot time series
---
[Back To Top ↥](#ProcessAudio)
## AllDataAugmentation methods
* `build_all(extract_features: bool)`: Augment audio and extract features if extract_features is True
---
[Back To Top ↥](#ProcessAudio)
## Util methods
* `read_audio(file_path: str, force_convert_wav: bool)`: Read Read audio, if the format isn't wav, the method convert that before to read
* `audio_convert_wav(audio_path: str, output_path: str)`: Convert audio to wav format
* `denoise_audio(data: np.array, sr: int)`: remove the noise of audio data
---
[Back To Top ↥](#ProcessAudio)
## Split methods
* `split(self, start: int, end: int, save: bool)`: Split audio in start to end, if you need seconds, start and end have to multiples of 1000
* `split_by_seconds(self, seconds: int, save: bool)`: Cut audio en segments of <seconds> parameter and save each one
---
[Back To Top ↥](#ProcessAudio)
## Graph methods
* `spectrogram(data: np.array, sr: int, output_path: str, title: str)`: Create the spectrogram for audio data
* `log_mel_spectrogram(data: np.array, sr: int, output_path: str, title: str)`: Create log mel spectrogram for audio data
---
[Back To Top ↥](#ProcessAudio)
# Usage
## Example Features
```python
import os
from ProcessAudio.Features import Features
filepath = os.path.dirname(os.path.abspath(__file__)) + os.sep
path_file = filepath + "demo" + os.sep + "dat_92.wav"
features = Features()
features.set_data(path_file)
DATA = features.build_basic() # Extract all features
print(DATA)
print(len(DATA))
```
---
[Back To Top ↥](#ProcessAudio)
## Example AudioAugmentation
```python
import os
from ProcessAudio.AudioAugmentation import AudioAugmentation
filepath = os.path.dirname(os.path.abspath(__file__)) + os.sep
path_file = filepath + "demo" + os.sep + "dat_92.wav"
folder_save = filepath + "new_audios" + os.sep
aumentation = AudioAugmentation(audio_file=path_file, save=folder_save)
audio_con_ruido = aumentation.add_noise(factor_ruido=0.05)
audio_normalizer = aumentation.normalizer()
audio_loudness = aumentation.loudness()
```
---
[Back To Top ↥](#ProcessAudio)
## Example AllDataAugmentation
```python
import os
from ProcessAudio.AllDataAugmentation import AllDataAugmentation
filepath = os.path.dirname(os.path.abspath(__file__)) + os.sep
path_file = filepath + "demo" + os.sep + "dat_92.wav"
folder_save = filepath + "new_audios" + os.sep
aumentation = AllDataAugmentation(path_file, path_save=folder_save, label=["cero", "uno"])
data, label = aumentation.build_all(extract_features=True)
print(len(data), len(label))
print(len(data[0]), label[0])
```
---
[Back To Top ↥](#ProcessAudio)
# Citing
If you want to cite ProcessAudio in an academic paper, there are two ways to do it.
- APA:
WISROVI, W.S.R.V. (2022). Python library to augment audio data and/or extract audio features (Version 0.22.11) [Computer Software]. https://github.com/wisrovi/ProcessAudio
- BibTex:
@software{WISROVI_Instrument_Classifier_2022,
author = {WISROVI, William Steve Rodríguez Villamizar},
month = {10},
title = {{Python library to augment audio data and/or extract audio features}},
URL = {https://github.com/wisrovi/ProcessAudio},
version = {0.22.11},
year = {2022}
}
---
[Back To Top ↥](#ProcessAudio)
# License
GPLv3 License
---
[Back To Top ↥](#ProcessAudio)
# Support:
<p>
<a href="https://www.buymeacoffee.com/wisrovirod8">
<img style="align='left';" src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" height="50" width="210" alt="wisrovirod8" />
</a>
</p>
Raw data
{
"_id": null,
"home_page": "https://github.com/wisrovi/ProcessAudio",
"name": "ProcessAudio",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "encoding, i18n, xml",
"author": "William Rodriguez",
"author_email": "wisrovi.rodriguez@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/32/7c/d7bc693c3445c34b5b48a6f4ae4792eb6a972b9846a8ebfc674402ca2ed9/ProcessAudio-0.24.5.tar.gz",
"platform": null,
"description": "# ProcessAudio\n Libreria python para hacer data augmentation en audios y/o extraer caracteristicas a audios\n\n---\n\n# Installation\n\n```bash\npip install ProcessAudio\n```\n---\n\n# Description\n\nA `ProcessAudio` object should be created and use its attributes.\n\nThis library have tree main functions:\n\n* `Features`: Extract features from audio\n* `AudioAugmentation`: Augment audio in different ways\n* `AllDataAugmentation`: Augment audio in different ways and extract features\n* `Util`: Read audio and denoise audio\n* `Split`: Split audio in n seconds or at desired cut points\n* `Graph`: Graph spectrogram or log_mel_spectrogram for an audio \n---\n\n[Back To Top \u21a5](#ProcessAudio)\n\n## Features methods\n\n* `set_data(data_audio:str=\"<path_audio_file>)`: Set data to extract features\n* `get_croma()`: Extract croma features\n* `get_mfcc()`: Extract mfcc features\n* `get_rmse()`: Extract rmse features\n* `get_centroide_espectral()`: Extract spectral centroid features\n* `get_rolloff()`: Extract spectral rolloff features\n* `get_cruce_por_cero()`: Extract zero crossing rate features\n* `get_ancho_banda_espectral()`: Extract spectral bandwidth features\n* `get_tonnetz()`: Extract tonnetz features\n* `build_basic()`: Extract a basic features in a list\n---\n\n[Back To Top \u21a5](#ProcessAudio)\n\n## AudioAugmentation methods\n\n* `loudness()`: Apply loudness to audio file creating a new data\n* `add_mask()`: Apply mask to audio file creating a new data\n* `pitch()`: Apply pitch to audio file creating a new data\n* `get_original()`: Get original audio file\n* `add_crop()`: Apply crop to audio file creating a new data\n* `add_noise()`: Apply noise to audio file creating a new data\n* `add_noise2()`: Apply noise to audio file creating a new data\n* `shift()`: Apply shift to audio file creating a new data\n* `stretch()`: Apply stretch to audio file creating a new data\n* `speed()`: Apply speed to audio file creating a new data\n* `normalizer()`: Apply normalizer to audio file creating a new data\n* `polarizer()`: Apply polarizer to audio file creating a new data\n* `write_audio_file()`: Write audio file\n* `plot_time_series()`: Plot time series\n---\n\n[Back To Top \u21a5](#ProcessAudio)\n\n## AllDataAugmentation methods\n\n* `build_all(extract_features: bool)`: Augment audio and extract features if extract_features is True\n\n---\n\n[Back To Top \u21a5](#ProcessAudio)\n\n## Util methods\n\n* `read_audio(file_path: str, force_convert_wav: bool)`: Read Read audio, if the format isn't wav, the method convert that before to read\n* `audio_convert_wav(audio_path: str, output_path: str)`: Convert audio to wav format\n* `denoise_audio(data: np.array, sr: int)`: remove the noise of audio data\n\n---\n\n[Back To Top \u21a5](#ProcessAudio)\n\n## Split methods\n\n* `split(self, start: int, end: int, save: bool)`: Split audio in start to end, if you need seconds, start and end have to multiples of 1000\n* `split_by_seconds(self, seconds: int, save: bool)`: Cut audio en segments of <seconds> parameter and save each one\n\n---\n\n[Back To Top \u21a5](#ProcessAudio)\n\n## Graph methods\n\n* `spectrogram(data: np.array, sr: int, output_path: str, title: str)`: Create the spectrogram for audio data\n* `log_mel_spectrogram(data: np.array, sr: int, output_path: str, title: str)`: Create log mel spectrogram for audio data\n\n---\n\n[Back To Top \u21a5](#ProcessAudio)\n\n\n\n\n\n\n\n\n\n\n\n\n# Usage\n\n## Example Features\n```python\nimport os\nfrom ProcessAudio.Features import Features\n\nfilepath = os.path.dirname(os.path.abspath(__file__)) + os.sep\npath_file = filepath + \"demo\" + os.sep + \"dat_92.wav\"\n\nfeatures = Features()\nfeatures.set_data(path_file)\nDATA = features.build_basic() # Extract all features\nprint(DATA)\nprint(len(DATA)) \n```\n---\n\n[Back To Top \u21a5](#ProcessAudio)\n\n## Example AudioAugmentation\n```python\nimport os\nfrom ProcessAudio.AudioAugmentation import AudioAugmentation\n\nfilepath = os.path.dirname(os.path.abspath(__file__)) + os.sep\npath_file = filepath + \"demo\" + os.sep + \"dat_92.wav\"\nfolder_save = filepath + \"new_audios\" + os.sep\n\naumentation = AudioAugmentation(audio_file=path_file, save=folder_save)\naudio_con_ruido = aumentation.add_noise(factor_ruido=0.05)\naudio_normalizer = aumentation.normalizer()\naudio_loudness = aumentation.loudness()\n```\n---\n\n[Back To Top \u21a5](#ProcessAudio)\n\n## Example AllDataAugmentation\n```python\nimport os\nfrom ProcessAudio.AllDataAugmentation import AllDataAugmentation\n\nfilepath = os.path.dirname(os.path.abspath(__file__)) + os.sep\npath_file = filepath + \"demo\" + os.sep + \"dat_92.wav\"\nfolder_save = filepath + \"new_audios\" + os.sep\n\naumentation = AllDataAugmentation(path_file, path_save=folder_save, label=[\"cero\", \"uno\"])\ndata, label = aumentation.build_all(extract_features=True)\nprint(len(data), len(label))\nprint(len(data[0]), label[0])\n```\n---\n\n[Back To Top \u21a5](#ProcessAudio)\n\n# Citing\n\n\nIf you want to cite ProcessAudio in an academic paper, there are two ways to do it.\n\n- APA:\n\n WISROVI, W.S.R.V. (2022). Python library to augment audio data and/or extract audio features (Version 0.22.11) [Computer Software]. https://github.com/wisrovi/ProcessAudio\n\n- BibTex:\n\n @software{WISROVI_Instrument_Classifier_2022,\nauthor = {WISROVI, William Steve Rodr\u00edguez Villamizar},\nmonth = {10},\ntitle = {{Python library to augment audio data and/or extract audio features}},\nURL = {https://github.com/wisrovi/ProcessAudio},\nversion = {0.22.11},\nyear = {2022}\n}\n\n\n---\n\n[Back To Top \u21a5](#ProcessAudio)\n\n# License\n\nGPLv3 License\n\n---\n\n[Back To Top \u21a5](#ProcessAudio)\n\n# Support:\n<p>\n <a href=\"https://www.buymeacoffee.com/wisrovirod8\"> \n <img style=\"align='left';\" src=\"https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png\" height=\"50\" width=\"210\" alt=\"wisrovirod8\" />\n </a> \n</p>\n\n",
"bugtrack_url": null,
"license": "GPLv3",
"summary": "Audio processing",
"version": "0.24.5",
"project_urls": {
"Download": "https://github.com/wisrovi/ProcessAudio/releases/tag/V0.24.03",
"Homepage": "https://github.com/wisrovi/ProcessAudio"
},
"split_keywords": [
"encoding",
" i18n",
" xml"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "327cd7bc693c3445c34b5b48a6f4ae4792eb6a972b9846a8ebfc674402ca2ed9",
"md5": "0e37ccd9cbd7e16de341e50d8f156304",
"sha256": "f8e6c2861bc267dd94185b54dd796cb9b6ebd89a85659a62e7b6552f37f84476"
},
"downloads": -1,
"filename": "ProcessAudio-0.24.5.tar.gz",
"has_sig": false,
"md5_digest": "0e37ccd9cbd7e16de341e50d8f156304",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 21396,
"upload_time": "2024-03-30T22:26:15",
"upload_time_iso_8601": "2024-03-30T22:26:15.226084Z",
"url": "https://files.pythonhosted.org/packages/32/7c/d7bc693c3445c34b5b48a6f4ae4792eb6a972b9846a8ebfc674402ca2ed9/ProcessAudio-0.24.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-30 22:26:15",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "wisrovi",
"github_project": "ProcessAudio",
"github_not_found": true,
"lcname": "processaudio"
}