CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
y33-j3T

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: y33-j3T/Coursera-Deep-Learning
Path: blob/master/Sequence Models/Week 3/Trigger word detection/__pycache__/td_utils.cpython-36.pyc
Views: 13381
3

(oZ��@sNddljZddlmZddlZddlmZdd�Zdd�Z	dd	�Z
d
d�ZdS)�N)�wavfile)�AudioSegmentcCstt|�\}}d}d}d}|j}|dkrBtj||||d�\}}}	}
n.|dkrptj|dd�df|||d�\}}}	}
|S)N��i@�x�)�noverlap�r)�get_wav_info�ndim�pltZspecgram)�wav_file�rate�dataZnfft�fsr�	nchannelsZpxxZfreqs�binsZim�r�;/home/jovyan/work/Week 3/Trigger word detection/td_utils.py�graph_spectrograms&rcCstj|�\}}||fS)N)r�read)rr
rrrrr	sr	cCs||j}|j|�S)N)�dBFS�
apply_gain)ZsoundZtarget_dBFSZchange_in_dBFSrrr�match_target_amplitudes
rcCs�g}g}g}x4tjd�D]&}|jd�rtjd|�}|j|�qWx4tjd�D]&}|jd�rNtjd|�}|j|�qNWx4tjd�D]&}|jd�r�tjd|�}|j|�q�W|||fS)Nz./raw_data/activates�wavz./raw_data/activates/z./raw_data/backgroundsz./raw_data/backgrounds/z./raw_data/negativesz./raw_data/negatives/)�os�listdir�endswithr�from_wav�append)Z	activatesZbackgroundsZ	negatives�filename�activateZ
background�negativerrr�load_raw_audios 


r")�matplotlib.pyplot�pyplotrZscipy.iorr�pydubrrr	rr"rrrr�<module>s