Skip to content

Commit

Permalink
doc: add parse stream example
Browse files Browse the repository at this point in the history
  • Loading branch information
rolandomunoz committed Nov 19, 2022
1 parent fc0fd0e commit 365f80e
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion docs/source/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ A TextGrid is hierarchical structured. It contains one or more tiers, which at t
Reading a TextGrid file
-----------------------

To read a TextGrid file you can use the function ``mytextgrid.read_from_file()``. This returns a ``TextGrid`` object.
To read a TextGrid file you can use the function ``mytextgrid.read_from_file()``.
This returns a ``TextGrid`` object.

.. code-block:: python
Expand All @@ -42,6 +43,22 @@ To read a TextGrid file you can use the function ``mytextgrid.read_from_file()``
>>> path = r'C:\Users\rolan\Documents\projects\sentence1.TextGrid'
>>> tg = mytextgrid.read_from_file(path)
You can also use ``mytextgrid.read_from_stream()`` which accepts a `str` or
file-like object.

.. code-block:: python
>>> import mytextgrid
>>> path = r'C:\Users\rolan\Documents\projects\sentence1.TextGrid'
>>> with open(textgrid_path, encoding = 'utf-8') as textfile:
>>> tg = mytextgrid.read_from_stream(textfile)
>>> with open(textgrid_path, encoding = 'utf-8') as textfile:
>>> text = textfile.read()
>>> tg = mytextgrid.read_from_stream(text)
.. warning::

TextGrid files come in `three formats`_: long, short and binary. At this moment, only the long format is supported.
Expand Down

0 comments on commit 365f80e

Please sign in to comment.