Created
October 9, 2019 19:52
-
-
Save davidrft/7fc1c38581dc7f0d3c3ad372de214485 to your computer and use it in GitHub Desktop.
Generator of windows from an audio file to short-time analysis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def windows(array, window_size, overlap=0): | |
""" Generator of windows from an audio file to short-time analysis | |
Keyword arguments: | |
array -- Array of audio samples | |
window_size -- Size of the window that will be generated | |
overlap -- Overlap of windows to be accounted for when generating new ones | |
""" | |
overlap_factor = (1 - overlap) | |
head, tail = 0, window_size | |
while head < len(array): | |
window = array[head:tail] | |
head += int(window_size * overlap_factor) | |
tail += int(window_size * overlap_factor) | |
yield window |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment