OneTrack
OneTrack(
maximum_formant,
sound=None,
samples=None,
sampling_frequency=None,
xmin=0.0,
n_formants=4,
window_length=0.025,
time_step=0.002,
pre_emphasis_from=50,
smoother=Smoother(method='dct_smooth_regression'),
loss_fun=Loss(method='lmse'),
agg_fun=Agg(method='agg_sum'),
heuristics=[],
)A single formant track.
You can provide either
- A parselmouth
Soundobject to thesoundargument
xor
- An array of audio samples to the
samplesargument - The sampling frequency to the
sampling_frequencyargument - Any optional time offset to the
xminargument.
If a Sound object is passed to sound, any values passed to samples, sampling_frequency and xmin are ignored.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| sound | pm.Sound | A parselmouth.Sound object. |
None |
| samples | np.ndarray | A numpy array of audio samples. | None |
| sampling_frequency | float | The audio sampling frequency. | None |
| xmin | float | The time offset for the audio. Defaults to 0.0. | 0.0 |
| maximum_formant | float | max formant | required |
| n_formants | int | The number of formants to track. Defaults to 4. | 4 |
| window_length | float | Window length of the formant analysis. Defaults to 0.025. | 0.025 |
| time_step | float | Time step of the formant analyusis window. Defaults to 0.002. | 0.002 |
| pre_emphasis_from | float | Pre-emphasis threshold. Defaults to 50. | 50 |
| smoother | Smoother | The smoother method to use. Defaults to Smoother(). |
Smoother(method='dct_smooth_regression') |
| loss_fun | Loss | The loss function to use. Defaults to Loss(). | Loss(method='lmse') |
| agg_fun | Agg | The loss aggregation function to use. Defaults to Agg(). | Agg(method='agg_sum') |
| heuristics | list[MinMaxHeuristic | SpacingHeuristic] | A list of formant tracking heuristics to use. | [] |
Attributes
| Name | Type | Description |
|---|---|---|
| maximum_formant | float | The max formant |
| time_domain | np.array | The time domain of the formant estimates |
| formants | np.ndarray | A (formants, time) array of values. The formants as initially estimated by praat-parselmouth |
| smoothed_formants | np.ndarray | The smoothed formant values, using the method passed to smoother. |
| parameters | np.ndarray | The smoothing parameters. |
| smooth_error | float | The error term between formants and smoothed formants. |
| file_name | str | The filename of the audio file, if set. |
| interval | aligned_textgrid.SequenceInterval |
The textgrid interval of the sound, if set. |
| id | str | The interval id of the sound, if set. |
| group | str | The tier group name of the sound, if set. |
Methods
| Name | Description |
|---|---|
| spectrogram | This will plot the spectrogram and formant tracks |
| to_df | Output either the formant values or the formant smoothing parameters as a polars dataframe |
spectrogram
OneTrack.spectrogram(**kwargs)This will plot the spectrogram and formant tracks of a single candidate track. If a file_name is provided, it will save the plot to disk.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| formants | int | The number of formants to plot. Defaults to 3. | required |
| maximum_frequency | float | The frequency range the spectrogram and formants will be plotted up to. Defaults to 3500. | required |
| tracks | bool | Whether or not to plot the formant tracks. Defaults to True. If False, just the spectogram will be plotted. | required |
| dynamic_range | float | A all spectrogram values below the dynamic range. will be plotted as white. Defaults to 60. | required |
| figsize | tuple[float, float] | Width and height of the figure in inches. Defaults to (8,5). | required |
| color_scale | str | A named matplotlib color scale for the spectrogram. Defaults to “Greys”. See here for more options. | required |
| file_name | Path | None |
If provided, how to save the spectrogram. If not provided (None) the plot will show interactively. Defaults to None. | required |
| dpi | float | If the plot is being saved, its image resolution in dots per inch. Defaults to 100. | required |
to_df
OneTrack.to_df(output='formants')Output either the formant values or the formant smoothing parameters as a polars dataframe
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| output | Literal['formants', 'param', 'log_param'] | Whether to output the formants or the smoothing parameters. Defaults to “formants”. | 'formants' |
Returns
| Name | Type | Description |
|---|---|---|
pl.DataFrame |
A polars.DataFrame |