No project description provided
Project description
Audio-File Extraction
About
Use this tool to segment (i.e., clip or slice), copy, and extract short-duration recordings, from long-duration WAV or FLAC files. Segmenting audio files into smaller parts can make recordings compatible for certain analytical workflows and allow for easier manipulation and sharing. Segment and extracting recordings based on a list of recording start times (date times) and a desired duration. This allows for applications such as the extraction of stratified audio samples, among others.
Downloading the package from PyPI
pip install sound-extraction
After downloading the package from PyPI, you can use the following command to run the program:
sound-extraction -r "/path/to/original/audio/files" -o "/path/to/output/folder" -c "/path/to/csv/file" -s "site_name"
Users can follow the same arguments and commands mentioned below to run the program. Here
- If you want to run the program from the source files then follow the steps below:
Setup (Windows)
Download Audio-File Extraction Files: Sound-File Extraction
python -m venv venv
venv\Scripts\Activate
pip install -r requirements.txt
If creating virtual environment gives us an error then open the Powershell with administrator and run the following command:
Set-ExecutionPolicy Unrestricted
Setup (Linux)
Download Audio-File Extraction Files: Sound-File Extraction
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
Test Files Usage
Download Test Files: Test Files
python sound_extraction.py -r "/path/to/original/audio/files" -o "/path/to/output/folder" -c "/path/to/csv/file" -s "site_name"
Usage
-
Run sound_extraction.py to get the extracted audio files. You need to set the working directory where the downloaded files are located. Here is an example:
python sound_extraction.py -r "/path/to/original/audio/files" -o "/path/to/output/folder" -c "/path/to/csv/file" -s "site_name"
Arguments and commands used are required to get the extraction of audio files according to the sample times. After entering the argument users will be asked to enter the custom sub-directory nameto store the extracted audio files. If you don't want to enter the custom name then just press Enter and it will extract the audio files in the same output directory mentioned in the argument.
-
Run sound_extraction.py to get the sliced audio files which can handle around 192K sample rate. Here is an example:
python sound_extraction.py -r "/path/to/original/audio/files" -o "/path/to/output/folder" -slice 10
Arguments and commands used are required to get the slicing of larger audio files into smaller audio files of your choice.
Here's a complete list of all command line arguments:
-r, Path to original audio files (required). Need to make sure all the audio files are stored in a folder.
-o, Path to output folder (required). Program will create a folder for you with current time, name of site and extraction of duration to the specified path.
-c, Path to the CSV file with the following requirements: Header should include "sample file" and "categories" columns. The "sample file" column should be in the format 20220608_170343, and the "categories" column should contain categories such as "Nocturnal", etc.
-s, Prefix or the recording name, or ID, etc. This will be used to name the extracted audio files.
-d, Duration of the extracted audio file. Change the duration of the extracted audio files, if required. Default is 3 minutes.
-span, Span of the audio file. Extracted audio files will not span to 3 minutes if the original file is shorter.
-e, Extension of the audio file (.wav or .flac). If your original audio files are flac then you need to use ".wav". Default is flac.
-slice, Slice the audio file in smaller segments/chunks. Default is 10 seconds.
We can see the arguments list by using the following command:
python sound_extraction.py -h
-
This is very basic version of the analysis of the workflow, you can adjust it to your needs.
-
All the unusual files are handled and will show in console as a log message.
-
Please open an issue if you have any questions or suggestions to add any features.
-
I will keep on updating the code and making it more efficient.
Error Handling
-
Log file will be created in the output folder with the name of
sound_extraction_logs.txtwhich will show all the corrupted files which happened during the extraction process. -
This program will send the error message to the Sentry server to improve the user performace and to keep track of the errors which will be handled by myself.
Important Notes
-
Try to have your original audio files in subfolder of root directory and once you provide path of root folder then code will search for all the files in all subfolders as well as in root folder.
-
Original files should be in the format
20220611T202300.wavor20220611T202300.flac. Sample files in CSV should be in the format20220611_202300.wavor20220611_202300.flacunder the headingsampleFile. For instance,
Changelog
- All the version changes are mentioned in the CHANGELOG.md file.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sound-extraction-1.1.1.tar.gz.
File metadata
- Download URL: sound-extraction-1.1.1.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c7cddc2551ea115a6fe9dc40f824ba307942385598cde922ed27cd00f4d4a98
|
|
| MD5 |
e6665bd0c52b8311b1f7e2aac8d42307
|
|
| BLAKE2b-256 |
30469d6c1bcb6ac503c59bae0d308faf02b84b5f972bf00de6911994d93f3e4d
|
File details
Details for the file sound_extraction-1.1.1-py3-none-any.whl.
File metadata
- Download URL: sound_extraction-1.1.1-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e195319f6f4d9f0dd4824940ff386b73542825d1a87be72ac534c5f6f03a65c
|
|
| MD5 |
6e820bae538f4db82f5231bd9b0d49bf
|
|
| BLAKE2b-256 |
7e09641a13c2486cc81a67da834d62bc6465fd0acbe6dde26ae7127ae1062158
|