# HackyHour Würzburg 40

## Topic Suggestions

Add your :+1: to the end of a line you are interested in

## Participants

• Markus :pizza:
• Matthias :sushi: :pizza:
• Rick (probably late, ~ 6pm) :pizza:

## Code

import numpy as np
from scipy.io import wavfile
from pydub import AudioSegment
from pydub.playback import play

begin = np.array([np.abs(wav[i*800:(i+1)*800]).sum() for i in range(60)])

# https://stackoverflow.com/a/24892274/4969760
def zero_runs(a, min_len=3):
# Create an array that is 1 where a is 0, and pad each end with an extra 0.
iszero = np.concatenate((, np.equal(a, 0).view(np.int8), ))
absdiff = np.abs(np.diff(iszero))
# Runs start and end where absdiff is 1.
ranges = np.where(absdiff == 1).reshape(-1,2)
# Filter stretches smaller than min_len
ranges = np.array(list(filter(lambda x: x-x>=min_len, ranges)))
return ranges

np.split(wav[:160000], zero_runs(wav[:16000],min_len=100).flatten()

def play_fragment(data):
audio_segment = AudioSegment(data.tobytes(),frame_rate=wav,sample_width=wav.dtype.itemsize,channels=1)
play(audio_segment)

play_fragment(wav[:160000])

first10 = list(filter(lambda x: np.abs(x).sum()>0, np.split(wav[:160000], zero_runs(wav[:160000],min_len=100).flatten())))

first1000 = list(filter(lambda x: np.abs(x).sum()>0, np.split(wav[:16000000], zero_runs(wav[:16000000],min_len=100).flatten())))

# out of memory
# allWords = list(filter(lambda x: np.abs(x).sum()>0, np.split(wav, zero_runs(wav,min_len=100).flatten())))

# find chimera
longest = np.argmax([x.shape for x in first1000])
play_fragment(first1000[longest])

# check shortest
shortest = np.argmax([x.shape for x in first1000])
play_fragment(first1000[shortest])

# save for inspection in audacity
wavfile.write("chimera.wav",wav,first1000[longest])