KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have some audio data loaded in a numpy array and I wish to segment the data by finding silent parts, i.e. parts where the audio amplitude is below a certain threshold over a period in time. An extremely simple way to do this is something like this: values = ''.join(("1" if (abs(x) < SILENCE_THRESHOLD) else "0" for x in samples)) pattern = re.compile('1{%d,}'%int(MIN_SILENCE)) for match in pattern.finditer(values): # code goes here The code above finds parts where there are at least MIN_SILENCE consecutive elements smaller than SILENCE_THRESHOLD. Now, obviously, the above code is horribly inefficient and a terrible abuse of regular expressions. Is there some other method that is more efficient, but still results in equally simple and short code?
Tags (comma-separated)
Save Edits
Cancel