|
1 |
| -# Sound Recognition with Python |
| 1 | +# Process sounds easy on python :headphones: |
2 | 2 |
|
3 | 3 | ## First Of All
|
4 |
| -Clone or Download project and ... |
| 4 | +Clone or Download project and import "sound.py" to your code: |
5 | 5 | ```python
|
6 |
| -import Sound |
| 6 | +import sound |
7 | 7 | ```
|
8 |
| -## Sound simulation |
9 |
| -* Initialize a Sound module with |
| 8 | +## Create a Noise |
| 9 | +* import Noise class from sound.py and initial it with a Wav file or byte array of a sound: |
10 | 10 | ```python
|
11 |
| -s = Sound.Sound(path='path.wav') |
12 |
| -``` |
13 |
| -or |
14 |
| -```python |
15 |
| -s = Sound.Sound(path='path.wav',name='mySound') |
16 |
| -``` |
| 11 | +Import Noise from sound |
| 12 | +noise1 = Noise(path='./M1.wav', name='Mic 1') |
17 | 13 |
|
18 |
| -* Initialize FFT(Fast Fourier transform) on our Sound module |
19 |
| -```python |
20 |
| -s.initFFT() |
21 |
| -print(s.getFFT()) |
22 |
| -s.drawFFT() |
23 |
| -``` |
24 |
| -* Sound schematics |
25 |
| -```python |
26 |
| -s.draw() #Sound Digital Schematic |
27 |
| -s.drawFFT() #Sound FFT Schematic |
| 14 | +# plot your noise |
| 15 | +noise1.draw() |
28 | 16 | ```
|
| 17 | +Method | Usage |
| 18 | +------- | ------- |
| 19 | +parse_wav() | parse wav file to byte array |
| 20 | +init_fft() | initials fft of noise |
| 21 | +get_fft() | returns fft of noise |
| 22 | +get_energy() | returns energy (power) of noise |
| 23 | +get_duration() | returns duration of noise in seconds |
| 24 | +get_slice() | returns slice of noise like 2 seconds of noise |
| 25 | +get_max() | returns upper bound of amplitude |
| 26 | +when_max() | returns when upper bound happends in seconds |
| 27 | +shift_right() | shifts noise signal to right in time domain |
| 28 | +shift_left() | shifts noise signal to left in time domain |
| 29 | +reverse() | reverses noise |
| 30 | +convolve(other) | convolve the noise to another or use '*' operator like 'n1 * n2' |
| 31 | +draw() | plot the noise in time domain |
| 32 | +draw_fft() | plot the noise fft in frequency domain |
| 33 | +draw_all() | plot the noise and fft both |
| 34 | +draw_phase() | plot phase of voise in frequency domain |
| 35 | +hear_noise() | returns IPython.display.audio object to hear noise in Jupyter Notebook |
| 36 | + |
29 | 37 |
|
| 38 | +* Requirments |
| 39 | + * matplotlib==3.3.0 |
| 40 | + * numpy==1.19.1 |
| 41 | + * scipy==1.5.1 |
| 42 | + * ipython==7.16.1 |
| 43 | + * For better experince install "Jupyter Notebook" |
| 44 | + |
0 commit comments