Skip to content

Commit

Permalink
Fixed handling of too few measurements for remeasurement, and turned …
Browse files Browse the repository at this point in the history
…off some debugging messages
  • Loading branch information
JoFrhwld committed Nov 5, 2013
1 parent 6daff5f commit d4c2f4f
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions FAVE-extract/bin/remeasure.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def excludeOutliers(vowels, vowelMeans, vowelCovs):
"""
Finds outliers and excludes them.
"""
sys.stderr.write("Excluding outlying vowels...")
# sys.stderr.write("Excluding outlying vowels...")
outvowels = {}
for vowel in vowels:
if vowel in vowelCovs:
Expand Down Expand Up @@ -142,9 +142,9 @@ def pruneVowels(vowels, vowel, vowelMeans, vowelCovs, outlie):
def calculateVowelMeans(vowels):
"""
calculates [means] and [covariance matrices] for each vowel class.
It returns these as R objects in dictionaries indexed by the vowel class.
It returns these as numpy arrays in dictionaries indexed by the vowel class.
"""
sys.stderr.write("Calculating vowel means...")
#sys.stderr.write("Calculating vowel means...")
vowelMeans = {}
vowelCovs = {}
for vowel in vowels:
Expand All @@ -156,9 +156,10 @@ def calculateVowelMeans(vowels):


vowelMeans[vowel] = np.array([vF1.mean(), vF2.mean(), vB1.mean(), vB2.mean(), vDur.mean()])
vowel_cov = np.cov(np.vstack((vF1, vF2, vB1, vB2, vDur)))
if linalg.det(vowel_cov) != 0:
vowelCovs[vowel] = linalg.inv(vowel_cov)
if vF1.shape[0] >= 7:
vowel_cov = np.cov(np.vstack((vF1, vF2, vB1, vB2, vDur)))
if linalg.det(vowel_cov) != 0:
vowelCovs[vowel] = linalg.inv(vowel_cov)
#sys.stderr.write("Vowel means calculated\n")
return vowelMeans, vowelCovs

Expand All @@ -172,7 +173,7 @@ def repredictF1F2(measurements, vowelMeans, vowelCovs, vowels):
"""
Predicts F1 and F2 from the speaker's own vowel distributions based on the mahalanobis distance.
"""
print "\nREMEASURING..."
#print "\nREMEASURING..."
remeasurements = []
for vm in measurements:

Expand Down

0 comments on commit d4c2f4f

Please sign in to comment.