Utilities¶
kudio.util.tools
¶
Small generic helpers: timing decorators and list utilities.
Classes:
| Name | Description |
|---|---|
Timer |
Decorator: run func in a daemon thread, optionally joining for at most |
Functions:
| Name | Description |
|---|---|
timer |
Decorator: log the wall-clock run time of func. |
find_duplicate |
Return the |
Timer
¶
timer
¶
Decorator: log the wall-clock run time of func.
Source code in kudio/util/tools.py
find_duplicate
¶
Return the Counter dict of file_list, logging duplicated entries.
Source code in kudio/util/tools.py
kudio.util.parallel
¶
Parallel batch processing helpers.
Functions:
| Name | Description |
|---|---|
map_waves |
Apply fn to every item, optionally across |
map_waves
¶
map_waves(
fn: Callable,
items: Iterable,
workers: int = 1,
desc: Optional[str] = None,
chunksize: int = 1,
) -> List
Apply fn to every item, optionally across workers processes.
With workers <= 1 runs sequentially (easier to debug); otherwise uses a
multiprocessing pool. fn must be top-level (picklable) for workers > 1.
Source code in kudio/util/parallel.py
kudio.util.colors
¶
ANSI-colored console helpers used by the CLI tools and the GUI.
Colors
¶
ANSI escape sequences (SGR codes).
kudio.util.conv
¶
Data conversion/export helpers.
Functions:
| Name | Description |
|---|---|
data2xlsx |
Write a dict or DataFrame to a sheet of an |
lowercase |
The strings in lst, lower-cased. Anything that is not a string is |
uppercase |
The strings in lst, upper-cased. Anything that is not a string is |
data2xlsx
¶
data2xlsx(
data: Union[dict, DataFrame],
xlsx_dir: Union[str, Path],
sheet_name: str,
index: bool = False,
fit_column: bool = True,
) -> Optional[str]
Write a dict or DataFrame to a sheet of an .xlsx file.
If the file already exists, the sheet is replaced; other sheets are kept.
With fit_column=True, column widths are auto-sized to the content.
Source code in kudio/util/conv.py
lowercase
¶
The strings in lst, lower-cased. Anything that is not a string is left out.
uppercase
¶
The strings in lst, upper-cased. Anything that is not a string is left out.
kudio.util.visual
¶
Plotting helpers: waveforms, spectrograms, training histories.
Classes:
| Name | Description |
|---|---|
Common |
Base figure wrapper with save/show/close helpers. |
WaveVisualizer |
Plot waveform + spectrogram side by side for one or more files. |
Functions:
| Name | Description |
|---|---|
history_plot |
Plot every history curve whose key contains metrics (Keras History). |
Common
¶
Base figure wrapper with save/show/close helpers.
Methods:
| Name | Description |
|---|---|
plot_stft_w_2mfe |
Waveform + two mel spectrograms (full band vs. |
Source code in kudio/util/visual.py
plot_stft_w_2mfe
staticmethod
¶
Waveform + two mel spectrograms (full band vs. sub_mfe_fq).
Source code in kudio/util/visual.py
WaveVisualizer
¶
WaveVisualizer(
fig_size: Tuple[float, float] = (7, 5),
dpi: int = 200,
subplots: Optional[int] = None,
)
Bases: Common
Plot waveform + spectrogram side by side for one or more files.
Source code in kudio/util/visual.py
history_plot
¶
Plot every history curve whose key contains metrics (Keras History).
Source code in kudio/util/visual.py
hist_plt
¶
Plot Keras accuracy/loss curves side by side.
Source code in kudio/util/visual.py
basic_analyze
¶
Waveform / STFT / zero-crossing-rate overview of a file.
Source code in kudio/util/visual.py
plot_4_features
¶
Waveform + spectral centroid/rolloff/ZCR and power spectral density.
Source code in kudio/util/visual.py
plot_3_features
¶
Waveform + spectral centroid/rolloff/ZCR.
Source code in kudio/util/visual.py
plot_PSD
¶
Power spectral density of a file.
Source code in kudio/util/visual.py
normalize
¶
Min-max scale to [0, 1] along axis.