hum 0.1.30__tar.gz → 0.1.32__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hum-0.1.32/PKG-INFO +570 -0
- {hum-0.1.30 → hum-0.1.32}/README.md +27 -27
- {hum-0.1.30 → hum-0.1.32}/hum/__init__.py +1 -0
- {hum-0.1.30 → hum-0.1.32}/hum/examples/annotated_sounds.py +7 -7
- {hum-0.1.30 → hum-0.1.32}/hum/examples/tagged_intervals.py +46 -40
- {hum-0.1.30 → hum-0.1.32}/hum/gen/__init__.py +1 -0
- {hum-0.1.30 → hum-0.1.32}/hum/gen/diagnosis_sounds.py +31 -24
- {hum-0.1.30 → hum-0.1.32}/hum/gen/signal_generators.py +17 -11
- {hum-0.1.30 → hum-0.1.32}/hum/gen/sine_mix.py +12 -7
- {hum-0.1.30 → hum-0.1.32}/hum/gen/voiced_time.py +16 -15
- {hum-0.1.30 → hum-0.1.32}/hum/lite_sample_sounds.py +48 -32
- {hum-0.1.30 → hum-0.1.32}/hum/sound/__init__.py +1 -0
- {hum-0.1.30 → hum-0.1.32}/hum/sound/audio.py +25 -24
- {hum-0.1.30 → hum-0.1.32}/hum/sound/audio_librosa.py +23 -21
- {hum-0.1.30 → hum-0.1.32}/hum/util.py +5 -4
- {hum-0.1.30 → hum-0.1.32}/hum/utils/__init__.py +1 -0
- {hum-0.1.30 → hum-0.1.32}/hum/utils/date_ticks.py +22 -20
- {hum-0.1.30 → hum-0.1.32}/hum/utils/infinite_waveform.py +1 -0
- {hum-0.1.30 → hum-0.1.32}/hum/utils/librosa_utils.py +183 -182
- {hum-0.1.30 → hum-0.1.32}/hum/utils/plotting.py +4 -3
- hum-0.1.32/hum.egg-info/PKG-INFO +570 -0
- {hum-0.1.30 → hum-0.1.32}/setup.cfg +3 -4
- {hum-0.1.30 → hum-0.1.32}/setup.py +3 -3
- hum-0.1.30/PKG-INFO +0 -570
- hum-0.1.30/hum.egg-info/PKG-INFO +0 -570
- {hum-0.1.30 → hum-0.1.32}/LICENSE +0 -0
- {hum-0.1.30 → hum-0.1.32}/hum/examples/__init__.py +0 -0
- {hum-0.1.30 → hum-0.1.32}/hum/gen/simple.py +0 -0
- {hum-0.1.30 → hum-0.1.32}/hum/gen/util.py +0 -0
- {hum-0.1.30 → hum-0.1.32}/hum/scrap/__init__.py +0 -0
- {hum-0.1.30 → hum-0.1.32}/hum.egg-info/SOURCES.txt +0 -0
- {hum-0.1.30 → hum-0.1.32}/hum.egg-info/dependency_links.txt +0 -0
- {hum-0.1.30 → hum-0.1.32}/hum.egg-info/not-zip-safe +0 -0
- {hum-0.1.30 → hum-0.1.32}/hum.egg-info/requires.txt +0 -0
- {hum-0.1.30 → hum-0.1.32}/hum.egg-info/top_level.txt +0 -0
hum-0.1.32/PKG-INFO
ADDED
|
@@ -0,0 +1,570 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: hum
|
|
3
|
+
Version: 0.1.32
|
|
4
|
+
Summary: Generate synthetic signals for ML pipelines
|
|
5
|
+
Home-page: https://github.com/thorwhalen/hum
|
|
6
|
+
License: mit
|
|
7
|
+
Keywords: data,signal processing,audio
|
|
8
|
+
Platform: any
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
# hum
|
|
14
|
+
Generate synthetic signals for ML pipelines
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
To install: ```pip install hum```
|
|
18
|
+
|
|
19
|
+
# functionality
|
|
20
|
+
This notebook gathers various examples of the functionality of `hum`:
|
|
21
|
+
- Synthetic datasets
|
|
22
|
+
- sound-like datasets
|
|
23
|
+
- diagnosis datasets
|
|
24
|
+
- signal generation
|
|
25
|
+
- Plotting and visualization
|
|
26
|
+
- plot
|
|
27
|
+
- display
|
|
28
|
+
- melspectrograms
|
|
29
|
+
- Infinite waveform from spectrums
|
|
30
|
+
- Various sample sounds
|
|
31
|
+
- Voiced time
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
from hum import (mk_sine_wf,
|
|
36
|
+
freq_based_stationary_wf,
|
|
37
|
+
BinarySound,
|
|
38
|
+
WfGen,
|
|
39
|
+
TimeSound,
|
|
40
|
+
mk_some_buzz_wf,
|
|
41
|
+
wf_with_timed_bleeps,
|
|
42
|
+
Sound,
|
|
43
|
+
plot_wf,
|
|
44
|
+
disp_wf,
|
|
45
|
+
InfiniteWaveform,
|
|
46
|
+
Voicer,
|
|
47
|
+
tell_time_continuously,
|
|
48
|
+
random_samples,
|
|
49
|
+
pure_tone,
|
|
50
|
+
triangular_tone,
|
|
51
|
+
square_tone,
|
|
52
|
+
AnnotatedWaveform,
|
|
53
|
+
gen_words,
|
|
54
|
+
categorical_gen,
|
|
55
|
+
bernoulli_gen,
|
|
56
|
+
create_session,
|
|
57
|
+
session_to_df
|
|
58
|
+
)
|
|
59
|
+
import matplotlib.pyplot as plt
|
|
60
|
+
from numpy.random import randint
|
|
61
|
+
import numpy as np
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Synthetic datasets
|
|
65
|
+
There are several different forms of synthetic data that `hum` can produce to be used in machine learning pipelines, with the first being sound-like datasets generally in the form of sine waves
|
|
66
|
+
|
|
67
|
+
### Sound-like datasets
|
|
68
|
+
|
|
69
|
+
`mk_sine_wf` provides an easy way to generate a simple waveform for synthetic testing purposes
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
DFLT_N_SAMPLES = 21 * 2048
|
|
74
|
+
DFLT_SR = 44100
|
|
75
|
+
wf = mk_sine_wf(freq=5, n_samples=DFLT_N_SAMPLES, sr=DFLT_SR, phase=0, gain=1)
|
|
76
|
+
plt.plot(wf);
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+

|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
wf = mk_sine_wf(freq=20, n_samples=DFLT_N_SAMPLES, sr=DFLT_SR, phase = 0.25, gain = 3)
|
|
88
|
+
plt.plot(wf);
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+

|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
`freq_based_stationary_wf` provides the ability to generate a more complex waveform by mixing sine waves of different frequencies with potentially different weights
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
wf_mix = freq_based_stationary_wf(freqs=(2, 4, 6, 8), weights=None,
|
|
102
|
+
n_samples = DFLT_N_SAMPLES, sr = DFLT_SR)
|
|
103
|
+
plt.plot(wf_mix);
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+

|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
```python
|
|
114
|
+
wf_mix = freq_based_stationary_wf(freqs=(2, 4, 6, 8), weights=(3,3,1,1),
|
|
115
|
+
n_samples = DFLT_N_SAMPLES, sr = DFLT_SR)
|
|
116
|
+
plt.plot(wf_mix);
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+

|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
`WfGen` is a class that allows for the generation of sinusoidal waveforms, the generation of lookup tables to be used in generating waveforms, and frequency weighted mixed waveforms
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
wfgen = WfGen(sr=44100, buf_size_frm=2048, amplitude=0.5)
|
|
130
|
+
lookup = np.array(wfgen.mk_lookup_table(freq=880))
|
|
131
|
+
wf = wfgen.mk_sine_wf(n_frm=100, freq=880)
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
np.array(lookup).T
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
array([ 0. , 0.06252526, 0.12406892, 0.1836648 , 0.24037727,
|
|
143
|
+
0.293316 , 0.34164989, 0.38462013, 0.42155213, 0.45186607,
|
|
144
|
+
0.47508605, 0.49084754, 0.49890309, 0.49912624, 0.49151348,
|
|
145
|
+
0.47618432, 0.45337943, 0.42345682, 0.38688626, 0.34424188,
|
|
146
|
+
0.29619315, 0.24349441, 0.186973 , 0.12751624, 0.06605758,
|
|
147
|
+
0.00356187, -0.05898977, -0.12061531, -0.18034728, -0.23724793,
|
|
148
|
+
-0.29042397, -0.33904057, -0.38233448, -0.41962604, -0.45032977,
|
|
149
|
+
-0.47396367, -0.4901567 , -0.49865463, -0.49932406, -0.49215447,
|
|
150
|
+
-0.47725843, -0.45486979, -0.42534003, -0.38913276, -0.34681639,
|
|
151
|
+
-0.29905527, -0.2465992 , -0.19027171, -0.13095709, -0.06958655])
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
```python
|
|
157
|
+
plt.plot(wf);
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+

|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
```python
|
|
168
|
+
wf_weight = wfgen.mk_wf_from_freq_weight_array(n_frm=10000, freq_weight_array=(10,1,6))
|
|
169
|
+
plt.plot(wf_weight);
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+

|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
### Diagnosis datasets
|
|
179
|
+
`hum` can also produce diagnosis datasets to be applied to machine learning pipelines
|
|
180
|
+
|
|
181
|
+
`BinarySound` is a class that generates binary waveforms
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
```python
|
|
185
|
+
bs = BinarySound(nbits=50, redundancy=142, repetition=3, header_size_words=1)
|
|
186
|
+
utc = randint(0,2,50)
|
|
187
|
+
wf = bs.mk_phrase(utc)
|
|
188
|
+
plt.plot(wf[:200]);
|
|
189
|
+
all(bs.decode(wf) == utc)
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
True
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+

|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
`BinarySound` can also be instantiated using audio parameters using the `for_audio_params` class method
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
```python
|
|
209
|
+
bs = BinarySound.for_audio_params(nbits=50, freq=6000, chk_size_frm=43008, sr=44100, header_size_words=1)
|
|
210
|
+
wf = bs.mk_phrase(utc)
|
|
211
|
+
plt.plot(wf[:200]);
|
|
212
|
+
all(bs.decode(wf) == utc)
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
True
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+

|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
utc phrases can be generated using `mk_utc_phrases` when `BinarySound` is instantiated with audio parameters
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
```python
|
|
232
|
+
plt.plot(bs.mk_utc_phrases()[:200]);
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+

|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
`TimeSound` is a class that generates timestamped waveform data
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
```python
|
|
245
|
+
time = TimeSound(sr=44100, buf_size_frm=2048, amplitude=0.5, n_ums_bits=30)
|
|
246
|
+
wf = time.timestamped_wf()
|
|
247
|
+
plt.plot(wf[2000:2300]);
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+

|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
`mk_some_buzz_wf` and `wf_with_timed_bleeps` are two more options to generate synthetic data of diagnosis sounds
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
```python
|
|
260
|
+
wf = mk_some_buzz_wf(sr=DFLT_SR)
|
|
261
|
+
plt.plot(wf[:500]);
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+

|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
```python
|
|
272
|
+
wf = wf_with_timed_bleeps(n_samples=DFLT_SR*2, bleep_loc=400, bleep_spec=100, sr=DFLT_SR)
|
|
273
|
+
plt.plot(wf[:150]);
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+

|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
### Signal generation
|
|
283
|
+
|
|
284
|
+
`hum` can create signals generated by sequences of symbols, perturbed by outliers injected at given points
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
```python
|
|
288
|
+
symb_res = categorical_gen(gen_words)
|
|
289
|
+
out_res = bernoulli_gen(p_out=0.01)
|
|
290
|
+
df = session_to_df(create_session(symb_res, out_res, alphabet=list('abcde'), session_length=500))
|
|
291
|
+
df.plot(subplots=True, figsize=(20,7));
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+

|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
## Plotting and visualization
|
|
301
|
+
`hum` also provides several options for plotting and visualization for the synthetic datasets it generates
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
```python
|
|
305
|
+
wfgen = WfGen()
|
|
306
|
+
wf = list()
|
|
307
|
+
for i in range(1, 1000, 20):
|
|
308
|
+
wf.extend(list(wfgen.mk_sine_wf(n_frm=2048, freq=i)))
|
|
309
|
+
wf = np.array(wf)
|
|
310
|
+
sr = 44100
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
### Plot waveform
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
```python
|
|
317
|
+
plot_wf(wf[:20000], sr)
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+

|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
### Display waveform
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
```python
|
|
330
|
+
disp_wf(wf, sr)
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+

|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
### Melspectrograms with `Sound`
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
```python
|
|
343
|
+
snd = Sound(wf=wf, sr=sr)
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
```python
|
|
348
|
+
snd.plot_wf(wf=wf[:20000], sr=sr)
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+

|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
```python
|
|
359
|
+
snd.melspectrogram(plot_it=False)
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
array([[-63.34856485, -45.14910401, -36.14726097, ..., -80. ,
|
|
366
|
+
-73.35788085, -60.58728436],
|
|
367
|
+
[-67.99632241, -74.80503122, -80. , ..., -80. ,
|
|
368
|
+
-72.1600597 , -60.16803079],
|
|
369
|
+
[-80. , -80. , -80. , ..., -80. ,
|
|
370
|
+
-72.90050429, -60.90871386],
|
|
371
|
+
...,
|
|
372
|
+
[-80. , -80. , -80. , ..., -80. ,
|
|
373
|
+
-80. , -80. ],
|
|
374
|
+
[-80. , -80. , -80. , ..., -80. ,
|
|
375
|
+
-80. , -80. ],
|
|
376
|
+
[-80. , -80. , -80. , ..., -80. ,
|
|
377
|
+
-80. , -80. ]])
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
```python
|
|
383
|
+
snd.display()
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+

|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
## Infinite waveform from spectrum
|
|
393
|
+
`hum` also provides the functionality to create an infinite waveform based on a given spectrum, and a noise amplifier if desired
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
```python
|
|
397
|
+
iwf = InfiniteWaveform(wf)
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
```python
|
|
402
|
+
wf = list(iwf.query(0,500000))
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
```python
|
|
407
|
+
disp_wf(wf)
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+

|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
```python
|
|
418
|
+
Sound(wf=wf).display()
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+

|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
## Sample sounds
|
|
428
|
+
`hum` also provides several functions to generate sample sounds shown below
|
|
429
|
+
|
|
430
|
+
### Random sample
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
```python
|
|
434
|
+
wf = random_samples(chk_size_frm=21*2048, max_amplitude=30000)
|
|
435
|
+
disp_wf(wf=wf, sr=sr)
|
|
436
|
+
Sound(wf=wf).display()
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+

|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
|
|
447
|
+

|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+
### Pure tone sample
|
|
452
|
+
|
|
453
|
+
|
|
454
|
+
```python
|
|
455
|
+
wf = pure_tone(chk_size_frm=21*2048, freq=440, sr=44100, max_amplitude=30000)
|
|
456
|
+
disp_wf(wf=wf, sr=sr)
|
|
457
|
+
Sound(wf=wf).display()
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
/Users/owenlloyd/opt/anaconda3/envs/oto3/lib/python3.8/site-packages/matplotlib/axes/_axes.py:7723: RuntimeWarning: divide by zero encountered in log10
|
|
461
|
+
Z = 10. * np.log10(spec)
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+

|
|
467
|
+
|
|
468
|
+
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+

|
|
473
|
+
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
### Triangular tone sample
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
```python
|
|
480
|
+
wf = triangular_tone(chk_size_frm=21*2048, freq=440, sr=44100, max_amplitude=30000)
|
|
481
|
+
disp_wf(wf=wf, sr=sr)
|
|
482
|
+
Sound(wf=wf).display()
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+

|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+

|
|
494
|
+
|
|
495
|
+
|
|
496
|
+
|
|
497
|
+
### Square tone sample
|
|
498
|
+
|
|
499
|
+
|
|
500
|
+
```python
|
|
501
|
+
wf = square_tone(chk_size_frm=21*2048, freq=440, sr=44100, max_amplitude=30000)
|
|
502
|
+
disp_wf(wf=wf, sr=sr)
|
|
503
|
+
Sound(wf=wf).display()
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
|
|
507
|
+
|
|
508
|
+

|
|
509
|
+
|
|
510
|
+
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+

|
|
515
|
+
|
|
516
|
+
|
|
517
|
+
|
|
518
|
+
### Annotated Waveform
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
```python
|
|
522
|
+
awf = AnnotatedWaveform(chk_size_frm=21*2048, freq=440, sr=44100, max_amplitude=30000)
|
|
523
|
+
gen = awf.chk_and_tag_gen()
|
|
524
|
+
list(gen)
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
|
|
530
|
+
[(array([-14025, 11555, 22270, ..., 10243, -18225, 3874], dtype=int16),
|
|
531
|
+
'random'),
|
|
532
|
+
(array([ 0, 1902, 3797, ..., 9361, 11149, 12893], dtype=int16),
|
|
533
|
+
'pure_tone'),
|
|
534
|
+
(array([-30000, -29900, -29800, ..., 10500, 10600, 10700], dtype=int16),
|
|
535
|
+
'triangular_tone'),
|
|
536
|
+
(array([30000, 30000, 30000, ..., 30000, 30000, 30000], dtype=int16),
|
|
537
|
+
'square_tone')]
|
|
538
|
+
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
|
|
542
|
+
```python
|
|
543
|
+
awf.get_wf_and_annots()
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
|
|
548
|
+
|
|
549
|
+
(array([ 5183, 10421, -21645, ..., 30000, 30000, 30000], dtype=int16),
|
|
550
|
+
{'random': [(0, 43008)],
|
|
551
|
+
'pure_tone': [(43008, 86016)],
|
|
552
|
+
'triangular_tone': [(86016, 129024)],
|
|
553
|
+
'square_tone': [(129024, 172032)]})
|
|
554
|
+
|
|
555
|
+
|
|
556
|
+
|
|
557
|
+
## Voiced time
|
|
558
|
+
Finally `hum` provides a function that will tell the time continuously with parameters for the frequency, speed, voice, volume, and time format
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
```python
|
|
562
|
+
tell_time_continuously(every_secs=5, verbose=True)
|
|
563
|
+
```
|
|
564
|
+
|
|
565
|
+
15 45 11
|
|
566
|
+
15 45 16
|
|
567
|
+
15 45 21
|
|
568
|
+
15 45 26
|
|
569
|
+
KeyboardInterrupt!!!
|
|
570
|
+
|