Mercurial > hg > auditok
changeset 333:6fc2d27bd2ef
Shorten long lines
author | Amine Sehili <amine.sehili@gmail.com> |
---|---|
date | Fri, 25 Oct 2019 20:23:51 +0100 |
parents | 445d8bf27cf2 |
children | f7cbf707a34e |
files | auditok/core.py auditok/dataset.py auditok/util.py |
diffstat | 3 files changed, 29 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/auditok/core.py Thu Oct 24 20:56:13 2019 +0100 +++ b/auditok/core.py Fri Oct 25 20:23:51 2019 +0100 @@ -441,7 +441,8 @@ if input is None: if max_read is None or max_read < 0: raise ValueError( - "'max_read' should not be None when reading from microphone" + "'max_read' should not be None when reading from " + "microphone" ) if skip > 0: raise ValueError( @@ -855,8 +856,8 @@ `init_max_silence` : *(int, default=0)* Maximum number of tolerated consecutive non-valid frames if the - number already gathered valid frames has not yet reached 'init_min'. - This argument is normally used if `init_min` is used. + number already gathered valid frames has not yet reached + 'init_min'.This argument is normally used if `init_min` is used. **Default = 0**, by default this argument is not taken into consideration. @@ -884,7 +885,9 @@ .. code:: python - from auditok import StreamTokenizer, StringDataSource, DataValidator + from auditok import (StreamTokenizer, + StringDataSource, + DataValidator) class UpperCaseChecker(DataValidator): def is_valid(self, frame): @@ -939,10 +942,10 @@ truncated at a non-valid but tolerated frame (`max_length` is reached but `max_continuous_silence` not yet) any tailing silence will be kept because it can potentially be part of valid token (if `max_length` was - bigger). But if `max_continuous_silence` is reached before `max_length`, - the delivered token will not be considered as truncated but a result of - *normal* end of detection (i.e. no more valid data). In that case the - tariling silence can be removed if you use the + bigger). But if `max_continuous_silence` is reached before + `max_length`, the delivered token will not be considered as truncated + but a result of *normal* end of detection (i.e. no more valid data). + In that case the tariling silence can be removed if you use the `StreamTokenizer.DROP_TRAILING_SILENCE` mode. :Example: @@ -1009,7 +1012,8 @@ self._is_valid = validator.is_valid else: raise TypeError( - "'validator' must be a callable or an instance of DataValidator" + "'validator' must be a callable or an instance of " + "DataValidator" ) if max_length <= 0: @@ -1077,7 +1081,8 @@ def tokenize(self, data_source, callback=None, generator=False): """ Read data from `data_source`, one frame a time, and process the read - frames in order to detect sequences of frames that make up valid tokens. + frames in order to detect sequences of frames that make up valid + tokens. :Parameters: `data_source` : instance of the :class:`DataSource` class that
--- a/auditok/dataset.py Thu Oct 24 20:56:13 2019 +0100 +++ b/auditok/dataset.py Fri Oct 25 20:23:51 2019 +0100 @@ -1,5 +1,5 @@ """ -This module contains links to audio files you can use for test purposes. +This module contains links to audio files that can be used for test purposes. """ import os @@ -22,4 +22,5 @@ silence.wav".format( cd=_current_dir, sep=os.path.sep ) -""" A wave file that contains a sentence between long leading and trailing periods of silence""" +"""A wave file that contains a sentence between long leading and trailing +periods of silence"""
--- a/auditok/util.py Thu Oct 24 20:56:13 2019 +0100 +++ b/auditok/util.py Fri Oct 25 20:23:51 2019 +0100 @@ -78,13 +78,15 @@ return partial(signal.separate_channels, fmt=fmt, channels=channels) raise ValueError( - "Selected channel must be an integer, None (alias 'any') or 'average' (alias 'avg' or 'mix')" + "Selected channel must be an integer, None (alias 'any') or 'average' " + "(alias 'avg' or 'mix')" ) class DataSource(ABC): """ - Base class for objects passed to :func:`auditok.core.StreamTokenizer.tokenize`. + Base class for objects passed to + :func:`auditok.core.StreamTokenizer.tokenize`. Subclasses should implement a :func:`DataSource.read` method. """ @@ -98,8 +100,8 @@ class DataValidator(ABC): """ - Base class for a validator object used by :class:`.core.StreamTokenizer` to check - if read data is valid. + Base class for a validator object used by :class:`.core.StreamTokenizer` + to check if read data is valid. Subclasses should implement :func:`is_valid` method. """ @@ -132,8 +134,9 @@ class StringDataSource(DataSource): """ A class that represent a :class:`DataSource` as a string buffer. - Each call to :func:`DataSource.read` returns on character and moves one step forward. - If the end of the buffer is reached, :func:`read` returns None. + Each call to :func:`DataSource.read` returns on character and moves one + step forward. If the end of the buffer is reached, :func:`read` returns + None. :Parameters: @@ -276,8 +279,8 @@ if "frames_per_buffer" in kwargs and "fbb" in kwargs: raise DuplicateArgument( - "Either 'frames_per_buffer' or 'fpb' must be specified, not \ - both" + "Either 'frames_per_buffer' or 'fpb' must be specified, not " + "both" ) if "sampling_rate" in kwargs and "sr" in kwargs: