features
get_embeddings(story)
Load embeddings, vocabulary and word onset/offset times from the textgrid file.
Source code in src/encoders/features.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
|
get_envelope(signal)
Compute the audio envelope
Source code in src/encoders/features.py
18 19 20 21 |
|
lanczosfun(f_c, t, a=3)
Lanczos function with cutoff frequency f_c.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
float
|
Cutoff frequency |
required |
|
ndarray or float
|
Time |
required |
|
int
|
Number of lobes (window size), typically 2 or 3; only signals within the window will have non-zero weights. |
3
|
Returns:
Type | Description |
---|---|
ndarray or float
|
Lanczos function with cutoff frequency f_c |
Source code in src/encoders/features.py
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
|
lanczosinterp2D(signal, oldtime, newtime, window=3, cutoff_mult=1.0)
Lanczos interpolation for 2D signals; interpolates [signal] from [oldtime] to [newtime], assuming that the rows of [signal] correspond to [oldtime]. Returns a new signal with rows corresponding to [newtime] and the same number of columns as [signal].
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
ndarray
|
2-D array of shape (n_samples, n_features) |
required |
|
ndarray
|
1-D array of old time points |
required |
|
ndarray
|
1-D array of new time points |
required |
|
int
|
Number of lobes (window size) for the Lanczos function |
3
|
|
float
|
Multiplier for the cutoff frequency |
1.0
|
Returns:
Type | Description |
---|---|
ndarray
|
2-D array of shape (len(newtime), n_features) |
Source code in src/encoders/features.py
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 |
|
load_embeddings()
Load the embedding vectors and vocabulary from the EMBEDDINGS_FILE (h5py).
Source code in src/encoders/features.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
|
load_envelope_data(story, tr_len, y_data, use_cache=True)
Load .wavfile, compute envelope, trim and downsample to match the number of samples in y_data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
str
|
The story for which to load/compute the envelope. |
required |
|
float
|
The time-to-repeat (TR) |
required |
|
ndarray
|
The data to match the sampling frequency of. Uses y_data.shape[0] to determine the number downsampling rate. |
required |
|
bool
|
Whether or not to save computed results to cache dir (will save to encoders.utils.load_config()['CACHE_DIR']) |
True
|
Returns:
Type | Description |
---|---|
ndarray
|
The envelope data. |
Source code in src/encoders/features.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
|
make_delayed(signal, delays, circpad=False)
Create delayed versions of the 2-D signal.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
ndarray
|
2-D array of shape (n_samples, n_features) |
required |
|
ndarray
|
1-D array of delays to apply to the signal can be positive or negative; negative values advance the signal (shifting it backward) |
required |
|
bool
|
If True, use circular padding for delays If False, use zero padding for delays |
False
|
Returns:
Type | Description |
---|---|
ndarray
|
2-D array of shape (n_samples, n_features * ndelays) |
Source code in src/encoders/features.py
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
|
sinc(f_c, t)
Sin function with cutoff frequency f_c.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
float
|
Cutoff frequency |
required |
|
ndarray or float
|
Time |
required |
Returns:
Type | Description |
---|---|
ndarray or float
|
Sin function with cutoff frequency f_c |
Source code in src/encoders/features.py
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
|