@@ -222,6 +222,14 @@ class ConfigRawReader(object):
|
||||
self.mov_Hpose_Yaw = config['raw_feature']['mov_Hpose_Yaw']
|
||||
self.mov_Hpose_Roll = config['raw_feature']['mov_Hpose_Roll']
|
||||
self.mov_Hpose_Dist = config['raw_feature']['mov_Hpose_Dist']
|
||||
|
||||
self.mov_freq_trem_freq = config['raw_feature']['mov_freq_trem_freq']
|
||||
self.mov_freq_trem_index = config['raw_feature']['mov_freq_trem_index']
|
||||
self.mov_freq_trem_pindex = config['raw_feature']['mov_freq_trem_pindex']
|
||||
self.mov_amp_trem_freq = config['raw_feature']['mov_amp_trem_freq']
|
||||
self.mov_amp_trem_index = config['raw_feature']['mov_amp_trem_index']
|
||||
self.mov_amp_trem_pindex = config['raw_feature']['mov_amp_trem_pindex']
|
||||
|
||||
self.mov_leye_x = config['raw_feature']['mov_leye_x']
|
||||
self.mov_leye_y = config['raw_feature']['mov_leye_y']
|
||||
self.mov_leye_z = config['raw_feature']['mov_leye_z']
|
||||
|
||||
@@ -7,7 +7,7 @@ created: 2020-20-07
|
||||
from dbm_lib.dbm_features.raw_features.audio import intensity, pitch_freq, hnr, gne, voice_frame_score, formant_freq
|
||||
from dbm_lib.dbm_features.raw_features.audio import pause_segment, jitter, shimmer, mfcc
|
||||
from dbm_lib.dbm_features.raw_features.video import face_asymmetry, face_au, face_emotion_expressivity, face_landmark
|
||||
from dbm_lib.dbm_features.raw_features.movement import head_motion, eye_blink, eye_gaze
|
||||
from dbm_lib.dbm_features.raw_features.movement import head_motion, eye_blink, eye_gaze, voice_tremor
|
||||
from dbm_lib.dbm_features.raw_features.nlp import transcribe, speech_features
|
||||
|
||||
import subprocess
|
||||
@@ -118,6 +118,7 @@ def process_movement(video_uri, out_dir, dbm_group, r_config, dlib_model):
|
||||
return
|
||||
|
||||
logger.info('Processing movement variables from data in {}'.format(video_uri))
|
||||
|
||||
logger.info('processing head movement....')
|
||||
head_motion.run_head_movement(video_uri, out_dir, r_config)
|
||||
|
||||
@@ -127,6 +128,9 @@ def process_movement(video_uri, out_dir, dbm_group, r_config, dlib_model):
|
||||
logger.info('processing eye gaze....')
|
||||
eye_gaze.run_eye_gaze(video_uri, out_dir, r_config)
|
||||
|
||||
logger.info('processing voice tremor....')
|
||||
voice_tremor.run_vtremor(video_uri, out_dir, r_config)
|
||||
|
||||
def process_nlp(video_uri, out_dir, dbm_group, r_config, deep_path):
|
||||
"""
|
||||
processing nlp features
|
||||
@@ -152,5 +156,3 @@ def remove_file(file_path):
|
||||
|
||||
if len(wav_file)> 0:
|
||||
os.remove(wav_file[0])
|
||||
|
||||
|
||||
@@ -11,3 +11,6 @@ from __future__ import print_function
|
||||
import os
|
||||
|
||||
DBMLIB_PATH = os.path.dirname(__file__)
|
||||
DBMLIB_VTREMOR_LIB = os.path.abspath(os.path.join(DBMLIB_PATH,
|
||||
'../../../../resources/libraries/voice_tremor.praat'))
|
||||
DBMLIB_FTREMOR_CONFIG = os.path.abspath(os.path.join(DBMLIB_PATH, '../resources/features/facial/config.json'))
|
||||
|
||||
94
dbm_lib/dbm_features/raw_features/movement/voice_tremor.py
Normal file
94
dbm_lib/dbm_features/raw_features/movement/voice_tremor.py
Normal file
@@ -0,0 +1,94 @@
|
||||
import pandas as pd
|
||||
import os
|
||||
import glob
|
||||
from os.path import join
|
||||
import parselmouth
|
||||
from parselmouth.praat import call, run_file
|
||||
import numpy as np
|
||||
import librosa
|
||||
import json
|
||||
import re
|
||||
import logging
|
||||
|
||||
from dbm_lib.dbm_features.raw_features.util import util as ut
|
||||
from dbm_lib.dbm_features.raw_features.movement import DBMLIB_VTREMOR_LIB
|
||||
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
logger=logging.getLogger()
|
||||
|
||||
vt_dir = 'movement/voice_tremor'
|
||||
csv_ext = '_vtremor.csv'
|
||||
|
||||
#Executing praat script using parselmouth function
|
||||
def tremor_praat(snd_file,r_cfg):
|
||||
"""
|
||||
Generating Voice tremor endpoint dataframe
|
||||
Args:
|
||||
snd_file: (.wav) parsed audio file
|
||||
r_cfg: Raw variable configuration file
|
||||
Returns tremor endpoint dataframe
|
||||
"""
|
||||
snd = parselmouth.Sound(snd_file)
|
||||
tremor_var = run_file(snd,DBMLIB_VTREMOR_LIB,capture_output=True)
|
||||
new_tremor_var = re.sub('--undefined--', '0', tremor_var[1])
|
||||
res = json.loads(new_tremor_var)
|
||||
tremor_df = pd.DataFrame(res,index=['0',])
|
||||
tremor_df.columns = [r_cfg.mov_freq_trem_freq,r_cfg.mov_amp_trem_freq,r_cfg.mov_freq_trem_index,
|
||||
r_cfg.mov_amp_trem_index,r_cfg.mov_freq_trem_pindex,r_cfg.mov_amp_trem_pindex]
|
||||
return tremor_df
|
||||
|
||||
def prepare_vtrem_output(audio_file, out_loc, r_config, fl_name):
|
||||
"""
|
||||
Preparing voice tremor matrix
|
||||
Args:
|
||||
audio_file: (.wav) parsed audio file ; r_config: raw config object
|
||||
out_loc: (str) Output directory for csv ; fl_name: file name
|
||||
"""
|
||||
df_tremor = tremor_praat(audio_file, r_config)
|
||||
df_tremor[r_config.err_reason] = 'Pass'# will replace with threshold in future release
|
||||
|
||||
logger.info('Processing Output file {} '.format(out_loc))
|
||||
ut.save_output(df_tremor, out_loc, fl_name, vt_dir, csv_ext)
|
||||
|
||||
def prepare_empty_vt(out_loc, fl_name, r_config, error_txt):
|
||||
|
||||
"""
|
||||
Preparing empty voice tremor matrix
|
||||
"""
|
||||
cols = [r_config.mov_freq_trem_freq, r_config.mov_amp_trem_freq, r_config.mov_freq_trem_index,
|
||||
r_config.mov_amp_trem_index, r_config.mov_freq_trem_pindex, r_config.mov_amp_trem_pindex, r_config.err_reason]
|
||||
|
||||
out_val = [[np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, error_txt]]
|
||||
df_tremor = pd.DataFrame(out_val, columns = cols)
|
||||
|
||||
logger.info('Saving Output file {} '.format(out_loc))
|
||||
ut.save_output(df_tremor, out_loc, fl_name, vt_dir, csv_ext)
|
||||
|
||||
def run_vtremor(video_uri, out_dir, r_config):
|
||||
"""
|
||||
Processing all patient's for fetching Formant freq
|
||||
---------------
|
||||
---------------
|
||||
Args:
|
||||
video_uri: video path; r_config: raw variable config object
|
||||
out_dir: (str) Output directory for processed output
|
||||
"""
|
||||
try:
|
||||
input_loc, out_loc, fl_name = ut.filter_path(video_uri, out_dir)
|
||||
aud_filter = glob.glob(join(input_loc, fl_name + '.wav'))
|
||||
|
||||
if len(aud_filter)>0:
|
||||
|
||||
audio_file = aud_filter[0]
|
||||
aud_dur = librosa.get_duration(filename=audio_file)
|
||||
|
||||
if float(aud_dur) < 0.5:
|
||||
logger.info('Output file {} size is less than 0.5sec'.format(audio_file))
|
||||
|
||||
error_txt = 'error: length less than 0.5 sec'
|
||||
prepare_empty_vt(video_uri, out_loc, fl_name, error_txt)
|
||||
return
|
||||
prepare_vtrem_output(audio_file, out_loc, r_config, fl_name)
|
||||
except Exception as e:
|
||||
logger.error('Failed to compute Voice Tremor {} for {}'.format(e,video_uri))
|
||||
prepare_empty_vt(out_loc, fl_name, r_config, e)
|
||||
@@ -34,13 +34,12 @@ def common_video(video_file, args, r_config):
|
||||
out_path = os.path.join(args.output_path, 'raw_variables')
|
||||
pf.audio_to_wav(video_file)
|
||||
of.process_open_face(video_file, os.path.dirname(video_file), out_path, OPENFACE_PATH, args.dbm_group)
|
||||
|
||||
pf.process_facial(video_file, out_path, args.dbm_group, r_config)
|
||||
pf.process_acoustic(video_file, out_path, args.dbm_group, r_config)
|
||||
pf.process_nlp(video_file, out_path, args.dbm_group, r_config, DEEP_SPEECH)
|
||||
|
||||
pf.remove_file(video_file)
|
||||
pf.process_movement(video_file, out_path, args.dbm_group, r_config, DLIB_SHAPE_MODEL)
|
||||
pf.remove_file(video_file)
|
||||
|
||||
def process_raw_video_file(args, s_config, r_config):
|
||||
"""
|
||||
@@ -107,7 +106,6 @@ def process_raw_video_dir(args, s_config, r_config):
|
||||
logger.info('Calculating raw variables...')
|
||||
for vid_file in vid_loc:
|
||||
try:
|
||||
|
||||
common_video(vid_file, args, r_config)
|
||||
except Exception as e:
|
||||
logger.error('Failed to process mp4 file.')
|
||||
|
||||
@@ -4,9 +4,9 @@ helpFunction()
|
||||
{
|
||||
echo ""
|
||||
echo "Usage: $0 --input_path parameterA --output_path parameterB --dbm_group parameterC"
|
||||
echo -e "\t--input_path Description of what is parameterA"
|
||||
echo -e "\t--output_path Description of what is parameterB"
|
||||
echo -e "\t-dbm_group Description of what is parameterC"
|
||||
echo -e "\t--input_path: path to the input files"
|
||||
echo -e "\t--output_path: path to the raw and derived variable output"
|
||||
echo -e "\t--dbm_group: list of feature groups"
|
||||
exit 1 # Exit script after printing help
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ derive_feature:
|
||||
#DBM Feature Group
|
||||
FEATURE_GROUP: ['FAC_ASYM', 'FAC_AU', 'FAC_EXP', 'FAC_LMK', 'ACO_INT', 'ACO_FF', 'ACO_HNR', 'ACO_GNE', 'ACO_FM',
|
||||
'ACO_JITTER','ACO_SHIMMER', 'ACO_PAUSE', 'ACO_VFS', 'ACO_MFCC', 'MOV_HM', 'MOV_HP', 'EYE_BLINK', 'NLP_SPEECH',
|
||||
'EYE_GAZE']
|
||||
'EYE_GAZE', 'MOV_VT']
|
||||
|
||||
#Feature group output file extensions
|
||||
FAC_ASYM_LOC: _facasym
|
||||
@@ -25,6 +25,7 @@ derive_feature:
|
||||
EYE_BLINK_LOC: _eyeblinks
|
||||
NLP_SPEECH_LOC: _nlp
|
||||
EYE_GAZE_LOC: _eyegaze
|
||||
MOV_VT_LOC: _vtremor
|
||||
|
||||
#Facial category feature group
|
||||
FAC_ASYM: ['fac_AsymMaskMouth', 'fac_AsymMaskEyebrow', 'fac_AsymMaskEye', 'fac_AsymMaskCom']
|
||||
@@ -67,6 +68,9 @@ derive_feature:
|
||||
MOV_HM: ['head_vel']
|
||||
MOV_HP: ['mov_Hpose_Dist','mov_Hpose_Pitch','mov_Hpose_Yaw','mov_Hpose_Roll']
|
||||
EYE_BLINK: ['mov_blink_ear', 'vid_dur', 'mov_blinkdur']
|
||||
MOV_VT: ['mov_freq_trem_freq', 'mov_freq_trem_index', 'mov_freq_trem_pindex', 'mov_amp_trem_freq',
|
||||
'mov_amp_trem_index', 'mov_amp_trem_pindex']
|
||||
|
||||
EYE_GAZE: ['mov_leye_x', 'mov_leye_y', 'mov_leye_z', 'mov_reye_x', 'mov_reye_y', 'mov_reye_z', 'mov_eleft_disp',
|
||||
'mov_eright_disp']
|
||||
|
||||
@@ -259,6 +263,14 @@ derive_feature:
|
||||
mov_blink_ear: ['mean', 'std']
|
||||
vid_dur: ['count']
|
||||
mov_blinkdur: ['mean', 'std']
|
||||
|
||||
mov_freq_trem_freq: ['mean']
|
||||
mov_freq_trem_index: ['mean']
|
||||
mov_freq_trem_pindex: ['mean']
|
||||
mov_amp_trem_freq: ['mean']
|
||||
mov_amp_trem_index: ['mean']
|
||||
mov_amp_trem_pindex: ['mean']
|
||||
|
||||
mov_leye_x: ['mean', 'std']
|
||||
mov_leye_y: ['mean', 'std']
|
||||
mov_leye_z: ['mean', 'std']
|
||||
|
||||
@@ -196,6 +196,14 @@ raw_feature:
|
||||
mov_Hpose_Yaw: mov_hposeyaw
|
||||
mov_Hpose_Roll: mov_hposeroll
|
||||
mov_Hpose_Dist: mov_hposedist
|
||||
|
||||
mov_freq_trem_freq: mov_freqtremfreq
|
||||
mov_freq_trem_index: mov_freqtremindex
|
||||
mov_freq_trem_pindex: mov_freqtrempindex
|
||||
mov_amp_trem_freq: mov_amptremfreq
|
||||
mov_amp_trem_index: mov_amptremindex
|
||||
mov_amp_trem_pindex: mov_amptrempindex
|
||||
|
||||
mov_leye_x: mov_lefteyex
|
||||
mov_leye_y: mov_lefteyey
|
||||
mov_leye_z: mov_lefteyez
|
||||
@@ -225,3 +233,5 @@ raw_feature:
|
||||
nlp_wordsPerMin: nlp_wordsPerMin
|
||||
nlp_totalTime: nlp_totalTime
|
||||
|
||||
|
||||
|
||||
|
||||
422
resources/libraries/voice_tremor.praat
Normal file
422
resources/libraries/voice_tremor.praat
Normal file
@@ -0,0 +1,422 @@
|
||||
|
||||
######################################
|
||||
# Global Settings
|
||||
######################################
|
||||
sourcedirec$ = "./"; directory of sounds to be analyzed
|
||||
minPi = 60; minimal Pitch [Hz]
|
||||
maxPi = 350; maximal Pitch [Hz]
|
||||
ts = 0.015; analysis time step [s]
|
||||
tremthresh = 0.15; minimal autocorr.-coefficient to assume "tremor"
|
||||
minTr = 1.5; minimal tremor frequency [Hz]
|
||||
maxTr = 15; maximal tremor frequency [Hz]
|
||||
|
||||
|
||||
|
||||
######################################
|
||||
# Sound (.wav) in, results (.txt) out
|
||||
######################################
|
||||
|
||||
# record/load and select the sound to be analyzed!!!
|
||||
|
||||
info$ = Info
|
||||
name$ = extractWord$(info$, "Object name: ")
|
||||
|
||||
slength = Get total duration
|
||||
call ftrem
|
||||
call atrem
|
||||
|
||||
echo
|
||||
...{"FTrF": 'ftrf:2#', "ATrF":'atrf:2',"FTrI":'ftri:3',"ATrI":'atri:3',"FTrP":'ftrp:3',"ATrP":'atrp:3'}
|
||||
|
||||
|
||||
|
||||
######################################
|
||||
# Frequency Tremor Analysis
|
||||
######################################
|
||||
procedure ftrem
|
||||
To Pitch (cc)... ts minPi 15 yes 0.03 0.3 0.01 0.35 0.14 maxPi
|
||||
|
||||
#Edit
|
||||
#pause
|
||||
|
||||
# because PRAAT only runs "Subtract linear fit" if the last frame is "voiceless" (!?):
|
||||
# numberOfFrames+1 (1)
|
||||
numberOfFrames = Get number of frames
|
||||
x1 = Get time from frame number... 1
|
||||
am_F0 = Get mean... 0 0 Hertz
|
||||
|
||||
Create Matrix... ftrem_0 0 slength numberOfFrames+1 ts x1 1 1 1 1 1 0
|
||||
for i from 1 to numberOfFrames
|
||||
select Pitch 'name$'
|
||||
f0 = Get value in frame... i Hertz
|
||||
select Matrix ftrem_0
|
||||
# write zeros to matrix where frames are voiceless
|
||||
if f0 = undefined
|
||||
Set value... 1 i 0
|
||||
else
|
||||
Set value... 1 i f0
|
||||
endif
|
||||
endfor
|
||||
|
||||
# remove the linear F0 trend (F0 declination)
|
||||
To Pitch
|
||||
Subtract linear fit... Hertz
|
||||
Rename... ftrem_0_lin
|
||||
|
||||
# undo (1)
|
||||
Create Matrix... ftrem 0 slength numberOfFrames ts x1 1 1 1 1 1 0
|
||||
for i from 1 to numberOfFrames
|
||||
select Pitch ftrem_0_lin
|
||||
f0 = Get value in frame... i Hertz
|
||||
select Matrix ftrem
|
||||
# write zeros to matrix where frames are voiceless
|
||||
if f0 = undefined
|
||||
Set value... 1 i 0
|
||||
else
|
||||
Set value... 1 i f0
|
||||
endif
|
||||
endfor
|
||||
|
||||
To Pitch
|
||||
|
||||
# normalize F0-contour by mean F0
|
||||
select Matrix ftrem
|
||||
Formula... (self-am_F0)/am_F0
|
||||
|
||||
# since zeros in the Matrix (unvoiced frames) become normalized to -1 but
|
||||
# unvoiced frames should be zero (if anything)
|
||||
# write zeros to matrix where frames are voiceless
|
||||
for i from 1 to numberOfFrames
|
||||
select Pitch ftrem
|
||||
f0 = Get value in frame... i Hertz
|
||||
if f0 = undefined
|
||||
select Matrix ftrem
|
||||
Set value... 1 i 0
|
||||
endif
|
||||
endfor
|
||||
|
||||
# to calculate autocorrelation (cc-method):
|
||||
select Matrix ftrem
|
||||
To Sound (slice)... 1
|
||||
# calculate Frequency of Frequency Tremor [Hz]
|
||||
To Pitch (cc)... slength minTr 15 yes 0.01 tremthresh 0.01 0.35 0.14 maxTr
|
||||
Rename... ftrem_norm
|
||||
|
||||
ftrf = Get mean... 0 0 Hertz
|
||||
|
||||
# calculate Intensity Index of Frequency Tremor [%]
|
||||
select Sound ftrem
|
||||
plus Pitch ftrem_norm
|
||||
To PointProcess (peaks)... yes no
|
||||
Rename... Maxima
|
||||
numberofMaxPoints = Get number of points
|
||||
ftri_max = 0
|
||||
noFMax = 0
|
||||
for iPoint from 1 to numberofMaxPoints
|
||||
select PointProcess Maxima
|
||||
ti = Get time from index... iPoint
|
||||
select Sound ftrem
|
||||
ftri_Point = Get value at time... Average ti Sinc70
|
||||
if ftri_Point = undefined
|
||||
ftri_Point = 0
|
||||
noFMax += 1
|
||||
endif
|
||||
ftri_max += abs(ftri_Point)
|
||||
endfor
|
||||
|
||||
select Sound ftrem
|
||||
plus PointProcess Maxima
|
||||
#Edit
|
||||
#pause
|
||||
|
||||
# ftri_max:= (mean) procentual deviation of F0-maxima from mean F0 at ftrf
|
||||
numberofMaxima = numberofMaxPoints - noFMax
|
||||
ftri_max = 100 * ftri_max/numberofMaxima
|
||||
|
||||
select Sound ftrem
|
||||
plus Pitch ftrem_norm
|
||||
To PointProcess (peaks)... no yes
|
||||
Rename... Minima
|
||||
numberofMinPoints = Get number of points
|
||||
ftri_min = 0
|
||||
noFMin = 0
|
||||
for iPoint from 1 to numberofMinPoints
|
||||
select PointProcess Minima
|
||||
ti = Get time from index... iPoint
|
||||
select Sound ftrem
|
||||
ftri_Point = Get value at time... Average ti Sinc70
|
||||
if ftri_Point = undefined
|
||||
ftri_Point = 0
|
||||
noFMin += 1
|
||||
endif
|
||||
ftri_min += abs(ftri_Point)
|
||||
endfor
|
||||
|
||||
select Sound ftrem
|
||||
plus PointProcess Minima
|
||||
#Edit
|
||||
#pause
|
||||
|
||||
|
||||
# ftri_min:= (mean) procentual deviation of F0-minima from mean F0 at ftrf
|
||||
numberofMinima = numberofMinPoints - noFMin
|
||||
ftri_min = 100 * ftri_min/numberofMinima
|
||||
|
||||
ftri = (ftri_max + ftri_min) / 2
|
||||
|
||||
ftrp = ftri * ftrf/(ftrf+1)
|
||||
|
||||
# uncomment to inspect frequnecy tremor objects:
|
||||
# pause
|
||||
|
||||
select Pitch ftrem
|
||||
# uncomment if only frequency tremor is to be analyzed:
|
||||
# plus Pitch 'name$'
|
||||
plus Matrix ftrem_0
|
||||
plus Pitch ftrem_0
|
||||
plus Pitch ftrem_0_lin
|
||||
plus Matrix ftrem
|
||||
plus Sound ftrem
|
||||
plus Pitch ftrem_norm
|
||||
plus PointProcess Maxima
|
||||
plus PointProcess Minima
|
||||
Remove
|
||||
|
||||
endproc
|
||||
|
||||
|
||||
######################################
|
||||
# Amplitude Tremor Analysis
|
||||
######################################
|
||||
procedure atrem
|
||||
select Sound 'name$'
|
||||
# uncomment if only amplitude tremor is to be analyzed:
|
||||
# To Pitch (cc)... ts minPi 15 yes 0.03 0.3 0.01 0.35 0.14 maxPi
|
||||
# select Sound 'name$'
|
||||
plus Pitch 'name$'
|
||||
To PointProcess (cc)
|
||||
select Sound 'name$'
|
||||
plus PointProcess 'name$'_'name$'
|
||||
|
||||
# amplitudes are integrals of intensity over periods -- not intensity maxima
|
||||
To AmplitudeTier (period)... 0 0 0.0001 0.02 1.7
|
||||
|
||||
#Edit
|
||||
#pause
|
||||
|
||||
# from here on out: prepare to autocorrelate AmplitudeTier-data
|
||||
# sample AmplitudeTier at (constant) rate ts
|
||||
numbOfAmpPoints = Get number of points
|
||||
first_ampP = Get time from index... 1
|
||||
last_ampP = Get time from index... numbOfAmpPoints
|
||||
|
||||
# to be able to -- automatically -- read Amp. values...
|
||||
Down to TableOfReal
|
||||
|
||||
select Pitch 'name$'
|
||||
frameNo1 = Get frame number from time... first_ampP
|
||||
hiframe1 = ceiling(frameNo1)
|
||||
t_hiframe1 = Get time from frame number... hiframe1
|
||||
|
||||
frameNoN = Get frame number from time... last_ampP
|
||||
loframeN = floor(frameNoN)
|
||||
|
||||
# number of Amp. points if (re-)sampled at ts
|
||||
numbOfPoints_neu = loframeN - hiframe1 + 1
|
||||
|
||||
# to enable autocorrelation of the Amp.-contour: ->Matrix->Sound
|
||||
|
||||
Create Matrix... atrem_nlc 0 slength numbOfPoints_neu+1 ts t_hiframe1 1 1 1 1 1 2
|
||||
# get the mean of the amplitude contour in time windows of constant duration
|
||||
for point_neu from 1 to numbOfPoints_neu
|
||||
t = (point_neu-1) * ts + t_hiframe1
|
||||
tl = t - ts/2
|
||||
tu = t + ts/2
|
||||
|
||||
select AmplitudeTier 'name$'_'name$'_'name$'
|
||||
loil = Get low index from time... tl
|
||||
hiil = Get high index from time... tl
|
||||
loiu = Get low index from time... tu
|
||||
hiiu = Get high index from time... tu
|
||||
|
||||
select TableOfReal 'name$'_'name$'_'name$'
|
||||
if loil = 0
|
||||
lotl = 0; time before the first amp. point
|
||||
druck_lol = Get value... hiil 2; amplitude value before the first amp. point
|
||||
else
|
||||
lotl = Get value... loil 1; time value of Amp.Point before tl in the PointProcess [s]
|
||||
druck_lol = Get value... loil 2; amplitude value before tl in the PointProcess [Pa, ranged from 0 to 1]
|
||||
endif
|
||||
|
||||
hitl = Get value... hiil 1
|
||||
druck_hil = Get value... hiil 2; amplitude value after tl in the PointProcess
|
||||
|
||||
lotu = Get value... loiu 1
|
||||
druck_lou = Get value... loiu 2; amplitude value before tu in the PointProcess
|
||||
|
||||
if hiiu = numbOfAmpPoints + 1
|
||||
hitu = slength; time after the last amp. point
|
||||
druck_hiu = Get value... hiil 2; amplitude value after the last amp. point
|
||||
else
|
||||
hitu = Get value... hiiu 1; time value after tu in the PointProcess
|
||||
druck_hiu = Get value... hiiu 2; amplitude value after tu in the PointProcess
|
||||
endif
|
||||
|
||||
nPinter = loiu - loil; = hiiu - hiil; number of amp.-points between tl and tu
|
||||
if nPinter > 0
|
||||
itinter = 0
|
||||
tinter = 0
|
||||
druck_tin = 0
|
||||
deltat = 0
|
||||
for iinter from 1 to nPinter
|
||||
hilft = itinter
|
||||
itinter = Get value... loil+iinter 1
|
||||
idruck_tin = Get value... loil+iinter 2
|
||||
|
||||
ideltat = itinter - hilft
|
||||
druck_tin += idruck_tin * ideltat
|
||||
tinter += itinter
|
||||
deltat += ideltat
|
||||
endfor
|
||||
|
||||
tin = tinter/nPinter
|
||||
druck_tin = druck_tin/deltat
|
||||
endif
|
||||
|
||||
druck_tl = ((hitl-tl)*druck_lol + (tl-lotl)*druck_hil) / (hitl-lotl)
|
||||
druck_tu = ((hitu-tu)*druck_lou + (tu-lotu)*druck_hiu) / (hitu-lotu)
|
||||
|
||||
if nPinter = 0; loil = loiu; hiil = hiiu
|
||||
druck_mean = (druck_tl + druck_tu) / 2
|
||||
else
|
||||
druck_mean = ((tin-tl)*(druck_tl + druck_tin)/2 + (tu-tin)*(druck_tin + druck_tu)/2) / (tu-tl)
|
||||
endif
|
||||
|
||||
select Matrix atrem_nlc
|
||||
Set value... 1 point_neu druck_mean
|
||||
endfor
|
||||
|
||||
To Pitch
|
||||
am_Int = Get mean... 0 0 Hertz
|
||||
|
||||
# because PRAAT classifies frequencies in Pitch objects <=0 as "voiceless" and
|
||||
# therefore parts with extreme INTENSITIES would be considered as "voiceless"
|
||||
# (irrelevant) after "Subtract linear fit" (1)
|
||||
# "1" is added to the original Pa-values (ranged from 0 to 1)
|
||||
select Matrix atrem_nlc
|
||||
Formula... self+1
|
||||
|
||||
# because PRAAT only runs "Subtract linear fit" if the last frame is "voiceless"...?(2)
|
||||
Set value... 1 numbOfPoints_neu+1 0
|
||||
|
||||
# remove the linear amp.-trend (amplitude declination)
|
||||
#Formula... self*1000; better for viewing
|
||||
To Pitch
|
||||
Rename... hilf_lincorr
|
||||
Subtract linear fit... Hertz
|
||||
Rename... atrem
|
||||
|
||||
# undo (1)...
|
||||
To Matrix
|
||||
Formula... self-1
|
||||
|
||||
# normalize Amp. contour by mean Amp.
|
||||
Formula... (self-am_Int)/am_Int
|
||||
|
||||
# remove last frame, undo (2)
|
||||
Create Matrix... atrem_besser 0 slength numbOfPoints_neu ts t_hiframe1 1 1 1 1 1 0
|
||||
for point_neu from 1 to numbOfPoints_neu
|
||||
select Matrix atrem
|
||||
spring = Get value in cell... 1 point_neu
|
||||
select Matrix atrem_besser
|
||||
Set value... 1 point_neu spring
|
||||
endfor
|
||||
|
||||
# to calculate autocorrelation (cc-method)
|
||||
To Sound (slice)... 1
|
||||
# calculate Frequency of Ampitude Tremor [Hz]
|
||||
To Pitch (cc)... slength minTr 15 yes 0.01 tremthresh 0.01 0.35 0.14 maxTr
|
||||
Rename... atrem_norm
|
||||
|
||||
atrf = Get mean... 0 0 Hertz
|
||||
|
||||
# calculate Intensity Index of Amplitude Tremor [%]
|
||||
select Sound atrem_besser
|
||||
plus Pitch atrem_norm
|
||||
To PointProcess (peaks)... yes no
|
||||
Rename... Maxima
|
||||
numberofMaxPoints = Get number of points
|
||||
atri_max = 0
|
||||
noAMax = 0
|
||||
for iPoint from 1 to numberofMaxPoints
|
||||
select PointProcess Maxima
|
||||
ti = Get time from index... iPoint
|
||||
select Sound atrem_besser
|
||||
atri_Point = Get value at time... 0 ti Sinc70
|
||||
if atri_Point = undefined
|
||||
atri_Point = 0
|
||||
noAMax += 1
|
||||
endif
|
||||
atri_max += abs(atri_Point)
|
||||
endfor
|
||||
|
||||
select Sound atrem_besser
|
||||
plus PointProcess Maxima
|
||||
#Edit
|
||||
#pause
|
||||
|
||||
# atri_max:= (mean) procentual deviation of Amp. maxima from mean Amp.[Pa] at atrf
|
||||
numberofMaxima = numberofMaxPoints - noAMax
|
||||
atri_max = 100 * atri_max / numberofMaxima
|
||||
|
||||
select Sound atrem_besser
|
||||
plus Pitch atrem_norm
|
||||
To PointProcess (peaks)... no yes
|
||||
Rename... Minima
|
||||
numberofMinPoints = Get number of points
|
||||
atri_min = 0
|
||||
noAMin = 0
|
||||
for iPoint from 1 to numberofMinPoints
|
||||
select PointProcess Minima
|
||||
ti = Get time from index... iPoint
|
||||
select Sound atrem_besser
|
||||
atri_Point = Get value at time... 0 ti Sinc70
|
||||
if atri_Point = undefined
|
||||
atri_Point = 0
|
||||
noAMin += 1
|
||||
endif
|
||||
atri_min += abs(atri_Point)
|
||||
endfor
|
||||
|
||||
select Sound atrem_besser
|
||||
plus PointProcess Minima
|
||||
#Edit
|
||||
#pause
|
||||
|
||||
# atri_min:= (mean) procentual deviation of Amp. minima from mean Amp.[Pa] at atrf
|
||||
numberofMinima = numberofMinPoints - noAMin
|
||||
atri_min = 100 * atri_min / numberofMinima
|
||||
|
||||
atri = (atri_max + atri_min) / 2
|
||||
|
||||
atrp = atri * atrf/(atrf+1)
|
||||
|
||||
# uncomment to inspect amplitude tremor objects:
|
||||
# pause
|
||||
|
||||
select Pitch 'name$'
|
||||
plus PointProcess 'name$'_'name$'
|
||||
plus AmplitudeTier 'name$'_'name$'_'name$'
|
||||
plus TableOfReal 'name$'_'name$'_'name$'
|
||||
plus Matrix atrem_nlc
|
||||
plus Pitch atrem_nlc
|
||||
plus Pitch hilf_lincorr
|
||||
plus Pitch atrem
|
||||
plus Matrix atrem
|
||||
plus Matrix atrem_besser
|
||||
plus Sound atrem_besser
|
||||
plus Pitch atrem_norm
|
||||
plus PointProcess Maxima
|
||||
plus PointProcess Minima
|
||||
Remove
|
||||
endproc
|
||||
Reference in New Issue
Block a user