Skip to content

Commit

Permalink
Use crowsetta.example not crowsetta.data in doc/index.md
Browse files Browse the repository at this point in the history
  • Loading branch information
NickleDave committed Oct 12, 2024
1 parent d10d02b commit a4827d6
Showing 1 changed file with 9 additions and 19 deletions.
28 changes: 9 additions & 19 deletions doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -159,20 +159,10 @@ and {ref}`Raven .txt files <raven>`.

Here is an example of loading an example {ref}`Praat .TextGrid <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)}"
)
Expand All @@ -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`)")
```

Expand Down Expand Up @@ -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 = []
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit a4827d6

Please sign in to comment.