From a4827d6b156a6062cfa8bedc766586487e616e25 Mon Sep 17 00:00:00 2001 From: David Nicholson Date: Fri, 11 Oct 2024 21:47:50 -0400 Subject: [PATCH] Use crowsetta.example not crowsetta.data in doc/index.md --- doc/index.md | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/doc/index.md b/doc/index.md index 6dff52d..f299157 100644 --- a/doc/index.md +++ b/doc/index.md @@ -4,7 +4,7 @@ jupytext: extension: .md format_name: myst format_version: 0.13 - jupytext_version: 1.14.5 + jupytext_version: 1.16.4 kernelspec: display_name: Python 3 (ipykernel) language: python @@ -159,20 +159,10 @@ and {ref}`Raven .txt files `. Here is an example of loading an example {ref}`Praat .TextGrid ` file: -```{code-cell} ipython3 -:tags: [remove-cell] - -# We make the `user_data_dir` directory ahead of time -# to avoid triggering a call to `input` prompting the user if it's ok -# to make that directory -import crowsetta -crowsetta.data.extract_data_files() -``` - ```{code-cell} ipython3 import crowsetta -example = crowsetta.data.get('textgrid') -a_textgrid = crowsetta.formats.seq.TextGrid.from_file(example.annot_path) +path = crowsetta.example('textgrid', return_path=True) +a_textgrid = crowsetta.formats.seq.TextGrid.from_file(path) print( f"`a_textgrid` is a {type(a_textgrid)}" ) @@ -187,8 +177,8 @@ each format can also be referred to by a shorthand string name: ```{code-cell} ipython3 import crowsetta -example = crowsetta.data.get('textgrid') -a_textgrid = crowsetta.formats.by_name('textgrid').from_file(example.annot_path) +path = crowsetta.example('textgrid', return_path=True) +a_textgrid = crowsetta.formats.by_name('textgrid').from_file(path) print(f"`a_textgrid` is a {type(a_textgrid)} (even when we load it with `formats.by_name`)") ``` @@ -261,9 +251,9 @@ import numpy as np import crowsetta # load an example annotation file -example = crowsetta.data.get('birdsong-recognition-dataset') +path = crowsetta.example('Annotation.xml', return_path=True) # in the next line we use the class, to make it absolutely clear which format we are working with -birdsongrec = crowsetta.formats.seq.BirdsongRec.from_file(example.annot_path) +birdsongrec = crowsetta.formats.seq.BirdsongRec.from_file(path) annots = birdsongrec.to_annot() # returns a list of `crowsetta.Annotation`s syllables_spects = [] @@ -297,8 +287,8 @@ a csv file. ```{code-cell} ipython3 import crowsetta -example = crowsetta.data.get('birdsong-recognition-dataset') -birdsongrec = crowsetta.formats.by_name('birdsong-recognition-dataset').from_file(example.annot_path) +path = crowsetta.example('Annotation.xml', return_path=True) +birdsongrec = crowsetta.formats.by_name('birdsong-recognition-dataset').from_file(path) annots = birdsongrec.to_annot(samplerate=32000) # returns a list of `crowsetta.Annotation`s # the 'generic-seq' format can write csv files from `Annotation`s with `Sequence`s. generic_seq = crowsetta.formats.by_name('generic-seq')(annots=annots)