MontrealCorpusTools / PolyglotDB

Language data store and linguistic query API
MIT License
36 stars 13 forks source link

Point formant measurement and refinement functions not accessible as attributes of CorpusContext objects #165

Closed soskuthy closed 2 years ago

soskuthy commented 2 years ago

The following code from the tutorial throws an error:

with CorpusContext(config) as c:
      c.analyze_formant_points()

  File "<stdin>", line 1, in <module>
  File "<string>", line 2, in <module>
  File "/usr/local/lib/python3.9/site-packages/polyglotdb-1.2.0a1-py3.9.egg/polyglotdb/corpus/base.py", line 217, in __getattr__
    raise (GraphQueryError(
polyglotdb.exceptions.GraphQueryError: The graph does not have any annotations of type 'analyze_formant_points'.  Possible types are: phone, syllable, utterance, word

When I check the attributes of CorpusContext(config), the list does not include analyze_formant_points, analyze_formant_points_refinement or analyze_formant_tracks_refinement (but it does include analyze_formant_tracks). I can, however, run the formant analysis as follows:

from polyglotdb.acoustics.formants.base import analyze_formant_points
from polyglotdb.acoustics.formants.helper import save_formant_point_data

with CorpusContext('taiwanese_mandarin') as c:
    c.config.praat_path = "/Applications/Praat.app/Contents/MacOS/Praat"
    save_formant_point_data(c, analyze_formant_points(c))

Note also that I have to manually save the output of the formant measurement algorithm using save_formant_point_data(). That is not the case for analyze_formant_points_refinement(), which automatically adds them as phone-level annotations (in fact, I can see that save_formant_point_data() is called from within that function):

from polyglotdb.acoustics.formants.refined import analyze_formant_points_refinement

with CorpusContext('taiwanese_mandarin') as c:
    c.config.praat_path = "/Applications/Praat.app/Contents/MacOS/Praat"
    analyze_formant_points_refinement(c)

Sorry, this may be two separate issues, and I'm not sure if it's a bug or if I'm not doing sth as intended – but thought it's worth flagging!

mmcauliffe commented 2 years ago

Updated it with the recent release to add the function to CorpusContext, so both of these should be fixed now.