Phonological features¶
Created on Jun 24 2020
@author: J. C. Vasquez-Correa
-
class
phonological.
Phonological
¶ Compute phonological features from continuous speech files.
18 descriptors are computed, bases on 18 different phonological classes from the phonet toolkit https://phonet.readthedocs.io/en/latest/?badge=latest
It computes the phonological log-likelihood ratio features from phonet
Static or dynamic matrices can be computed:
Static matrix is formed with 108 features formed with (18 descriptors) x (6 functionals: mean, std, skewness, kurtosis, max, min)
Dynamic matrix is formed with the 18 descriptors computed for frames of 25 ms with a time-shift of 10 ms.
Script is called as follows
>>> python phonological.py <file_or_folder_audio> <file_features> <static (true or false)> <plots (true or false)> <format (csv, txt, npy, kaldi, torch)>
Examples command line:
>>> python phonological.py "../audios/001_ddk1_PCGITA.wav" "phonologicalfeaturesAst.txt" "true" "true" "txt" >>> python phonological.py "../audios/001_ddk1_PCGITA.wav" "phonologicalfeaturesUst.csv" "true" "true" "csv" >>> python phonological.py "../audios/001_ddk1_PCGITA.wav" "phonologicalfeaturesUdyn.pt" "false" "true" "torch"
>>> python phonological.py "../audios/" "phonologicalfeaturesst.txt" "true" "false" "txt" >>> python phonological.py "../audios/" "phonologicalfeaturesst.csv" "true" "false" "csv" >>> python phonological.py "../audios/" "phonologicalfeaturesdyn.pt" "false" "false" "torch" >>> python phonological.py "../audios/" "phonologicalfeaturesdyn.csv" "false" "false" "csv"
Examples directly in Python
>>> phonological=Phonological() >>> file_audio="../audios/001_ddk1_PCGITA.wav" >>> features1=phonological.extract_features_file(file_audio, static=True, plots=True, fmt="npy") >>> features2=phonological.extract_features_file(file_audio, static=True, plots=True, fmt="dataframe") >>> features3=phonological.extract_features_file(file_audio, static=False, plots=True, fmt="torch") >>> phonological.extract_features_file(file_audio, static=False, plots=False, fmt="kaldi", kaldi_file="./test")
-
extract_features_file
(audio, static=True, plots=False, fmt='npy', kaldi_file='')¶ Extract the phonological features from an audio file
Parameters: - audio – .wav audio file.
- static – whether to compute and return statistic functionals over the feature matrix, or return the feature matrix computed over frames
- plots – timeshift to extract the features
- fmt – format to return the features (npy, dataframe, torch, kaldi)
- kaldi_file – file to store kaldi features, only valid when fmt==”kaldi”
Returns: features computed from the audio file.
>>> phonological=Phonological() >>> file_audio="../audios/001_ddk1_PCGITA.wav" >>> features1=phonological.extract_features_file(file_audio, static=True, plots=True, fmt="npy") >>> features2=phonological.extract_features_file(file_audio, static=True, plots=True, fmt="dataframe") >>> features3=phonological.extract_features_file(file_audio, static=False, plots=True, fmt="torch") >>> phonological.extract_features_file(file_audio, static=False, plots=False, fmt="kaldi", kaldi_file="./test")
>>> phonological=Phonological() >>> path_audio="../audios/" >>> features1=phonological.extract_features_path(path_audio, static=True, plots=False, fmt="npy") >>> features2=phonological.extract_features_path(path_audio, static=True, plots=False, fmt="csv") >>> features3=phonological.extract_features_path(path_audio, static=False, plots=True, fmt="torch") >>> phonological.extract_features_path(path_audio, static=False, plots=False, fmt="kaldi", kaldi_file="./test.ark")
-
extract_features_path
(path_audio, static=True, plots=False, fmt='npy', kaldi_file='')¶ Extract the phonological features for audios inside a path
Parameters: - path_audio – directory with (.wav) audio files inside, sampled at 16 kHz
- static – whether to compute and return statistic functionals over the feature matrix, or return the feature matrix computed over frames
- plots – timeshift to extract the features
- fmt – format to return the features (npy, dataframe, torch, kaldi)
- kaldi_file – file to store kaldifeatures, only valid when fmt==”kaldi”
Returns: features computed from the audio file.
>>> phonological=Phonological() >>> path_audio="../audios/" >>> features1=phonological.extract_features_path(path_audio, static=True, plots=False, fmt="npy") >>> features2=phonological.extract_features_path(path_audio, static=True, plots=False, fmt="csv") >>> features3=phonological.extract_features_path(path_audio, static=False, plots=True, fmt="torch") >>> phonological.extract_features_path(path_audio, static=False, plots=False, fmt="kaldi", kaldi_file="./test.ark")
-