repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
tammoippen/iso4217parse | iso4217parse/__init__.py | parse | def parse(v, country_code=None):
"""Try parse `v` to currencies; filter by country_code
If `v` is a number, try `by_code_num()`; otherwise try:
1) if `v` is 3 character uppercase: `by_alpha3()`
2) Exact symbol match: `by_symbol()`
3) Exact country code match: `by_country()`
4) F... | python | def parse(v, country_code=None):
"""Try parse `v` to currencies; filter by country_code
If `v` is a number, try `by_code_num()`; otherwise try:
1) if `v` is 3 character uppercase: `by_alpha3()`
2) Exact symbol match: `by_symbol()`
3) Exact country code match: `by_country()`
4) F... | [
"def",
"parse",
"(",
"v",
",",
"country_code",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"v",
",",
"int",
")",
":",
"res",
"=",
"by_code_num",
"(",
"v",
")",
"return",
"[",
"]",
"if",
"not",
"res",
"else",
"[",
"res",
"]",
"if",
"not",
"i... | Try parse `v` to currencies; filter by country_code
If `v` is a number, try `by_code_num()`; otherwise try:
1) if `v` is 3 character uppercase: `by_alpha3()`
2) Exact symbol match: `by_symbol()`
3) Exact country code match: `by_country()`
4) Fuzzy by symbol match heuristic: `by_symb... | [
"Try",
"parse",
"v",
"to",
"currencies",
";",
"filter",
"by",
"country_code"
] | dd2971bd66e83424c43d16d6b54b3f6d0c4201cf | https://github.com/tammoippen/iso4217parse/blob/dd2971bd66e83424c43d16d6b54b3f6d0c4201cf/iso4217parse/__init__.py#L233-L275 | train |
moremoban/moban | moban/data_loaders/json_loader.py | open_json | def open_json(file_name):
"""
returns json contents as string
"""
with open(file_name, "r") as json_data:
data = json.load(json_data)
return data | python | def open_json(file_name):
"""
returns json contents as string
"""
with open(file_name, "r") as json_data:
data = json.load(json_data)
return data | [
"def",
"open_json",
"(",
"file_name",
")",
":",
"with",
"open",
"(",
"file_name",
",",
"\"r\"",
")",
"as",
"json_data",
":",
"data",
"=",
"json",
".",
"load",
"(",
"json_data",
")",
"return",
"data"
] | returns json contents as string | [
"returns",
"json",
"contents",
"as",
"string"
] | 5d1674ae461b065a9a54fe89c445cbf6d3cd63c0 | https://github.com/moremoban/moban/blob/5d1674ae461b065a9a54fe89c445cbf6d3cd63c0/moban/data_loaders/json_loader.py#L9-L15 | train |
moremoban/moban | moban/utils.py | merge | def merge(left, right):
"""
deep merge dictionary on the left with the one
on the right.
Fill in left dictionary with right one where
the value of the key from the right one in
the left one is missing or None.
"""
if isinstance(left, dict) and isinstance(right, dict):
for key, v... | python | def merge(left, right):
"""
deep merge dictionary on the left with the one
on the right.
Fill in left dictionary with right one where
the value of the key from the right one in
the left one is missing or None.
"""
if isinstance(left, dict) and isinstance(right, dict):
for key, v... | [
"def",
"merge",
"(",
"left",
",",
"right",
")",
":",
"if",
"isinstance",
"(",
"left",
",",
"dict",
")",
"and",
"isinstance",
"(",
"right",
",",
"dict",
")",
":",
"for",
"key",
",",
"value",
"in",
"right",
".",
"items",
"(",
")",
":",
"if",
"key",... | deep merge dictionary on the left with the one
on the right.
Fill in left dictionary with right one where
the value of the key from the right one in
the left one is missing or None. | [
"deep",
"merge",
"dictionary",
"on",
"the",
"left",
"with",
"the",
"one",
"on",
"the",
"right",
"."
] | 5d1674ae461b065a9a54fe89c445cbf6d3cd63c0 | https://github.com/moremoban/moban/blob/5d1674ae461b065a9a54fe89c445cbf6d3cd63c0/moban/utils.py#L13-L30 | train |
smira/txZMQ | txzmq/factory.py | ZmqFactory.shutdown | def shutdown(self):
"""
Shutdown factory.
This is shutting down all created connections
and terminating ZeroMQ context. Also cleans up
Twisted reactor.
"""
for connection in self.connections.copy():
connection.shutdown()
self.connections = No... | python | def shutdown(self):
"""
Shutdown factory.
This is shutting down all created connections
and terminating ZeroMQ context. Also cleans up
Twisted reactor.
"""
for connection in self.connections.copy():
connection.shutdown()
self.connections = No... | [
"def",
"shutdown",
"(",
"self",
")",
":",
"for",
"connection",
"in",
"self",
".",
"connections",
".",
"copy",
"(",
")",
":",
"connection",
".",
"shutdown",
"(",
")",
"self",
".",
"connections",
"=",
"None",
"self",
".",
"context",
".",
"term",
"(",
"... | Shutdown factory.
This is shutting down all created connections
and terminating ZeroMQ context. Also cleans up
Twisted reactor. | [
"Shutdown",
"factory",
"."
] | a2b3caf7884eb68ad952f8db0c07ab5bd88949e7 | https://github.com/smira/txZMQ/blob/a2b3caf7884eb68ad952f8db0c07ab5bd88949e7/txzmq/factory.py#L44-L63 | train |
smira/txZMQ | txzmq/pubsub.py | ZmqPubConnection.publish | def publish(self, message, tag=b''):
"""
Publish `message` with specified `tag`.
:param message: message data
:type message: str
:param tag: message tag
:type tag: str
"""
self.send(tag + b'\0' + message) | python | def publish(self, message, tag=b''):
"""
Publish `message` with specified `tag`.
:param message: message data
:type message: str
:param tag: message tag
:type tag: str
"""
self.send(tag + b'\0' + message) | [
"def",
"publish",
"(",
"self",
",",
"message",
",",
"tag",
"=",
"b''",
")",
":",
"self",
".",
"send",
"(",
"tag",
"+",
"b'\\0'",
"+",
"message",
")"
] | Publish `message` with specified `tag`.
:param message: message data
:type message: str
:param tag: message tag
:type tag: str | [
"Publish",
"message",
"with",
"specified",
"tag",
"."
] | a2b3caf7884eb68ad952f8db0c07ab5bd88949e7 | https://github.com/smira/txZMQ/blob/a2b3caf7884eb68ad952f8db0c07ab5bd88949e7/txzmq/pubsub.py#L17-L26 | train |
smira/txZMQ | txzmq/req_rep.py | ZmqREQConnection._getNextId | def _getNextId(self):
"""
Returns an unique id.
By default, generates pool of UUID in increments
of ``UUID_POOL_GEN_SIZE``. Could be overridden to
provide custom ID generation.
:return: generated unique "on the wire" message ID
:rtype: str
"""
if... | python | def _getNextId(self):
"""
Returns an unique id.
By default, generates pool of UUID in increments
of ``UUID_POOL_GEN_SIZE``. Could be overridden to
provide custom ID generation.
:return: generated unique "on the wire" message ID
:rtype: str
"""
if... | [
"def",
"_getNextId",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_uuids",
":",
"for",
"_",
"in",
"range",
"(",
"self",
".",
"UUID_POOL_GEN_SIZE",
")",
":",
"self",
".",
"_uuids",
".",
"append",
"(",
"uuid",
".",
"uuid4",
"(",
")",
".",
"bytes... | Returns an unique id.
By default, generates pool of UUID in increments
of ``UUID_POOL_GEN_SIZE``. Could be overridden to
provide custom ID generation.
:return: generated unique "on the wire" message ID
:rtype: str | [
"Returns",
"an",
"unique",
"id",
"."
] | a2b3caf7884eb68ad952f8db0c07ab5bd88949e7 | https://github.com/smira/txZMQ/blob/a2b3caf7884eb68ad952f8db0c07ab5bd88949e7/txzmq/req_rep.py#L48-L62 | train |
smira/txZMQ | txzmq/req_rep.py | ZmqREQConnection._releaseId | def _releaseId(self, msgId):
"""
Release message ID to the pool.
@param msgId: message ID, no longer on the wire
@type msgId: C{str}
"""
self._uuids.append(msgId)
if len(self._uuids) > 2 * self.UUID_POOL_GEN_SIZE:
self._uuids[-self.UUID_POOL_GEN_SIZE:... | python | def _releaseId(self, msgId):
"""
Release message ID to the pool.
@param msgId: message ID, no longer on the wire
@type msgId: C{str}
"""
self._uuids.append(msgId)
if len(self._uuids) > 2 * self.UUID_POOL_GEN_SIZE:
self._uuids[-self.UUID_POOL_GEN_SIZE:... | [
"def",
"_releaseId",
"(",
"self",
",",
"msgId",
")",
":",
"self",
".",
"_uuids",
".",
"append",
"(",
"msgId",
")",
"if",
"len",
"(",
"self",
".",
"_uuids",
")",
">",
"2",
"*",
"self",
".",
"UUID_POOL_GEN_SIZE",
":",
"self",
".",
"_uuids",
"[",
"-",... | Release message ID to the pool.
@param msgId: message ID, no longer on the wire
@type msgId: C{str} | [
"Release",
"message",
"ID",
"to",
"the",
"pool",
"."
] | a2b3caf7884eb68ad952f8db0c07ab5bd88949e7 | https://github.com/smira/txZMQ/blob/a2b3caf7884eb68ad952f8db0c07ab5bd88949e7/txzmq/req_rep.py#L64-L73 | train |
smira/txZMQ | txzmq/req_rep.py | ZmqREQConnection._cancel | def _cancel(self, msgId):
"""
Cancel outstanding REQ, drop reply silently.
@param msgId: message ID to cancel
@type msgId: C{str}
"""
_, canceller = self._requests.pop(msgId, (None, None))
if canceller is not None and canceller.active():
canceller.ca... | python | def _cancel(self, msgId):
"""
Cancel outstanding REQ, drop reply silently.
@param msgId: message ID to cancel
@type msgId: C{str}
"""
_, canceller = self._requests.pop(msgId, (None, None))
if canceller is not None and canceller.active():
canceller.ca... | [
"def",
"_cancel",
"(",
"self",
",",
"msgId",
")",
":",
"_",
",",
"canceller",
"=",
"self",
".",
"_requests",
".",
"pop",
"(",
"msgId",
",",
"(",
"None",
",",
"None",
")",
")",
"if",
"canceller",
"is",
"not",
"None",
"and",
"canceller",
".",
"active... | Cancel outstanding REQ, drop reply silently.
@param msgId: message ID to cancel
@type msgId: C{str} | [
"Cancel",
"outstanding",
"REQ",
"drop",
"reply",
"silently",
"."
] | a2b3caf7884eb68ad952f8db0c07ab5bd88949e7 | https://github.com/smira/txZMQ/blob/a2b3caf7884eb68ad952f8db0c07ab5bd88949e7/txzmq/req_rep.py#L75-L85 | train |
smira/txZMQ | txzmq/req_rep.py | ZmqREQConnection._timeoutRequest | def _timeoutRequest(self, msgId):
"""
Cancel timedout request.
@param msgId: message ID to cancel
@type msgId: C{str}
"""
d, _ = self._requests.pop(msgId, (None, None))
if not d.called:
d.errback(ZmqRequestTimeoutError(msgId)) | python | def _timeoutRequest(self, msgId):
"""
Cancel timedout request.
@param msgId: message ID to cancel
@type msgId: C{str}
"""
d, _ = self._requests.pop(msgId, (None, None))
if not d.called:
d.errback(ZmqRequestTimeoutError(msgId)) | [
"def",
"_timeoutRequest",
"(",
"self",
",",
"msgId",
")",
":",
"d",
",",
"_",
"=",
"self",
".",
"_requests",
".",
"pop",
"(",
"msgId",
",",
"(",
"None",
",",
"None",
")",
")",
"if",
"not",
"d",
".",
"called",
":",
"d",
".",
"errback",
"(",
"Zmq... | Cancel timedout request.
@param msgId: message ID to cancel
@type msgId: C{str} | [
"Cancel",
"timedout",
"request",
"."
] | a2b3caf7884eb68ad952f8db0c07ab5bd88949e7 | https://github.com/smira/txZMQ/blob/a2b3caf7884eb68ad952f8db0c07ab5bd88949e7/txzmq/req_rep.py#L87-L95 | train |
smira/txZMQ | txzmq/req_rep.py | ZmqREQConnection.sendMsg | def sendMsg(self, *messageParts, **kwargs):
"""
Send request and deliver response back when available.
:param messageParts: message data
:type messageParts: tuple
:param timeout: as keyword argument, timeout on request
:type timeout: float
:return: Deferred that ... | python | def sendMsg(self, *messageParts, **kwargs):
"""
Send request and deliver response back when available.
:param messageParts: message data
:type messageParts: tuple
:param timeout: as keyword argument, timeout on request
:type timeout: float
:return: Deferred that ... | [
"def",
"sendMsg",
"(",
"self",
",",
"*",
"messageParts",
",",
"**",
"kwargs",
")",
":",
"messageId",
"=",
"self",
".",
"_getNextId",
"(",
")",
"d",
"=",
"defer",
".",
"Deferred",
"(",
"canceller",
"=",
"lambda",
"_",
":",
"self",
".",
"_cancel",
"(",... | Send request and deliver response back when available.
:param messageParts: message data
:type messageParts: tuple
:param timeout: as keyword argument, timeout on request
:type timeout: float
:return: Deferred that will fire when response comes back | [
"Send",
"request",
"and",
"deliver",
"response",
"back",
"when",
"available",
"."
] | a2b3caf7884eb68ad952f8db0c07ab5bd88949e7 | https://github.com/smira/txZMQ/blob/a2b3caf7884eb68ad952f8db0c07ab5bd88949e7/txzmq/req_rep.py#L97-L122 | train |
smira/txZMQ | txzmq/req_rep.py | ZmqREPConnection.reply | def reply(self, messageId, *messageParts):
"""
Send reply to request with specified ``messageId``.
:param messageId: message uuid
:type messageId: str
:param messageParts: message data
:type messageParts: list
"""
routingInfo = self._routingInfo.pop(messa... | python | def reply(self, messageId, *messageParts):
"""
Send reply to request with specified ``messageId``.
:param messageId: message uuid
:type messageId: str
:param messageParts: message data
:type messageParts: list
"""
routingInfo = self._routingInfo.pop(messa... | [
"def",
"reply",
"(",
"self",
",",
"messageId",
",",
"*",
"messageParts",
")",
":",
"routingInfo",
"=",
"self",
".",
"_routingInfo",
".",
"pop",
"(",
"messageId",
")",
"self",
".",
"send",
"(",
"routingInfo",
"+",
"[",
"messageId",
",",
"b''",
"]",
"+",... | Send reply to request with specified ``messageId``.
:param messageId: message uuid
:type messageId: str
:param messageParts: message data
:type messageParts: list | [
"Send",
"reply",
"to",
"request",
"with",
"specified",
"messageId",
"."
] | a2b3caf7884eb68ad952f8db0c07ab5bd88949e7 | https://github.com/smira/txZMQ/blob/a2b3caf7884eb68ad952f8db0c07ab5bd88949e7/txzmq/req_rep.py#L159-L169 | train |
ynop/audiomate | audiomate/corpus/io/base.py | CorpusReader.load | def load(self, path):
"""
Load and return the corpus from the given path.
Args:
path (str): Path to the data set to load.
Returns:
Corpus: The loaded corpus
Raises:
IOError: When the data set is invalid, for example because required files (a... | python | def load(self, path):
"""
Load and return the corpus from the given path.
Args:
path (str): Path to the data set to load.
Returns:
Corpus: The loaded corpus
Raises:
IOError: When the data set is invalid, for example because required files (a... | [
"def",
"load",
"(",
"self",
",",
"path",
")",
":",
"missing_files",
"=",
"self",
".",
"_check_for_missing_files",
"(",
"path",
")",
"if",
"len",
"(",
"missing_files",
")",
">",
"0",
":",
"raise",
"IOError",
"(",
"'Invalid data set of type {}: files {} not found ... | Load and return the corpus from the given path.
Args:
path (str): Path to the data set to load.
Returns:
Corpus: The loaded corpus
Raises:
IOError: When the data set is invalid, for example because required files (annotations, …) are missing. | [
"Load",
"and",
"return",
"the",
"corpus",
"from",
"the",
"given",
"path",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/corpus/io/base.py#L61-L81 | train |
ynop/audiomate | audiomate/corpus/io/tuda.py | TudaReader.get_ids_from_folder | def get_ids_from_folder(path, part_name):
"""
Return all ids from the given folder, which have a corresponding beamformedSignal file.
"""
valid_ids = set({})
for xml_file in glob.glob(os.path.join(path, '*.xml')):
idx = os.path.splitext(os.path.basename(xml_file))[0]... | python | def get_ids_from_folder(path, part_name):
"""
Return all ids from the given folder, which have a corresponding beamformedSignal file.
"""
valid_ids = set({})
for xml_file in glob.glob(os.path.join(path, '*.xml')):
idx = os.path.splitext(os.path.basename(xml_file))[0]... | [
"def",
"get_ids_from_folder",
"(",
"path",
",",
"part_name",
")",
":",
"valid_ids",
"=",
"set",
"(",
"{",
"}",
")",
"for",
"xml_file",
"in",
"glob",
".",
"glob",
"(",
"os",
".",
"path",
".",
"join",
"(",
"path",
",",
"'*.xml'",
")",
")",
":",
"idx"... | Return all ids from the given folder, which have a corresponding beamformedSignal file. | [
"Return",
"all",
"ids",
"from",
"the",
"given",
"folder",
"which",
"have",
"a",
"corresponding",
"beamformedSignal",
"file",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/corpus/io/tuda.py#L152-L164 | train |
ynop/audiomate | audiomate/corpus/io/tuda.py | TudaReader.load_file | def load_file(folder_path, idx, corpus):
"""
Load speaker, file, utterance, labels for the file with the given id.
"""
xml_path = os.path.join(folder_path, '{}.xml'.format(idx))
wav_paths = glob.glob(os.path.join(folder_path, '{}_*.wav'.format(idx)))
if len(wav_paths) ==... | python | def load_file(folder_path, idx, corpus):
"""
Load speaker, file, utterance, labels for the file with the given id.
"""
xml_path = os.path.join(folder_path, '{}.xml'.format(idx))
wav_paths = glob.glob(os.path.join(folder_path, '{}_*.wav'.format(idx)))
if len(wav_paths) ==... | [
"def",
"load_file",
"(",
"folder_path",
",",
"idx",
",",
"corpus",
")",
":",
"xml_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"folder_path",
",",
"'{}.xml'",
".",
"format",
"(",
"idx",
")",
")",
"wav_paths",
"=",
"glob",
".",
"glob",
"(",
"os",
... | Load speaker, file, utterance, labels for the file with the given id. | [
"Load",
"speaker",
"file",
"utterance",
"labels",
"for",
"the",
"file",
"with",
"the",
"given",
"id",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/corpus/io/tuda.py#L167-L227 | train |
ynop/audiomate | audiomate/formats/ctm.py | read_file | def read_file(path):
"""
Reads a ctm file.
Args:
path (str): Path to the file
Returns:
(dict): Dictionary with entries.
Example::
>>> read_file('/path/to/file.txt')
{
'wave-ab': [
['1', 0.00, 0.07, 'HI', 1],
['1', 0.09, ... | python | def read_file(path):
"""
Reads a ctm file.
Args:
path (str): Path to the file
Returns:
(dict): Dictionary with entries.
Example::
>>> read_file('/path/to/file.txt')
{
'wave-ab': [
['1', 0.00, 0.07, 'HI', 1],
['1', 0.09, ... | [
"def",
"read_file",
"(",
"path",
")",
":",
"gen",
"=",
"textfile",
".",
"read_separated_lines_generator",
"(",
"path",
",",
"max_columns",
"=",
"6",
",",
"ignore_lines_starting_with",
"=",
"[",
"';;'",
"]",
")",
"utterances",
"=",
"collections",
".",
"defaultd... | Reads a ctm file.
Args:
path (str): Path to the file
Returns:
(dict): Dictionary with entries.
Example::
>>> read_file('/path/to/file.txt')
{
'wave-ab': [
['1', 0.00, 0.07, 'HI', 1],
['1', 0.09, 0.08, 'AH', 1]
],
... | [
"Reads",
"a",
"ctm",
"file",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/formats/ctm.py#L28-L66 | train |
ynop/audiomate | audiomate/corpus/subset/utils.py | split_identifiers | def split_identifiers(identifiers=[], proportions={}):
"""
Split the given identifiers by the given proportions.
Args:
identifiers (list): List of identifiers (str).
proportions (dict): A dictionary containing the proportions with the identifier from the
input as key.
Returns:
... | python | def split_identifiers(identifiers=[], proportions={}):
"""
Split the given identifiers by the given proportions.
Args:
identifiers (list): List of identifiers (str).
proportions (dict): A dictionary containing the proportions with the identifier from the
input as key.
Returns:
... | [
"def",
"split_identifiers",
"(",
"identifiers",
"=",
"[",
"]",
",",
"proportions",
"=",
"{",
"}",
")",
":",
"abs_proportions",
"=",
"absolute_proportions",
"(",
"proportions",
",",
"len",
"(",
"identifiers",
")",
")",
"parts",
"=",
"{",
"}",
"start_index",
... | Split the given identifiers by the given proportions.
Args:
identifiers (list): List of identifiers (str).
proportions (dict): A dictionary containing the proportions with the identifier from the
input as key.
Returns:
dict: Dictionary containing a list of identifiers per part ... | [
"Split",
"the",
"given",
"identifiers",
"by",
"the",
"given",
"proportions",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/corpus/subset/utils.py#L41-L72 | train |
ynop/audiomate | audiomate/corpus/subset/utils.py | select_balanced_subset | def select_balanced_subset(items, select_count, categories, select_count_values=None, seed=None):
"""
Select items so the summed category weights are balanced.
Each item has a dictionary containing the category weights.
Items are selected until ``select_count`` is reached.
The value that is added to... | python | def select_balanced_subset(items, select_count, categories, select_count_values=None, seed=None):
"""
Select items so the summed category weights are balanced.
Each item has a dictionary containing the category weights.
Items are selected until ``select_count`` is reached.
The value that is added to... | [
"def",
"select_balanced_subset",
"(",
"items",
",",
"select_count",
",",
"categories",
",",
"select_count_values",
"=",
"None",
",",
"seed",
"=",
"None",
")",
":",
"rand",
"=",
"random",
".",
"Random",
"(",
")",
"rand",
".",
"seed",
"(",
"seed",
")",
"if... | Select items so the summed category weights are balanced.
Each item has a dictionary containing the category weights.
Items are selected until ``select_count`` is reached.
The value that is added to ``select_count`` for an item can be defined in the dictionary ``select_count_values``.
If this is not def... | [
"Select",
"items",
"so",
"the",
"summed",
"category",
"weights",
"are",
"balanced",
".",
"Each",
"item",
"has",
"a",
"dictionary",
"containing",
"the",
"category",
"weights",
".",
"Items",
"are",
"selected",
"until",
"select_count",
"is",
"reached",
".",
"The"... | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/corpus/subset/utils.py#L176-L260 | train |
ynop/audiomate | audiomate/utils/misc.py | length_of_overlap | def length_of_overlap(first_start, first_end, second_start, second_end):
"""
Find the length of the overlapping part of two segments.
Args:
first_start (float): Start of the first segment.
first_end (float): End of the first segment.
second_start (float): Start of the second segment... | python | def length_of_overlap(first_start, first_end, second_start, second_end):
"""
Find the length of the overlapping part of two segments.
Args:
first_start (float): Start of the first segment.
first_end (float): End of the first segment.
second_start (float): Start of the second segment... | [
"def",
"length_of_overlap",
"(",
"first_start",
",",
"first_end",
",",
"second_start",
",",
"second_end",
")",
":",
"if",
"first_end",
"<=",
"second_start",
"or",
"first_start",
">=",
"second_end",
":",
"return",
"0.0",
"if",
"first_start",
"<",
"second_start",
... | Find the length of the overlapping part of two segments.
Args:
first_start (float): Start of the first segment.
first_end (float): End of the first segment.
second_start (float): Start of the second segment.
second_end (float): End of the second segment.
Return:
float: ... | [
"Find",
"the",
"length",
"of",
"the",
"overlapping",
"part",
"of",
"two",
"segments",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/utils/misc.py#L1-L27 | train |
ynop/audiomate | audiomate/annotations/relabeling.py | find_missing_projections | def find_missing_projections(label_list, projections):
"""
Finds all combinations of labels in `label_list` that are not covered by an entry in the dictionary of
`projections`. Returns a list containing tuples of uncovered label combinations or en empty list if there are none.
All uncovered label combin... | python | def find_missing_projections(label_list, projections):
"""
Finds all combinations of labels in `label_list` that are not covered by an entry in the dictionary of
`projections`. Returns a list containing tuples of uncovered label combinations or en empty list if there are none.
All uncovered label combin... | [
"def",
"find_missing_projections",
"(",
"label_list",
",",
"projections",
")",
":",
"unmapped_combinations",
"=",
"set",
"(",
")",
"if",
"WILDCARD_COMBINATION",
"in",
"projections",
":",
"return",
"[",
"]",
"for",
"labeled_segment",
"in",
"label_list",
".",
"range... | Finds all combinations of labels in `label_list` that are not covered by an entry in the dictionary of
`projections`. Returns a list containing tuples of uncovered label combinations or en empty list if there are none.
All uncovered label combinations are naturally sorted.
Each entry in the dictionary of p... | [
"Finds",
"all",
"combinations",
"of",
"labels",
"in",
"label_list",
"that",
"are",
"not",
"covered",
"by",
"an",
"entry",
"in",
"the",
"dictionary",
"of",
"projections",
".",
"Returns",
"a",
"list",
"containing",
"tuples",
"of",
"uncovered",
"label",
"combinat... | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/annotations/relabeling.py#L71-L110 | train |
ynop/audiomate | audiomate/annotations/relabeling.py | load_projections | def load_projections(projections_file):
"""
Loads projections defined in the given `projections_file`.
The `projections_file` is expected to be in the following format::
old_label_1 | new_label_1
old_label_1 old_label_2 | new_label_2
old_label_3 |
You can define one projection... | python | def load_projections(projections_file):
"""
Loads projections defined in the given `projections_file`.
The `projections_file` is expected to be in the following format::
old_label_1 | new_label_1
old_label_1 old_label_2 | new_label_2
old_label_3 |
You can define one projection... | [
"def",
"load_projections",
"(",
"projections_file",
")",
":",
"projections",
"=",
"{",
"}",
"for",
"parts",
"in",
"textfile",
".",
"read_separated_lines_generator",
"(",
"projections_file",
",",
"'|'",
")",
":",
"combination",
"=",
"tuple",
"(",
"sorted",
"(",
... | Loads projections defined in the given `projections_file`.
The `projections_file` is expected to be in the following format::
old_label_1 | new_label_1
old_label_1 old_label_2 | new_label_2
old_label_3 |
You can define one projection per line. Each projection starts with a list of one... | [
"Loads",
"projections",
"defined",
"in",
"the",
"given",
"projections_file",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/annotations/relabeling.py#L113-L148 | train |
ynop/audiomate | audiomate/corpus/subset/selection.py | SubsetGenerator.random_subset_by_duration | def random_subset_by_duration(self, relative_duration, balance_labels=False, label_list_ids=None):
"""
Create a subview of random utterances with a approximate duration relative to the full corpus.
Random utterances are selected so that the sum of all utterance durations
equals to the re... | python | def random_subset_by_duration(self, relative_duration, balance_labels=False, label_list_ids=None):
"""
Create a subview of random utterances with a approximate duration relative to the full corpus.
Random utterances are selected so that the sum of all utterance durations
equals to the re... | [
"def",
"random_subset_by_duration",
"(",
"self",
",",
"relative_duration",
",",
"balance_labels",
"=",
"False",
",",
"label_list_ids",
"=",
"None",
")",
":",
"total_duration",
"=",
"self",
".",
"corpus",
".",
"total_duration",
"subset_duration",
"=",
"relative_durat... | Create a subview of random utterances with a approximate duration relative to the full corpus.
Random utterances are selected so that the sum of all utterance durations
equals to the relative duration of the full corpus.
Args:
relative_duration (float): A value between 0 and 1. (e.g... | [
"Create",
"a",
"subview",
"of",
"random",
"utterances",
"with",
"a",
"approximate",
"duration",
"relative",
"to",
"the",
"full",
"corpus",
".",
"Random",
"utterances",
"are",
"selected",
"so",
"that",
"the",
"sum",
"of",
"all",
"utterance",
"durations",
"equal... | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/corpus/subset/selection.py#L62-L105 | train |
ynop/audiomate | audiomate/corpus/subset/selection.py | SubsetGenerator.random_subsets | def random_subsets(self, relative_sizes, by_duration=False, balance_labels=False, label_list_ids=None):
"""
Create a bunch of subsets with the given sizes relative to the size or duration of the full corpus.
Basically the same as calling ``random_subset`` or ``random_subset_by_duration`` multipl... | python | def random_subsets(self, relative_sizes, by_duration=False, balance_labels=False, label_list_ids=None):
"""
Create a bunch of subsets with the given sizes relative to the size or duration of the full corpus.
Basically the same as calling ``random_subset`` or ``random_subset_by_duration`` multipl... | [
"def",
"random_subsets",
"(",
"self",
",",
"relative_sizes",
",",
"by_duration",
"=",
"False",
",",
"balance_labels",
"=",
"False",
",",
"label_list_ids",
"=",
"None",
")",
":",
"resulting_sets",
"=",
"{",
"}",
"next_bigger_subset",
"=",
"self",
".",
"corpus",... | Create a bunch of subsets with the given sizes relative to the size or duration of the full corpus.
Basically the same as calling ``random_subset`` or ``random_subset_by_duration`` multiple times
with different values. But this method makes sure that every subset contains only utterances,
that a... | [
"Create",
"a",
"bunch",
"of",
"subsets",
"with",
"the",
"given",
"sizes",
"relative",
"to",
"the",
"size",
"or",
"duration",
"of",
"the",
"full",
"corpus",
".",
"Basically",
"the",
"same",
"as",
"calling",
"random_subset",
"or",
"random_subset_by_duration",
"m... | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/corpus/subset/selection.py#L107-L141 | train |
ynop/audiomate | audiomate/utils/text.py | remove_punctuation | def remove_punctuation(text, exceptions=[]):
"""
Return a string with punctuation removed.
Parameters:
text (str): The text to remove punctuation from.
exceptions (list): List of symbols to keep in the given text.
Return:
str: The input text without the punctuation.
"""
... | python | def remove_punctuation(text, exceptions=[]):
"""
Return a string with punctuation removed.
Parameters:
text (str): The text to remove punctuation from.
exceptions (list): List of symbols to keep in the given text.
Return:
str: The input text without the punctuation.
"""
... | [
"def",
"remove_punctuation",
"(",
"text",
",",
"exceptions",
"=",
"[",
"]",
")",
":",
"all_but",
"=",
"[",
"r'\\w'",
",",
"r'\\s'",
"]",
"all_but",
".",
"extend",
"(",
"exceptions",
")",
"pattern",
"=",
"'[^{}]'",
".",
"format",
"(",
"''",
".",
"join",... | Return a string with punctuation removed.
Parameters:
text (str): The text to remove punctuation from.
exceptions (list): List of symbols to keep in the given text.
Return:
str: The input text without the punctuation. | [
"Return",
"a",
"string",
"with",
"punctuation",
"removed",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/utils/text.py#L8-L29 | train |
ynop/audiomate | audiomate/utils/text.py | starts_with_prefix_in_list | def starts_with_prefix_in_list(text, prefixes):
"""
Return True if the given string starts with one of the prefixes in the given list, otherwise
return False.
Arguments:
text (str): Text to check for prefixes.
prefixes (list): List of prefixes to check for.
Returns:
bool: T... | python | def starts_with_prefix_in_list(text, prefixes):
"""
Return True if the given string starts with one of the prefixes in the given list, otherwise
return False.
Arguments:
text (str): Text to check for prefixes.
prefixes (list): List of prefixes to check for.
Returns:
bool: T... | [
"def",
"starts_with_prefix_in_list",
"(",
"text",
",",
"prefixes",
")",
":",
"for",
"prefix",
"in",
"prefixes",
":",
"if",
"text",
".",
"startswith",
"(",
"prefix",
")",
":",
"return",
"True",
"return",
"False"
] | Return True if the given string starts with one of the prefixes in the given list, otherwise
return False.
Arguments:
text (str): Text to check for prefixes.
prefixes (list): List of prefixes to check for.
Returns:
bool: True if the given text starts with any of the given prefixes,... | [
"Return",
"True",
"if",
"the",
"given",
"string",
"starts",
"with",
"one",
"of",
"the",
"prefixes",
"in",
"the",
"given",
"list",
"otherwise",
"return",
"False",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/utils/text.py#L32-L47 | train |
ynop/audiomate | audiomate/corpus/io/tatoeba.py | TatoebaDownloader._load_audio_list | def _load_audio_list(self, path):
"""
Load and filter the audio list.
Args:
path (str): Path to the audio list file.
Returns:
dict: Dictionary of filtered sentences (id : username, license, attribution-url)
"""
result = {}
for entry in ... | python | def _load_audio_list(self, path):
"""
Load and filter the audio list.
Args:
path (str): Path to the audio list file.
Returns:
dict: Dictionary of filtered sentences (id : username, license, attribution-url)
"""
result = {}
for entry in ... | [
"def",
"_load_audio_list",
"(",
"self",
",",
"path",
")",
":",
"result",
"=",
"{",
"}",
"for",
"entry",
"in",
"textfile",
".",
"read_separated_lines_generator",
"(",
"path",
",",
"separator",
"=",
"'\\t'",
",",
"max_columns",
"=",
"4",
")",
":",
"for",
"... | Load and filter the audio list.
Args:
path (str): Path to the audio list file.
Returns:
dict: Dictionary of filtered sentences (id : username, license, attribution-url) | [
"Load",
"and",
"filter",
"the",
"audio",
"list",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/corpus/io/tatoeba.py#L73-L102 | train |
ynop/audiomate | audiomate/corpus/io/tatoeba.py | TatoebaDownloader._load_sentence_list | def _load_sentence_list(self, path):
"""
Load and filter the sentence list.
Args:
path (str): Path to the sentence list.
Returns:
dict: Dictionary of sentences (id : language, transcription)
"""
result = {}
for entry in textfile.read_se... | python | def _load_sentence_list(self, path):
"""
Load and filter the sentence list.
Args:
path (str): Path to the sentence list.
Returns:
dict: Dictionary of sentences (id : language, transcription)
"""
result = {}
for entry in textfile.read_se... | [
"def",
"_load_sentence_list",
"(",
"self",
",",
"path",
")",
":",
"result",
"=",
"{",
"}",
"for",
"entry",
"in",
"textfile",
".",
"read_separated_lines_generator",
"(",
"path",
",",
"separator",
"=",
"'\\t'",
",",
"max_columns",
"=",
"3",
")",
":",
"if",
... | Load and filter the sentence list.
Args:
path (str): Path to the sentence list.
Returns:
dict: Dictionary of sentences (id : language, transcription) | [
"Load",
"and",
"filter",
"the",
"sentence",
"list",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/corpus/io/tatoeba.py#L104-L121 | train |
ynop/audiomate | audiomate/corpus/io/tatoeba.py | TatoebaDownloader._download_audio_files | def _download_audio_files(self, records, target_path):
"""
Download all audio files based on the given records.
"""
for record in records:
audio_folder = os.path.join(target_path, 'audio', record[2])
audio_file = os.path.join(audio_folder, '{}.mp3'.format(record[... | python | def _download_audio_files(self, records, target_path):
"""
Download all audio files based on the given records.
"""
for record in records:
audio_folder = os.path.join(target_path, 'audio', record[2])
audio_file = os.path.join(audio_folder, '{}.mp3'.format(record[... | [
"def",
"_download_audio_files",
"(",
"self",
",",
"records",
",",
"target_path",
")",
":",
"for",
"record",
"in",
"records",
":",
"audio_folder",
"=",
"os",
".",
"path",
".",
"join",
"(",
"target_path",
",",
"'audio'",
",",
"record",
"[",
"2",
"]",
")",
... | Download all audio files based on the given records. | [
"Download",
"all",
"audio",
"files",
"based",
"on",
"the",
"given",
"records",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/corpus/io/tatoeba.py#L123-L134 | train |
ynop/audiomate | audiomate/corpus/subset/splitting.py | Splitter.split_by_proportionally_distribute_labels | def split_by_proportionally_distribute_labels(self, proportions={}, use_lengths=True):
"""
Split the corpus into subsets, so the occurrence of the labels is distributed amongst the
subsets according to the given proportions.
Args:
proportions (dict): A dictionary containing ... | python | def split_by_proportionally_distribute_labels(self, proportions={}, use_lengths=True):
"""
Split the corpus into subsets, so the occurrence of the labels is distributed amongst the
subsets according to the given proportions.
Args:
proportions (dict): A dictionary containing ... | [
"def",
"split_by_proportionally_distribute_labels",
"(",
"self",
",",
"proportions",
"=",
"{",
"}",
",",
"use_lengths",
"=",
"True",
")",
":",
"identifiers",
"=",
"{",
"}",
"for",
"utterance",
"in",
"self",
".",
"corpus",
".",
"utterances",
".",
"values",
"(... | Split the corpus into subsets, so the occurrence of the labels is distributed amongst the
subsets according to the given proportions.
Args:
proportions (dict): A dictionary containing the relative size of the target subsets.
The key is an identifier for the s... | [
"Split",
"the",
"corpus",
"into",
"subsets",
"so",
"the",
"occurrence",
"of",
"the",
"labels",
"is",
"distributed",
"amongst",
"the",
"subsets",
"according",
"to",
"the",
"given",
"proportions",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/corpus/subset/splitting.py#L153-L178 | train |
ynop/audiomate | audiomate/corpus/subset/splitting.py | Splitter._subviews_from_utterance_splits | def _subviews_from_utterance_splits(self, splits):
"""
Create subviews from a dict containing utterance-ids for each subview.
e.g. {'train': ['utt-1', 'utt-2'], 'test': [...], ...}
"""
subviews = {}
for idx, subview_utterances in splits.items():
filter = sub... | python | def _subviews_from_utterance_splits(self, splits):
"""
Create subviews from a dict containing utterance-ids for each subview.
e.g. {'train': ['utt-1', 'utt-2'], 'test': [...], ...}
"""
subviews = {}
for idx, subview_utterances in splits.items():
filter = sub... | [
"def",
"_subviews_from_utterance_splits",
"(",
"self",
",",
"splits",
")",
":",
"subviews",
"=",
"{",
"}",
"for",
"idx",
",",
"subview_utterances",
"in",
"splits",
".",
"items",
"(",
")",
":",
"filter",
"=",
"subview",
".",
"MatchingUtteranceIdxFilter",
"(",
... | Create subviews from a dict containing utterance-ids for each subview.
e.g. {'train': ['utt-1', 'utt-2'], 'test': [...], ...} | [
"Create",
"subviews",
"from",
"a",
"dict",
"containing",
"utterance",
"-",
"ids",
"for",
"each",
"subview",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/corpus/subset/splitting.py#L180-L193 | train |
ynop/audiomate | audiomate/tracks/container.py | ContainerTrack.sampling_rate | def sampling_rate(self):
"""
Return the sampling rate.
"""
with self.container.open_if_needed(mode='r') as cnt:
return cnt.get(self.key)[1] | python | def sampling_rate(self):
"""
Return the sampling rate.
"""
with self.container.open_if_needed(mode='r') as cnt:
return cnt.get(self.key)[1] | [
"def",
"sampling_rate",
"(",
"self",
")",
":",
"with",
"self",
".",
"container",
".",
"open_if_needed",
"(",
"mode",
"=",
"'r'",
")",
"as",
"cnt",
":",
"return",
"cnt",
".",
"get",
"(",
"self",
".",
"key",
")",
"[",
"1",
"]"
] | Return the sampling rate. | [
"Return",
"the",
"sampling",
"rate",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/tracks/container.py#L47-L52 | train |
ynop/audiomate | audiomate/tracks/container.py | ContainerTrack.duration | def duration(self):
"""
Return the duration in seconds.
"""
with self.container.open_if_needed(mode='r') as cnt:
samples, sr = cnt.get(self.key)
return samples.shape[0] / sr | python | def duration(self):
"""
Return the duration in seconds.
"""
with self.container.open_if_needed(mode='r') as cnt:
samples, sr = cnt.get(self.key)
return samples.shape[0] / sr | [
"def",
"duration",
"(",
"self",
")",
":",
"with",
"self",
".",
"container",
".",
"open_if_needed",
"(",
"mode",
"=",
"'r'",
")",
"as",
"cnt",
":",
"samples",
",",
"sr",
"=",
"cnt",
".",
"get",
"(",
"self",
".",
"key",
")",
"return",
"samples",
".",... | Return the duration in seconds. | [
"Return",
"the",
"duration",
"in",
"seconds",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/tracks/container.py#L70-L77 | train |
ynop/audiomate | audiomate/tracks/container.py | ContainerTrack.read_samples | def read_samples(self, sr=None, offset=0, duration=None):
"""
Return the samples from the track in the container.
Uses librosa for resampling, if needed.
Args:
sr (int): If ``None``, uses the sampling rate given by the file,
otherwise resamples to the g... | python | def read_samples(self, sr=None, offset=0, duration=None):
"""
Return the samples from the track in the container.
Uses librosa for resampling, if needed.
Args:
sr (int): If ``None``, uses the sampling rate given by the file,
otherwise resamples to the g... | [
"def",
"read_samples",
"(",
"self",
",",
"sr",
"=",
"None",
",",
"offset",
"=",
"0",
",",
"duration",
"=",
"None",
")",
":",
"with",
"self",
".",
"container",
".",
"open_if_needed",
"(",
"mode",
"=",
"'r'",
")",
"as",
"cnt",
":",
"samples",
",",
"n... | Return the samples from the track in the container.
Uses librosa for resampling, if needed.
Args:
sr (int): If ``None``, uses the sampling rate given by the file,
otherwise resamples to the given sampling rate.
offset (float): The time in seconds, from wher... | [
"Return",
"the",
"samples",
"from",
"the",
"track",
"in",
"the",
"container",
".",
"Uses",
"librosa",
"for",
"resampling",
"if",
"needed",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/tracks/container.py#L79-L115 | train |
ynop/audiomate | audiomate/utils/jsonfile.py | write_json_to_file | def write_json_to_file(path, data):
"""
Writes data as json to file.
Parameters:
path (str): Path to write to
data (dict, list): Data
"""
with open(path, 'w', encoding='utf-8') as f:
json.dump(data, f) | python | def write_json_to_file(path, data):
"""
Writes data as json to file.
Parameters:
path (str): Path to write to
data (dict, list): Data
"""
with open(path, 'w', encoding='utf-8') as f:
json.dump(data, f) | [
"def",
"write_json_to_file",
"(",
"path",
",",
"data",
")",
":",
"with",
"open",
"(",
"path",
",",
"'w'",
",",
"encoding",
"=",
"'utf-8'",
")",
"as",
"f",
":",
"json",
".",
"dump",
"(",
"data",
",",
"f",
")"
] | Writes data as json to file.
Parameters:
path (str): Path to write to
data (dict, list): Data | [
"Writes",
"data",
"as",
"json",
"to",
"file",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/utils/jsonfile.py#L8-L17 | train |
ynop/audiomate | audiomate/utils/jsonfile.py | read_json_file | def read_json_file(path):
"""
Reads and return the data from the json file at the given path.
Parameters:
path (str): Path to read
Returns:
dict,list: The read json as dict/list.
"""
with open(path, 'r', encoding='utf-8') as f:
data = json.load(f)
return data | python | def read_json_file(path):
"""
Reads and return the data from the json file at the given path.
Parameters:
path (str): Path to read
Returns:
dict,list: The read json as dict/list.
"""
with open(path, 'r', encoding='utf-8') as f:
data = json.load(f)
return data | [
"def",
"read_json_file",
"(",
"path",
")",
":",
"with",
"open",
"(",
"path",
",",
"'r'",
",",
"encoding",
"=",
"'utf-8'",
")",
"as",
"f",
":",
"data",
"=",
"json",
".",
"load",
"(",
"f",
")",
"return",
"data"
] | Reads and return the data from the json file at the given path.
Parameters:
path (str): Path to read
Returns:
dict,list: The read json as dict/list. | [
"Reads",
"and",
"return",
"the",
"data",
"from",
"the",
"json",
"file",
"at",
"the",
"given",
"path",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/utils/jsonfile.py#L20-L34 | train |
ynop/audiomate | audiomate/annotations/label_list.py | LabelList.add | def add(self, label):
"""
Add a label to the end of the list.
Args:
label (Label): The label to add.
"""
label.label_list = self
self.label_tree.addi(label.start, label.end, label) | python | def add(self, label):
"""
Add a label to the end of the list.
Args:
label (Label): The label to add.
"""
label.label_list = self
self.label_tree.addi(label.start, label.end, label) | [
"def",
"add",
"(",
"self",
",",
"label",
")",
":",
"label",
".",
"label_list",
"=",
"self",
"self",
".",
"label_tree",
".",
"addi",
"(",
"label",
".",
"start",
",",
"label",
".",
"end",
",",
"label",
")"
] | Add a label to the end of the list.
Args:
label (Label): The label to add. | [
"Add",
"a",
"label",
"to",
"the",
"end",
"of",
"the",
"list",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/annotations/label_list.py#L90-L98 | train |
ynop/audiomate | audiomate/annotations/label_list.py | LabelList.merge_overlaps | def merge_overlaps(self, threshold=0.0):
"""
Merge overlapping labels with the same value.
Two labels are considered overlapping,
if ``l2.start - l1.end < threshold``.
Args:
threshold (float): Maximal distance between two labels
to be c... | python | def merge_overlaps(self, threshold=0.0):
"""
Merge overlapping labels with the same value.
Two labels are considered overlapping,
if ``l2.start - l1.end < threshold``.
Args:
threshold (float): Maximal distance between two labels
to be c... | [
"def",
"merge_overlaps",
"(",
"self",
",",
"threshold",
"=",
"0.0",
")",
":",
"updated_labels",
"=",
"[",
"]",
"all_intervals",
"=",
"self",
".",
"label_tree",
".",
"copy",
"(",
")",
"def",
"recursive_overlaps",
"(",
"interval",
")",
":",
"range_start",
"=... | Merge overlapping labels with the same value.
Two labels are considered overlapping,
if ``l2.start - l1.end < threshold``.
Args:
threshold (float): Maximal distance between two labels
to be considered as overlapping.
(def... | [
"Merge",
"overlapping",
"labels",
"with",
"the",
"same",
"value",
".",
"Two",
"labels",
"are",
"considered",
"overlapping",
"if",
"l2",
".",
"start",
"-",
"l1",
".",
"end",
"<",
"threshold",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/annotations/label_list.py#L141-L209 | train |
ynop/audiomate | audiomate/annotations/label_list.py | LabelList.label_total_duration | def label_total_duration(self):
"""
Return for each distinct label value the total duration of all occurrences.
Returns:
dict: A dictionary containing for every label-value (key)
the total duration in seconds (value).
Example:
>>> ll = LabelLis... | python | def label_total_duration(self):
"""
Return for each distinct label value the total duration of all occurrences.
Returns:
dict: A dictionary containing for every label-value (key)
the total duration in seconds (value).
Example:
>>> ll = LabelLis... | [
"def",
"label_total_duration",
"(",
"self",
")",
":",
"durations",
"=",
"collections",
".",
"defaultdict",
"(",
"float",
")",
"for",
"label",
"in",
"self",
":",
"durations",
"[",
"label",
".",
"value",
"]",
"+=",
"label",
".",
"duration",
"return",
"durati... | Return for each distinct label value the total duration of all occurrences.
Returns:
dict: A dictionary containing for every label-value (key)
the total duration in seconds (value).
Example:
>>> ll = LabelList(labels=[
>>> Label('a', 3, 5),
... | [
"Return",
"for",
"each",
"distinct",
"label",
"value",
"the",
"total",
"duration",
"of",
"all",
"occurrences",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/annotations/label_list.py#L215-L240 | train |
ynop/audiomate | audiomate/annotations/label_list.py | LabelList.label_values | def label_values(self):
"""
Return a list of all occuring label values.
Returns:
list: Lexicographically sorted list (str) of label values.
Example:
>>> ll = LabelList(labels=[
>>> Label('a', 3.2, 4.5),
>>> Label('b', 5.1, 8.9),
... | python | def label_values(self):
"""
Return a list of all occuring label values.
Returns:
list: Lexicographically sorted list (str) of label values.
Example:
>>> ll = LabelList(labels=[
>>> Label('a', 3.2, 4.5),
>>> Label('b', 5.1, 8.9),
... | [
"def",
"label_values",
"(",
"self",
")",
":",
"all_labels",
"=",
"set",
"(",
"[",
"l",
".",
"value",
"for",
"l",
"in",
"self",
"]",
")",
"return",
"sorted",
"(",
"all_labels",
")"
] | Return a list of all occuring label values.
Returns:
list: Lexicographically sorted list (str) of label values.
Example:
>>> ll = LabelList(labels=[
>>> Label('a', 3.2, 4.5),
>>> Label('b', 5.1, 8.9),
>>> Label('c', 7.2, 10.5),
... | [
"Return",
"a",
"list",
"of",
"all",
"occuring",
"label",
"values",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/annotations/label_list.py#L242-L262 | train |
ynop/audiomate | audiomate/annotations/label_list.py | LabelList.label_count | def label_count(self):
"""
Return for each label the number of occurrences within the list.
Returns:
dict: A dictionary containing for every label-value (key)
the number of occurrences (value).
Example:
>>> ll = LabelList(labels=[
>>> ... | python | def label_count(self):
"""
Return for each label the number of occurrences within the list.
Returns:
dict: A dictionary containing for every label-value (key)
the number of occurrences (value).
Example:
>>> ll = LabelList(labels=[
>>> ... | [
"def",
"label_count",
"(",
"self",
")",
":",
"occurrences",
"=",
"collections",
".",
"defaultdict",
"(",
"int",
")",
"for",
"label",
"in",
"self",
":",
"occurrences",
"[",
"label",
".",
"value",
"]",
"+=",
"1",
"return",
"occurrences"
] | Return for each label the number of occurrences within the list.
Returns:
dict: A dictionary containing for every label-value (key)
the number of occurrences (value).
Example:
>>> ll = LabelList(labels=[
>>> Label('a', 3.2, 4.5),
>>> ... | [
"Return",
"for",
"each",
"label",
"the",
"number",
"of",
"occurrences",
"within",
"the",
"list",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/annotations/label_list.py#L264-L289 | train |
ynop/audiomate | audiomate/annotations/label_list.py | LabelList.all_tokens | def all_tokens(self, delimiter=' '):
"""
Return a list of all tokens occurring in the label-list.
Args:
delimiter (str): The delimiter used to split labels into tokens
(see :meth:`audiomate.annotations.Label.tokenized`).
Returns:
:c... | python | def all_tokens(self, delimiter=' '):
"""
Return a list of all tokens occurring in the label-list.
Args:
delimiter (str): The delimiter used to split labels into tokens
(see :meth:`audiomate.annotations.Label.tokenized`).
Returns:
:c... | [
"def",
"all_tokens",
"(",
"self",
",",
"delimiter",
"=",
"' '",
")",
":",
"tokens",
"=",
"set",
"(",
")",
"for",
"label",
"in",
"self",
":",
"tokens",
"=",
"tokens",
".",
"union",
"(",
"set",
"(",
"label",
".",
"tokenized",
"(",
"delimiter",
"=",
"... | Return a list of all tokens occurring in the label-list.
Args:
delimiter (str): The delimiter used to split labels into tokens
(see :meth:`audiomate.annotations.Label.tokenized`).
Returns:
:class:`set`: A set of distinct tokens. | [
"Return",
"a",
"list",
"of",
"all",
"tokens",
"occurring",
"in",
"the",
"label",
"-",
"list",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/annotations/label_list.py#L291-L307 | train |
ynop/audiomate | audiomate/annotations/label_list.py | LabelList.join | def join(self, delimiter=' ', overlap_threshold=0.1):
"""
Return a string with all labels concatenated together.
The order of the labels is defined by the start of the label.
If the overlapping between two labels is greater than ``overlap_threshold``,
an Exception is thrown.
... | python | def join(self, delimiter=' ', overlap_threshold=0.1):
"""
Return a string with all labels concatenated together.
The order of the labels is defined by the start of the label.
If the overlapping between two labels is greater than ``overlap_threshold``,
an Exception is thrown.
... | [
"def",
"join",
"(",
"self",
",",
"delimiter",
"=",
"' '",
",",
"overlap_threshold",
"=",
"0.1",
")",
":",
"sorted_by_start",
"=",
"sorted",
"(",
"self",
".",
"labels",
")",
"concat_values",
"=",
"[",
"]",
"last_label_end",
"=",
"None",
"for",
"label",
"i... | Return a string with all labels concatenated together.
The order of the labels is defined by the start of the label.
If the overlapping between two labels is greater than ``overlap_threshold``,
an Exception is thrown.
Args:
delimiter (str): A string to join two consecutive l... | [
"Return",
"a",
"string",
"with",
"all",
"labels",
"concatenated",
"together",
".",
"The",
"order",
"of",
"the",
"labels",
"is",
"defined",
"by",
"the",
"start",
"of",
"the",
"label",
".",
"If",
"the",
"overlapping",
"between",
"two",
"labels",
"is",
"great... | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/annotations/label_list.py#L313-L349 | train |
ynop/audiomate | audiomate/annotations/label_list.py | LabelList.separated | def separated(self):
"""
Create a separate Label-List for every distinct label-value.
Returns:
dict: A dictionary with distinct label-values as keys.
Every value is a LabelList containing only labels with the same value.
Example:
>>> ll = Label... | python | def separated(self):
"""
Create a separate Label-List for every distinct label-value.
Returns:
dict: A dictionary with distinct label-values as keys.
Every value is a LabelList containing only labels with the same value.
Example:
>>> ll = Label... | [
"def",
"separated",
"(",
"self",
")",
":",
"separated_lls",
"=",
"collections",
".",
"defaultdict",
"(",
"LabelList",
")",
"for",
"label",
"in",
"self",
".",
"labels",
":",
"separated_lls",
"[",
"label",
".",
"value",
"]",
".",
"add",
"(",
"label",
")",
... | Create a separate Label-List for every distinct label-value.
Returns:
dict: A dictionary with distinct label-values as keys.
Every value is a LabelList containing only labels with the same value.
Example:
>>> ll = LabelList(idx='some', labels=[
>>>... | [
"Create",
"a",
"separate",
"Label",
"-",
"List",
"for",
"every",
"distinct",
"label",
"-",
"value",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/annotations/label_list.py#L393-L422 | train |
ynop/audiomate | audiomate/annotations/label_list.py | LabelList.labels_in_range | def labels_in_range(self, start, end, fully_included=False):
"""
Return a list of labels, that are within the given range.
Also labels that only overlap are included.
Args:
start(float): Start-time in seconds.
end(float): End-time in seconds.
fully_in... | python | def labels_in_range(self, start, end, fully_included=False):
"""
Return a list of labels, that are within the given range.
Also labels that only overlap are included.
Args:
start(float): Start-time in seconds.
end(float): End-time in seconds.
fully_in... | [
"def",
"labels_in_range",
"(",
"self",
",",
"start",
",",
"end",
",",
"fully_included",
"=",
"False",
")",
":",
"if",
"fully_included",
":",
"intervals",
"=",
"self",
".",
"label_tree",
".",
"envelop",
"(",
"start",
",",
"end",
")",
"else",
":",
"interva... | Return a list of labels, that are within the given range.
Also labels that only overlap are included.
Args:
start(float): Start-time in seconds.
end(float): End-time in seconds.
fully_included(bool): If ``True``, only labels fully included
... | [
"Return",
"a",
"list",
"of",
"labels",
"that",
"are",
"within",
"the",
"given",
"range",
".",
"Also",
"labels",
"that",
"only",
"overlap",
"are",
"included",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/annotations/label_list.py#L424-L456 | train |
ynop/audiomate | audiomate/annotations/label_list.py | LabelList.ranges | def ranges(self, yield_ranges_without_labels=False, include_labels=None):
"""
Generate all ranges of the label-list. A range is defined
as a part of the label-list for which the same labels are defined.
Args:
yield_ranges_without_labels(bool): If True also yields ranges for
... | python | def ranges(self, yield_ranges_without_labels=False, include_labels=None):
"""
Generate all ranges of the label-list. A range is defined
as a part of the label-list for which the same labels are defined.
Args:
yield_ranges_without_labels(bool): If True also yields ranges for
... | [
"def",
"ranges",
"(",
"self",
",",
"yield_ranges_without_labels",
"=",
"False",
",",
"include_labels",
"=",
"None",
")",
":",
"tree_copy",
"=",
"self",
".",
"label_tree",
".",
"copy",
"(",
")",
"if",
"include_labels",
"is",
"not",
"None",
":",
"for",
"iv",... | Generate all ranges of the label-list. A range is defined
as a part of the label-list for which the same labels are defined.
Args:
yield_ranges_without_labels(bool): If True also yields ranges for
which no labels are defined.
inclu... | [
"Generate",
"all",
"ranges",
"of",
"the",
"label",
"-",
"list",
".",
"A",
"range",
"is",
"defined",
"as",
"a",
"part",
"of",
"the",
"label",
"-",
"list",
"for",
"which",
"the",
"same",
"labels",
"are",
"defined",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/annotations/label_list.py#L458-L518 | train |
ynop/audiomate | audiomate/annotations/label_list.py | LabelList.create_single | def create_single(cls, value, idx='default'):
""" Create a label-list with a single label containing the given value. """
return LabelList(idx=idx, labels=[
Label(value=value)
]) | python | def create_single(cls, value, idx='default'):
""" Create a label-list with a single label containing the given value. """
return LabelList(idx=idx, labels=[
Label(value=value)
]) | [
"def",
"create_single",
"(",
"cls",
",",
"value",
",",
"idx",
"=",
"'default'",
")",
":",
"return",
"LabelList",
"(",
"idx",
"=",
"idx",
",",
"labels",
"=",
"[",
"Label",
"(",
"value",
"=",
"value",
")",
"]",
")"
] | Create a label-list with a single label containing the given value. | [
"Create",
"a",
"label",
"-",
"list",
"with",
"a",
"single",
"label",
"containing",
"the",
"given",
"value",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/annotations/label_list.py#L634-L639 | train |
ynop/audiomate | audiomate/corpus/io/mailabs.py | MailabsReader.get_folders | def get_folders(path):
"""
Return a list of all subfolder-paths in the given path.
"""
folder_paths = []
for item in os.listdir(path):
folder_path = os.path.join(path, item)
if os.path.isdir(folder_path):
folder_paths.append(folder_path)
... | python | def get_folders(path):
"""
Return a list of all subfolder-paths in the given path.
"""
folder_paths = []
for item in os.listdir(path):
folder_path = os.path.join(path, item)
if os.path.isdir(folder_path):
folder_paths.append(folder_path)
... | [
"def",
"get_folders",
"(",
"path",
")",
":",
"folder_paths",
"=",
"[",
"]",
"for",
"item",
"in",
"os",
".",
"listdir",
"(",
"path",
")",
":",
"folder_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"path",
",",
"item",
")",
"if",
"os",
".",
"pat... | Return a list of all subfolder-paths in the given path. | [
"Return",
"a",
"list",
"of",
"all",
"subfolder",
"-",
"paths",
"in",
"the",
"given",
"path",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/corpus/io/mailabs.py#L82-L94 | train |
ynop/audiomate | audiomate/corpus/io/mailabs.py | MailabsReader.load_tag | def load_tag(corpus, path):
"""
Iterate over all speakers on load them.
Collect all utterance-idx and create a subset of them.
"""
tag_idx = os.path.basename(path)
data_path = os.path.join(path, 'by_book')
tag_utt_ids = []
for gender_path in MailabsReader... | python | def load_tag(corpus, path):
"""
Iterate over all speakers on load them.
Collect all utterance-idx and create a subset of them.
"""
tag_idx = os.path.basename(path)
data_path = os.path.join(path, 'by_book')
tag_utt_ids = []
for gender_path in MailabsReader... | [
"def",
"load_tag",
"(",
"corpus",
",",
"path",
")",
":",
"tag_idx",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"path",
")",
"data_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"path",
",",
"'by_book'",
")",
"tag_utt_ids",
"=",
"[",
"]",
"for"... | Iterate over all speakers on load them.
Collect all utterance-idx and create a subset of them. | [
"Iterate",
"over",
"all",
"speakers",
"on",
"load",
"them",
".",
"Collect",
"all",
"utterance",
"-",
"idx",
"and",
"create",
"a",
"subset",
"of",
"them",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/corpus/io/mailabs.py#L97-L129 | train |
ynop/audiomate | audiomate/corpus/io/mailabs.py | MailabsReader.load_speaker | def load_speaker(corpus, path):
"""
Create a speaker instance for the given path.
"""
base_path, speaker_name = os.path.split(path)
base_path, gender_desc = os.path.split(base_path)
base_path, __ = os.path.split(base_path)
base_path, tag = os.path.split(base_path)... | python | def load_speaker(corpus, path):
"""
Create a speaker instance for the given path.
"""
base_path, speaker_name = os.path.split(path)
base_path, gender_desc = os.path.split(base_path)
base_path, __ = os.path.split(base_path)
base_path, tag = os.path.split(base_path)... | [
"def",
"load_speaker",
"(",
"corpus",
",",
"path",
")",
":",
"base_path",
",",
"speaker_name",
"=",
"os",
".",
"path",
".",
"split",
"(",
"path",
")",
"base_path",
",",
"gender_desc",
"=",
"os",
".",
"path",
".",
"split",
"(",
"base_path",
")",
"base_p... | Create a speaker instance for the given path. | [
"Create",
"a",
"speaker",
"instance",
"for",
"the",
"given",
"path",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/corpus/io/mailabs.py#L132-L151 | train |
ynop/audiomate | audiomate/corpus/io/mailabs.py | MailabsReader.load_books_of_speaker | def load_books_of_speaker(corpus, path, speaker):
"""
Load all utterances for the speaker at the given path.
"""
utt_ids = []
for book_path in MailabsReader.get_folders(path):
meta_path = os.path.join(book_path, 'metadata.csv')
wavs_path = os.path.join(bo... | python | def load_books_of_speaker(corpus, path, speaker):
"""
Load all utterances for the speaker at the given path.
"""
utt_ids = []
for book_path in MailabsReader.get_folders(path):
meta_path = os.path.join(book_path, 'metadata.csv')
wavs_path = os.path.join(bo... | [
"def",
"load_books_of_speaker",
"(",
"corpus",
",",
"path",
",",
"speaker",
")",
":",
"utt_ids",
"=",
"[",
"]",
"for",
"book_path",
"in",
"MailabsReader",
".",
"get_folders",
"(",
"path",
")",
":",
"meta_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
... | Load all utterances for the speaker at the given path. | [
"Load",
"all",
"utterances",
"for",
"the",
"speaker",
"at",
"the",
"given",
"path",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/corpus/io/mailabs.py#L154-L204 | train |
ynop/audiomate | audiomate/containers/container.py | Container.open | def open(self, mode=None):
"""
Open the container file.
Args:
mode (str): Either 'r' for read-only, 'w' for truncate and write or
'a' for append. (default: 'a').
If ``None``, uses ``self.mode``.
"""
if mode is None:
... | python | def open(self, mode=None):
"""
Open the container file.
Args:
mode (str): Either 'r' for read-only, 'w' for truncate and write or
'a' for append. (default: 'a').
If ``None``, uses ``self.mode``.
"""
if mode is None:
... | [
"def",
"open",
"(",
"self",
",",
"mode",
"=",
"None",
")",
":",
"if",
"mode",
"is",
"None",
":",
"mode",
"=",
"self",
".",
"mode",
"elif",
"mode",
"not",
"in",
"[",
"'r'",
",",
"'w'",
",",
"'a'",
"]",
":",
"raise",
"ValueError",
"(",
"'Invalid mo... | Open the container file.
Args:
mode (str): Either 'r' for read-only, 'w' for truncate and write or
'a' for append. (default: 'a').
If ``None``, uses ``self.mode``. | [
"Open",
"the",
"container",
"file",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/containers/container.py#L35-L51 | train |
ynop/audiomate | audiomate/containers/container.py | Container.open_if_needed | def open_if_needed(self, mode=None):
"""
Convenience context-manager for the use with ``with``.
Opens the container if not already done.
Only closes the container if it was opened within this context.
Args:
mode (str): Either 'r' for read-only, 'w' for truncate and w... | python | def open_if_needed(self, mode=None):
"""
Convenience context-manager for the use with ``with``.
Opens the container if not already done.
Only closes the container if it was opened within this context.
Args:
mode (str): Either 'r' for read-only, 'w' for truncate and w... | [
"def",
"open_if_needed",
"(",
"self",
",",
"mode",
"=",
"None",
")",
":",
"was_open",
"=",
"self",
".",
"is_open",
"(",
")",
"if",
"not",
"was_open",
":",
"self",
".",
"open",
"(",
"mode",
"=",
"mode",
")",
"try",
":",
"yield",
"self",
"finally",
"... | Convenience context-manager for the use with ``with``.
Opens the container if not already done.
Only closes the container if it was opened within this context.
Args:
mode (str): Either 'r' for read-only, 'w' for truncate and write or
'a' for append. (default:... | [
"Convenience",
"context",
"-",
"manager",
"for",
"the",
"use",
"with",
"with",
".",
"Opens",
"the",
"container",
"if",
"not",
"already",
"done",
".",
"Only",
"closes",
"the",
"container",
"if",
"it",
"was",
"opened",
"within",
"this",
"context",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/containers/container.py#L68-L88 | train |
ynop/audiomate | audiomate/containers/container.py | Container.get | def get(self, key, mem_map=True):
"""
Read and return the data stored for the given key.
Args:
key (str): The key to read the data from.
mem_map (bool): If ``True`` returns the data as
memory-mapped array, otherwise a copy is returned.
... | python | def get(self, key, mem_map=True):
"""
Read and return the data stored for the given key.
Args:
key (str): The key to read the data from.
mem_map (bool): If ``True`` returns the data as
memory-mapped array, otherwise a copy is returned.
... | [
"def",
"get",
"(",
"self",
",",
"key",
",",
"mem_map",
"=",
"True",
")",
":",
"self",
".",
"raise_error_if_not_open",
"(",
")",
"if",
"key",
"in",
"self",
".",
"_file",
":",
"data",
"=",
"self",
".",
"_file",
"[",
"key",
"]",
"if",
"not",
"mem_map"... | Read and return the data stored for the given key.
Args:
key (str): The key to read the data from.
mem_map (bool): If ``True`` returns the data as
memory-mapped array, otherwise a copy is returned.
Note:
The container has to be opened in ... | [
"Read",
"and",
"return",
"the",
"data",
"stored",
"for",
"the",
"given",
"key",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/containers/container.py#L111-L136 | train |
ynop/audiomate | audiomate/containers/container.py | Container.remove | def remove(self, key):
"""
Remove the data stored for the given key.
Args:
key (str): Key of the data to remove.
Note:
The container has to be opened in advance.
"""
self.raise_error_if_not_open()
if key in self._file:
del se... | python | def remove(self, key):
"""
Remove the data stored for the given key.
Args:
key (str): Key of the data to remove.
Note:
The container has to be opened in advance.
"""
self.raise_error_if_not_open()
if key in self._file:
del se... | [
"def",
"remove",
"(",
"self",
",",
"key",
")",
":",
"self",
".",
"raise_error_if_not_open",
"(",
")",
"if",
"key",
"in",
"self",
".",
"_file",
":",
"del",
"self",
".",
"_file",
"[",
"key",
"]"
] | Remove the data stored for the given key.
Args:
key (str): Key of the data to remove.
Note:
The container has to be opened in advance. | [
"Remove",
"the",
"data",
"stored",
"for",
"the",
"given",
"key",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/containers/container.py#L196-L209 | train |
ynop/audiomate | audiomate/tracks/utterance.py | Utterance.end_abs | def end_abs(self):
"""
Return the absolute end of the utterance relative to the signal.
"""
if self.end == float('inf'):
return self.track.duration
else:
return self.end | python | def end_abs(self):
"""
Return the absolute end of the utterance relative to the signal.
"""
if self.end == float('inf'):
return self.track.duration
else:
return self.end | [
"def",
"end_abs",
"(",
"self",
")",
":",
"if",
"self",
".",
"end",
"==",
"float",
"(",
"'inf'",
")",
":",
"return",
"self",
".",
"track",
".",
"duration",
"else",
":",
"return",
"self",
".",
"end"
] | Return the absolute end of the utterance relative to the signal. | [
"Return",
"the",
"absolute",
"end",
"of",
"the",
"utterance",
"relative",
"to",
"the",
"signal",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/tracks/utterance.py#L68-L75 | train |
ynop/audiomate | audiomate/tracks/utterance.py | Utterance.num_samples | def num_samples(self, sr=None):
"""
Return the number of samples.
Args:
sr (int): Calculate the number of samples with the given
sampling-rate. If None use the native sampling-rate.
Returns:
int: Number of samples
"""
native... | python | def num_samples(self, sr=None):
"""
Return the number of samples.
Args:
sr (int): Calculate the number of samples with the given
sampling-rate. If None use the native sampling-rate.
Returns:
int: Number of samples
"""
native... | [
"def",
"num_samples",
"(",
"self",
",",
"sr",
"=",
"None",
")",
":",
"native_sr",
"=",
"self",
".",
"sampling_rate",
"num_samples",
"=",
"units",
".",
"seconds_to_sample",
"(",
"self",
".",
"duration",
",",
"native_sr",
")",
"if",
"sr",
"is",
"not",
"Non... | Return the number of samples.
Args:
sr (int): Calculate the number of samples with the given
sampling-rate. If None use the native sampling-rate.
Returns:
int: Number of samples | [
"Return",
"the",
"number",
"of",
"samples",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/tracks/utterance.py#L84-L102 | train |
ynop/audiomate | audiomate/tracks/utterance.py | Utterance.read_samples | def read_samples(self, sr=None, offset=0, duration=None):
"""
Read the samples of the utterance.
Args:
sr (int): If None uses the sampling rate given by the track,
otherwise resamples to the given sampling rate.
offset (float): Offset in seconds to ... | python | def read_samples(self, sr=None, offset=0, duration=None):
"""
Read the samples of the utterance.
Args:
sr (int): If None uses the sampling rate given by the track,
otherwise resamples to the given sampling rate.
offset (float): Offset in seconds to ... | [
"def",
"read_samples",
"(",
"self",
",",
"sr",
"=",
"None",
",",
"offset",
"=",
"0",
",",
"duration",
"=",
"None",
")",
":",
"read_duration",
"=",
"self",
".",
"duration",
"if",
"offset",
">",
"0",
"and",
"read_duration",
"is",
"not",
"None",
":",
"r... | Read the samples of the utterance.
Args:
sr (int): If None uses the sampling rate given by the track,
otherwise resamples to the given sampling rate.
offset (float): Offset in seconds to read samples from.
duration (float): If not ``None`` read only thi... | [
"Read",
"the",
"samples",
"of",
"the",
"utterance",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/tracks/utterance.py#L108-L139 | train |
ynop/audiomate | audiomate/tracks/utterance.py | Utterance.set_label_list | def set_label_list(self, label_lists):
"""
Set the given label-list for this utterance.
If the label-list-idx is not set, ``default`` is used.
If there is already a label-list with the given idx,
it will be overriden.
Args:
label_list (LabelList, list): A sin... | python | def set_label_list(self, label_lists):
"""
Set the given label-list for this utterance.
If the label-list-idx is not set, ``default`` is used.
If there is already a label-list with the given idx,
it will be overriden.
Args:
label_list (LabelList, list): A sin... | [
"def",
"set_label_list",
"(",
"self",
",",
"label_lists",
")",
":",
"if",
"isinstance",
"(",
"label_lists",
",",
"annotations",
".",
"LabelList",
")",
":",
"label_lists",
"=",
"[",
"label_lists",
"]",
"for",
"label_list",
"in",
"label_lists",
":",
"if",
"lab... | Set the given label-list for this utterance.
If the label-list-idx is not set, ``default`` is used.
If there is already a label-list with the given idx,
it will be overriden.
Args:
label_list (LabelList, list): A single or multi. label-lists to add. | [
"Set",
"the",
"given",
"label",
"-",
"list",
"for",
"this",
"utterance",
".",
"If",
"the",
"label",
"-",
"list",
"-",
"idx",
"is",
"not",
"set",
"default",
"is",
"used",
".",
"If",
"there",
"is",
"already",
"a",
"label",
"-",
"list",
"with",
"the",
... | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/tracks/utterance.py#L152-L172 | train |
ynop/audiomate | audiomate/tracks/utterance.py | Utterance.all_label_values | def all_label_values(self, label_list_ids=None):
"""
Return a set of all label-values occurring in this utterance.
Args:
label_list_ids (list): If not None, only label-values from
label-lists with an id contained in this list
... | python | def all_label_values(self, label_list_ids=None):
"""
Return a set of all label-values occurring in this utterance.
Args:
label_list_ids (list): If not None, only label-values from
label-lists with an id contained in this list
... | [
"def",
"all_label_values",
"(",
"self",
",",
"label_list_ids",
"=",
"None",
")",
":",
"values",
"=",
"set",
"(",
")",
"for",
"label_list",
"in",
"self",
".",
"label_lists",
".",
"values",
"(",
")",
":",
"if",
"label_list_ids",
"is",
"None",
"or",
"label_... | Return a set of all label-values occurring in this utterance.
Args:
label_list_ids (list): If not None, only label-values from
label-lists with an id contained in this list
are considered.
Returns:
:class:`s... | [
"Return",
"a",
"set",
"of",
"all",
"label",
"-",
"values",
"occurring",
"in",
"this",
"utterance",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/tracks/utterance.py#L174-L192 | train |
ynop/audiomate | audiomate/tracks/utterance.py | Utterance.label_count | def label_count(self, label_list_ids=None):
"""
Return a dictionary containing the number of times,
every label-value in this utterance is occurring.
Args:
label_list_ids (list): If not None, only labels from label-lists
with an id containe... | python | def label_count(self, label_list_ids=None):
"""
Return a dictionary containing the number of times,
every label-value in this utterance is occurring.
Args:
label_list_ids (list): If not None, only labels from label-lists
with an id containe... | [
"def",
"label_count",
"(",
"self",
",",
"label_list_ids",
"=",
"None",
")",
":",
"count",
"=",
"collections",
".",
"defaultdict",
"(",
"int",
")",
"for",
"label_list",
"in",
"self",
".",
"label_lists",
".",
"values",
"(",
")",
":",
"if",
"label_list_ids",
... | Return a dictionary containing the number of times,
every label-value in this utterance is occurring.
Args:
label_list_ids (list): If not None, only labels from label-lists
with an id contained in this list
are considered... | [
"Return",
"a",
"dictionary",
"containing",
"the",
"number",
"of",
"times",
"every",
"label",
"-",
"value",
"in",
"this",
"utterance",
"is",
"occurring",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/tracks/utterance.py#L194-L215 | train |
ynop/audiomate | audiomate/tracks/utterance.py | Utterance.all_tokens | def all_tokens(self, delimiter=' ', label_list_ids=None):
"""
Return a list of all tokens occurring in
one of the labels in the label-lists.
Args:
delimiter (str): The delimiter used to split labels into tokens
(see :meth:`audiomate.annotations.L... | python | def all_tokens(self, delimiter=' ', label_list_ids=None):
"""
Return a list of all tokens occurring in
one of the labels in the label-lists.
Args:
delimiter (str): The delimiter used to split labels into tokens
(see :meth:`audiomate.annotations.L... | [
"def",
"all_tokens",
"(",
"self",
",",
"delimiter",
"=",
"' '",
",",
"label_list_ids",
"=",
"None",
")",
":",
"tokens",
"=",
"set",
"(",
")",
"for",
"label_list",
"in",
"self",
".",
"label_lists",
".",
"values",
"(",
")",
":",
"if",
"label_list_ids",
"... | Return a list of all tokens occurring in
one of the labels in the label-lists.
Args:
delimiter (str): The delimiter used to split labels into tokens
(see :meth:`audiomate.annotations.Label.tokenized`).
label_list_ids (list): If not None, only labels ... | [
"Return",
"a",
"list",
"of",
"all",
"tokens",
"occurring",
"in",
"one",
"of",
"the",
"labels",
"in",
"the",
"label",
"-",
"lists",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/tracks/utterance.py#L217-L237 | train |
ynop/audiomate | audiomate/tracks/utterance.py | Utterance.label_total_duration | def label_total_duration(self, label_list_ids=None):
"""
Return a dictionary containing the number of seconds,
every label-value is occurring in this utterance.
Args:
label_list_ids (list): If not None, only labels from label-lists
with an ... | python | def label_total_duration(self, label_list_ids=None):
"""
Return a dictionary containing the number of seconds,
every label-value is occurring in this utterance.
Args:
label_list_ids (list): If not None, only labels from label-lists
with an ... | [
"def",
"label_total_duration",
"(",
"self",
",",
"label_list_ids",
"=",
"None",
")",
":",
"duration",
"=",
"collections",
".",
"defaultdict",
"(",
"float",
")",
"for",
"label_list",
"in",
"self",
".",
"label_lists",
".",
"values",
"(",
")",
":",
"if",
"lab... | Return a dictionary containing the number of seconds,
every label-value is occurring in this utterance.
Args:
label_list_ids (list): If not None, only labels from label-lists
with an id contained in this
list are consider... | [
"Return",
"a",
"dictionary",
"containing",
"the",
"number",
"of",
"seconds",
"every",
"label",
"-",
"value",
"is",
"occurring",
"in",
"this",
"utterance",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/tracks/utterance.py#L239-L260 | train |
ynop/audiomate | audiomate/containers/features.py | FeatureContainer.stats | def stats(self):
"""
Return statistics calculated overall features in the container.
Note:
The feature container has to be opened in advance.
Returns:
DataStats: Statistics overall data points of all features.
"""
self.raise_error_if_not_open()
... | python | def stats(self):
"""
Return statistics calculated overall features in the container.
Note:
The feature container has to be opened in advance.
Returns:
DataStats: Statistics overall data points of all features.
"""
self.raise_error_if_not_open()
... | [
"def",
"stats",
"(",
"self",
")",
":",
"self",
".",
"raise_error_if_not_open",
"(",
")",
"per_key_stats",
"=",
"self",
".",
"stats_per_key",
"(",
")",
"return",
"stats",
".",
"DataStats",
".",
"concatenate",
"(",
"per_key_stats",
".",
"values",
"(",
")",
"... | Return statistics calculated overall features in the container.
Note:
The feature container has to be opened in advance.
Returns:
DataStats: Statistics overall data points of all features. | [
"Return",
"statistics",
"calculated",
"overall",
"features",
"in",
"the",
"container",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/containers/features.py#L60-L74 | train |
ynop/audiomate | audiomate/containers/features.py | FeatureContainer.stats_per_key | def stats_per_key(self):
"""
Return statistics calculated for each key in the container.
Note:
The feature container has to be opened in advance.
Returns:
dict: A dictionary containing a DataStats object for each key.
"""
self.raise_error_if_not_... | python | def stats_per_key(self):
"""
Return statistics calculated for each key in the container.
Note:
The feature container has to be opened in advance.
Returns:
dict: A dictionary containing a DataStats object for each key.
"""
self.raise_error_if_not_... | [
"def",
"stats_per_key",
"(",
"self",
")",
":",
"self",
".",
"raise_error_if_not_open",
"(",
")",
"all_stats",
"=",
"{",
"}",
"for",
"key",
",",
"data",
"in",
"self",
".",
"_file",
".",
"items",
"(",
")",
":",
"data",
"=",
"data",
"[",
"(",
")",
"]"... | Return statistics calculated for each key in the container.
Note:
The feature container has to be opened in advance.
Returns:
dict: A dictionary containing a DataStats object for each key. | [
"Return",
"statistics",
"calculated",
"for",
"each",
"key",
"in",
"the",
"container",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/containers/features.py#L76-L98 | train |
ynop/audiomate | audiomate/corpus/base.py | CorpusView.all_label_values | def all_label_values(self, label_list_ids=None):
"""
Return a set of all label-values occurring in this corpus.
Args:
label_list_ids (list): If not None, only labels from label-lists with an id contained in this list
are considered.
Return... | python | def all_label_values(self, label_list_ids=None):
"""
Return a set of all label-values occurring in this corpus.
Args:
label_list_ids (list): If not None, only labels from label-lists with an id contained in this list
are considered.
Return... | [
"def",
"all_label_values",
"(",
"self",
",",
"label_list_ids",
"=",
"None",
")",
":",
"values",
"=",
"set",
"(",
")",
"for",
"utterance",
"in",
"self",
".",
"utterances",
".",
"values",
"(",
")",
":",
"values",
"=",
"values",
".",
"union",
"(",
"uttera... | Return a set of all label-values occurring in this corpus.
Args:
label_list_ids (list): If not None, only labels from label-lists with an id contained in this list
are considered.
Returns:
:class:`set`: A set of distinct label-values. | [
"Return",
"a",
"set",
"of",
"all",
"label",
"-",
"values",
"occurring",
"in",
"this",
"corpus",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/corpus/base.py#L133-L149 | train |
ynop/audiomate | audiomate/corpus/base.py | CorpusView.label_count | def label_count(self, label_list_ids=None):
"""
Return a dictionary containing the number of times, every label-value in this corpus is occurring.
Args:
label_list_ids (list): If not None, only labels from label-lists with an id contained in this list
... | python | def label_count(self, label_list_ids=None):
"""
Return a dictionary containing the number of times, every label-value in this corpus is occurring.
Args:
label_list_ids (list): If not None, only labels from label-lists with an id contained in this list
... | [
"def",
"label_count",
"(",
"self",
",",
"label_list_ids",
"=",
"None",
")",
":",
"count",
"=",
"collections",
".",
"defaultdict",
"(",
"int",
")",
"for",
"utterance",
"in",
"self",
".",
"utterances",
".",
"values",
"(",
")",
":",
"for",
"label_value",
",... | Return a dictionary containing the number of times, every label-value in this corpus is occurring.
Args:
label_list_ids (list): If not None, only labels from label-lists with an id contained in this list
are considered.
Returns:
dict: A dictio... | [
"Return",
"a",
"dictionary",
"containing",
"the",
"number",
"of",
"times",
"every",
"label",
"-",
"value",
"in",
"this",
"corpus",
"is",
"occurring",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/corpus/base.py#L151-L168 | train |
ynop/audiomate | audiomate/corpus/base.py | CorpusView.label_durations | def label_durations(self, label_list_ids=None):
"""
Return a dictionary containing the total duration, every label-value in this corpus is occurring.
Args:
label_list_ids (list): If not None, only labels from label-lists with an id contained in this list
... | python | def label_durations(self, label_list_ids=None):
"""
Return a dictionary containing the total duration, every label-value in this corpus is occurring.
Args:
label_list_ids (list): If not None, only labels from label-lists with an id contained in this list
... | [
"def",
"label_durations",
"(",
"self",
",",
"label_list_ids",
"=",
"None",
")",
":",
"duration",
"=",
"collections",
".",
"defaultdict",
"(",
"int",
")",
"for",
"utterance",
"in",
"self",
".",
"utterances",
".",
"values",
"(",
")",
":",
"for",
"label_value... | Return a dictionary containing the total duration, every label-value in this corpus is occurring.
Args:
label_list_ids (list): If not None, only labels from label-lists with an id contained in this list
are considered.
Returns:
dict: A diction... | [
"Return",
"a",
"dictionary",
"containing",
"the",
"total",
"duration",
"every",
"label",
"-",
"value",
"in",
"this",
"corpus",
"is",
"occurring",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/corpus/base.py#L170-L187 | train |
ynop/audiomate | audiomate/corpus/base.py | CorpusView.all_tokens | def all_tokens(self, delimiter=' ', label_list_ids=None):
"""
Return a list of all tokens occurring in one of the labels in the corpus.
Args:
delimiter (str): The delimiter used to split labels into tokens
(see :meth:`audiomate.annotations.Label.tokenize... | python | def all_tokens(self, delimiter=' ', label_list_ids=None):
"""
Return a list of all tokens occurring in one of the labels in the corpus.
Args:
delimiter (str): The delimiter used to split labels into tokens
(see :meth:`audiomate.annotations.Label.tokenize... | [
"def",
"all_tokens",
"(",
"self",
",",
"delimiter",
"=",
"' '",
",",
"label_list_ids",
"=",
"None",
")",
":",
"tokens",
"=",
"set",
"(",
")",
"for",
"utterance",
"in",
"self",
".",
"utterances",
".",
"values",
"(",
")",
":",
"tokens",
"=",
"tokens",
... | Return a list of all tokens occurring in one of the labels in the corpus.
Args:
delimiter (str): The delimiter used to split labels into tokens
(see :meth:`audiomate.annotations.Label.tokenized`).
label_list_ids (list): If not None, only labels from label-li... | [
"Return",
"a",
"list",
"of",
"all",
"tokens",
"occurring",
"in",
"one",
"of",
"the",
"labels",
"in",
"the",
"corpus",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/corpus/base.py#L189-L207 | train |
ynop/audiomate | audiomate/corpus/base.py | CorpusView.total_duration | def total_duration(self):
"""
Return the total amount of audio summed over all utterances in the corpus in seconds.
"""
duration = 0
for utterance in self.utterances.values():
duration += utterance.duration
return duration | python | def total_duration(self):
"""
Return the total amount of audio summed over all utterances in the corpus in seconds.
"""
duration = 0
for utterance in self.utterances.values():
duration += utterance.duration
return duration | [
"def",
"total_duration",
"(",
"self",
")",
":",
"duration",
"=",
"0",
"for",
"utterance",
"in",
"self",
".",
"utterances",
".",
"values",
"(",
")",
":",
"duration",
"+=",
"utterance",
".",
"duration",
"return",
"duration"
] | Return the total amount of audio summed over all utterances in the corpus in seconds. | [
"Return",
"the",
"total",
"amount",
"of",
"audio",
"summed",
"over",
"all",
"utterances",
"in",
"the",
"corpus",
"in",
"seconds",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/corpus/base.py#L214-L223 | train |
ynop/audiomate | audiomate/corpus/base.py | CorpusView.stats | def stats(self):
"""
Return statistics calculated overall samples of all utterances in the corpus.
Returns:
DataStats: A DataStats object containing statistics overall samples in the corpus.
"""
per_utt_stats = self.stats_per_utterance()
return stats.DataSta... | python | def stats(self):
"""
Return statistics calculated overall samples of all utterances in the corpus.
Returns:
DataStats: A DataStats object containing statistics overall samples in the corpus.
"""
per_utt_stats = self.stats_per_utterance()
return stats.DataSta... | [
"def",
"stats",
"(",
"self",
")",
":",
"per_utt_stats",
"=",
"self",
".",
"stats_per_utterance",
"(",
")",
"return",
"stats",
".",
"DataStats",
".",
"concatenate",
"(",
"per_utt_stats",
".",
"values",
"(",
")",
")"
] | Return statistics calculated overall samples of all utterances in the corpus.
Returns:
DataStats: A DataStats object containing statistics overall samples in the corpus. | [
"Return",
"statistics",
"calculated",
"overall",
"samples",
"of",
"all",
"utterances",
"in",
"the",
"corpus",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/corpus/base.py#L225-L234 | train |
ynop/audiomate | audiomate/corpus/base.py | CorpusView.stats_per_utterance | def stats_per_utterance(self):
"""
Return statistics calculated for all samples of each utterance in the corpus.
Returns:
dict: A dictionary containing a DataStats object for each utt.
"""
all_stats = {}
for utterance in self.utterances.values():
... | python | def stats_per_utterance(self):
"""
Return statistics calculated for all samples of each utterance in the corpus.
Returns:
dict: A dictionary containing a DataStats object for each utt.
"""
all_stats = {}
for utterance in self.utterances.values():
... | [
"def",
"stats_per_utterance",
"(",
"self",
")",
":",
"all_stats",
"=",
"{",
"}",
"for",
"utterance",
"in",
"self",
".",
"utterances",
".",
"values",
"(",
")",
":",
"data",
"=",
"utterance",
".",
"read_samples",
"(",
")",
"all_stats",
"[",
"utterance",
".... | Return statistics calculated for all samples of each utterance in the corpus.
Returns:
dict: A dictionary containing a DataStats object for each utt. | [
"Return",
"statistics",
"calculated",
"for",
"all",
"samples",
"of",
"each",
"utterance",
"in",
"the",
"corpus",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/corpus/base.py#L236-L254 | train |
ynop/audiomate | audiomate/corpus/base.py | CorpusView.split_utterances_to_max_time | def split_utterances_to_max_time(self, max_time=60.0, overlap=0.0):
"""
Create a new corpus, where all the utterances are of given maximal duration.
Utterance longer than ``max_time`` are split up into multiple utterances.
.. warning::
Subviews and FeatureContainers are not ... | python | def split_utterances_to_max_time(self, max_time=60.0, overlap=0.0):
"""
Create a new corpus, where all the utterances are of given maximal duration.
Utterance longer than ``max_time`` are split up into multiple utterances.
.. warning::
Subviews and FeatureContainers are not ... | [
"def",
"split_utterances_to_max_time",
"(",
"self",
",",
"max_time",
"=",
"60.0",
",",
"overlap",
"=",
"0.0",
")",
":",
"from",
"audiomate",
".",
"corpus",
"import",
"Corpus",
"result",
"=",
"Corpus",
"(",
")",
"tracks",
"=",
"copy",
".",
"deepcopy",
"(",
... | Create a new corpus, where all the utterances are of given maximal duration.
Utterance longer than ``max_time`` are split up into multiple utterances.
.. warning::
Subviews and FeatureContainers are not added to the newly create corpus.
Arguments:
max_time (float): Maxi... | [
"Create",
"a",
"new",
"corpus",
"where",
"all",
"the",
"utterances",
"are",
"of",
"given",
"maximal",
"duration",
".",
"Utterance",
"longer",
"than",
"max_time",
"are",
"split",
"up",
"into",
"multiple",
"utterances",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/corpus/base.py#L260-L323 | train |
ynop/audiomate | audiomate/feeding/dataset.py | MultiFrameDataset.get_utt_regions | def get_utt_regions(self):
"""
Return the regions of all utterances, assuming all utterances are concatenated.
It is assumed that the utterances are sorted in ascending order for concatenation.
A region is defined by offset (in chunks), length (num-chunks) and
a list of referenc... | python | def get_utt_regions(self):
"""
Return the regions of all utterances, assuming all utterances are concatenated.
It is assumed that the utterances are sorted in ascending order for concatenation.
A region is defined by offset (in chunks), length (num-chunks) and
a list of referenc... | [
"def",
"get_utt_regions",
"(",
"self",
")",
":",
"regions",
"=",
"[",
"]",
"current_offset",
"=",
"0",
"for",
"utt_idx",
"in",
"sorted",
"(",
"self",
".",
"utt_ids",
")",
":",
"offset",
"=",
"current_offset",
"num_frames",
"=",
"[",
"]",
"refs",
"=",
"... | Return the regions of all utterances, assuming all utterances are concatenated.
It is assumed that the utterances are sorted in ascending order for concatenation.
A region is defined by offset (in chunks), length (num-chunks) and
a list of references to the utterance datasets in the containers.... | [
"Return",
"the",
"regions",
"of",
"all",
"utterances",
"assuming",
"all",
"utterances",
"are",
"concatenated",
".",
"It",
"is",
"assumed",
"that",
"the",
"utterances",
"are",
"sorted",
"in",
"ascending",
"order",
"for",
"concatenation",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/feeding/dataset.py#L343-L379 | train |
ynop/audiomate | audiomate/containers/audio.py | AudioContainer.get | def get(self, key, mem_map=True):
"""
Return the samples for the given key and the sampling-rate.
Args:
key (str): The key to read the data from.
mem_map (bool): If ``True`` returns the data as
memory-mapped array, otherwise a copy is returned... | python | def get(self, key, mem_map=True):
"""
Return the samples for the given key and the sampling-rate.
Args:
key (str): The key to read the data from.
mem_map (bool): If ``True`` returns the data as
memory-mapped array, otherwise a copy is returned... | [
"def",
"get",
"(",
"self",
",",
"key",
",",
"mem_map",
"=",
"True",
")",
":",
"self",
".",
"raise_error_if_not_open",
"(",
")",
"if",
"key",
"in",
"self",
".",
"_file",
":",
"data",
"=",
"self",
".",
"_file",
"[",
"key",
"]",
"sampling_rate",
"=",
... | Return the samples for the given key and the sampling-rate.
Args:
key (str): The key to read the data from.
mem_map (bool): If ``True`` returns the data as
memory-mapped array, otherwise a copy is returned.
Note:
The container has to be o... | [
"Return",
"the",
"samples",
"for",
"the",
"given",
"key",
"and",
"the",
"sampling",
"-",
"rate",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/containers/audio.py#L19-L46 | train |
ynop/audiomate | audiomate/containers/audio.py | AudioContainer.set | def set(self, key, samples, sampling_rate):
"""
Set the samples and sampling-rate for the given key.
Existing data will be overwritten.
The samples have to have ``np.float32`` datatype and values in
the range of -1.0 and 1.0.
Args:
key (str): A key to store t... | python | def set(self, key, samples, sampling_rate):
"""
Set the samples and sampling-rate for the given key.
Existing data will be overwritten.
The samples have to have ``np.float32`` datatype and values in
the range of -1.0 and 1.0.
Args:
key (str): A key to store t... | [
"def",
"set",
"(",
"self",
",",
"key",
",",
"samples",
",",
"sampling_rate",
")",
":",
"if",
"not",
"np",
".",
"issubdtype",
"(",
"samples",
".",
"dtype",
",",
"np",
".",
"floating",
")",
":",
"raise",
"ValueError",
"(",
"'Samples are required as np.float3... | Set the samples and sampling-rate for the given key.
Existing data will be overwritten.
The samples have to have ``np.float32`` datatype and values in
the range of -1.0 and 1.0.
Args:
key (str): A key to store the data for.
samples (numpy.ndarray): 1-D array of a... | [
"Set",
"the",
"samples",
"and",
"sampling",
"-",
"rate",
"for",
"the",
"given",
"key",
".",
"Existing",
"data",
"will",
"be",
"overwritten",
".",
"The",
"samples",
"have",
"to",
"have",
"np",
".",
"float32",
"datatype",
"and",
"values",
"in",
"the",
"ran... | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/containers/audio.py#L48-L77 | train |
ynop/audiomate | audiomate/containers/audio.py | AudioContainer.append | def append(self, key, samples, sampling_rate):
"""
Append the given samples to the data that already exists
in the container for the given key.
Args:
key (str): A key to store the data for.
samples (numpy.ndarray): 1-D array of audio samples (int-16).
... | python | def append(self, key, samples, sampling_rate):
"""
Append the given samples to the data that already exists
in the container for the given key.
Args:
key (str): A key to store the data for.
samples (numpy.ndarray): 1-D array of audio samples (int-16).
... | [
"def",
"append",
"(",
"self",
",",
"key",
",",
"samples",
",",
"sampling_rate",
")",
":",
"if",
"not",
"np",
".",
"issubdtype",
"(",
"samples",
".",
"dtype",
",",
"np",
".",
"floating",
")",
":",
"raise",
"ValueError",
"(",
"'Samples are required as np.flo... | Append the given samples to the data that already exists
in the container for the given key.
Args:
key (str): A key to store the data for.
samples (numpy.ndarray): 1-D array of audio samples (int-16).
sampling_rate (int): The sampling-rate of the audio samples.
... | [
"Append",
"the",
"given",
"samples",
"to",
"the",
"data",
"that",
"already",
"exists",
"in",
"the",
"container",
"for",
"the",
"given",
"key",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/containers/audio.py#L79-L116 | train |
ynop/audiomate | audiomate/corpus/io/voxforge.py | VoxforgeDownloader.available_files | def available_files(url):
""" Extract and return urls for all available .tgz files. """
req = requests.get(url)
if req.status_code != 200:
raise base.FailedDownloadException('Failed to download data (status {}) from {}!'.format(req.status_code,
... | python | def available_files(url):
""" Extract and return urls for all available .tgz files. """
req = requests.get(url)
if req.status_code != 200:
raise base.FailedDownloadException('Failed to download data (status {}) from {}!'.format(req.status_code,
... | [
"def",
"available_files",
"(",
"url",
")",
":",
"req",
"=",
"requests",
".",
"get",
"(",
"url",
")",
"if",
"req",
".",
"status_code",
"!=",
"200",
":",
"raise",
"base",
".",
"FailedDownloadException",
"(",
"'Failed to download data (status {}) from {}!'",
".",
... | Extract and return urls for all available .tgz files. | [
"Extract",
"and",
"return",
"urls",
"for",
"all",
"available",
".",
"tgz",
"files",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/corpus/io/voxforge.py#L60-L76 | train |
ynop/audiomate | audiomate/corpus/io/voxforge.py | VoxforgeDownloader.download_files | def download_files(file_urls, target_path):
""" Download all files and store to the given path. """
os.makedirs(target_path, exist_ok=True)
downloaded_files = []
for file_url in file_urls:
req = requests.get(file_url)
if req.status_code != 200:
r... | python | def download_files(file_urls, target_path):
""" Download all files and store to the given path. """
os.makedirs(target_path, exist_ok=True)
downloaded_files = []
for file_url in file_urls:
req = requests.get(file_url)
if req.status_code != 200:
r... | [
"def",
"download_files",
"(",
"file_urls",
",",
"target_path",
")",
":",
"os",
".",
"makedirs",
"(",
"target_path",
",",
"exist_ok",
"=",
"True",
")",
"downloaded_files",
"=",
"[",
"]",
"for",
"file_url",
"in",
"file_urls",
":",
"req",
"=",
"requests",
"."... | Download all files and store to the given path. | [
"Download",
"all",
"files",
"and",
"store",
"to",
"the",
"given",
"path",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/corpus/io/voxforge.py#L79-L99 | train |
ynop/audiomate | audiomate/corpus/io/voxforge.py | VoxforgeDownloader.extract_files | def extract_files(file_paths, target_path):
""" Unpack all files to the given path. """
os.makedirs(target_path, exist_ok=True)
extracted = []
for file_path in file_paths:
with tarfile.open(file_path, 'r') as archive:
archive.extractall(target_path)
... | python | def extract_files(file_paths, target_path):
""" Unpack all files to the given path. """
os.makedirs(target_path, exist_ok=True)
extracted = []
for file_path in file_paths:
with tarfile.open(file_path, 'r') as archive:
archive.extractall(target_path)
... | [
"def",
"extract_files",
"(",
"file_paths",
",",
"target_path",
")",
":",
"os",
".",
"makedirs",
"(",
"target_path",
",",
"exist_ok",
"=",
"True",
")",
"extracted",
"=",
"[",
"]",
"for",
"file_path",
"in",
"file_paths",
":",
"with",
"tarfile",
".",
"open",
... | Unpack all files to the given path. | [
"Unpack",
"all",
"files",
"to",
"the",
"given",
"path",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/corpus/io/voxforge.py#L102-L114 | train |
ynop/audiomate | audiomate/utils/naming.py | index_name_if_in_list | def index_name_if_in_list(name, name_list, suffix='', prefix=''):
"""
Find a unique name by adding an index to the name so it is unique within the given list.
Parameters:
name (str): Name
name_list (iterable): List of names that the new name must differ from.
suffix (str): The suffi... | python | def index_name_if_in_list(name, name_list, suffix='', prefix=''):
"""
Find a unique name by adding an index to the name so it is unique within the given list.
Parameters:
name (str): Name
name_list (iterable): List of names that the new name must differ from.
suffix (str): The suffi... | [
"def",
"index_name_if_in_list",
"(",
"name",
",",
"name_list",
",",
"suffix",
"=",
"''",
",",
"prefix",
"=",
"''",
")",
":",
"new_name",
"=",
"'{}'",
".",
"format",
"(",
"name",
")",
"index",
"=",
"1",
"while",
"new_name",
"in",
"name_list",
":",
"new_... | Find a unique name by adding an index to the name so it is unique within the given list.
Parameters:
name (str): Name
name_list (iterable): List of names that the new name must differ from.
suffix (str): The suffix to append after the index.
prefix (str): The prefix to append in fro... | [
"Find",
"a",
"unique",
"name",
"by",
"adding",
"an",
"index",
"to",
"the",
"name",
"so",
"it",
"is",
"unique",
"within",
"the",
"given",
"list",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/utils/naming.py#L10-L30 | train |
ynop/audiomate | audiomate/utils/naming.py | generate_name | def generate_name(length=15, not_in=None):
"""
Generates a random string of lowercase letters with the given length.
Parameters:
length (int): Length of the string to output.
not_in (list): Only return a string not in the given iterator.
Returns:
str: A new name thats not in th... | python | def generate_name(length=15, not_in=None):
"""
Generates a random string of lowercase letters with the given length.
Parameters:
length (int): Length of the string to output.
not_in (list): Only return a string not in the given iterator.
Returns:
str: A new name thats not in th... | [
"def",
"generate_name",
"(",
"length",
"=",
"15",
",",
"not_in",
"=",
"None",
")",
":",
"value",
"=",
"''",
".",
"join",
"(",
"random",
".",
"choice",
"(",
"string",
".",
"ascii_lowercase",
")",
"for",
"i",
"in",
"range",
"(",
"length",
")",
")",
"... | Generates a random string of lowercase letters with the given length.
Parameters:
length (int): Length of the string to output.
not_in (list): Only return a string not in the given iterator.
Returns:
str: A new name thats not in the given list. | [
"Generates",
"a",
"random",
"string",
"of",
"lowercase",
"letters",
"with",
"the",
"given",
"length",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/utils/naming.py#L33-L49 | train |
ynop/audiomate | audiomate/corpus/io/__init__.py | create_downloader_of_type | def create_downloader_of_type(type_name):
"""
Create an instance of the downloader with the given name.
Args:
type_name: The name of a downloader.
Returns:
An instance of the downloader with the given type.
"""
downloaders = available_downloaders()
if t... | python | def create_downloader_of_type(type_name):
"""
Create an instance of the downloader with the given name.
Args:
type_name: The name of a downloader.
Returns:
An instance of the downloader with the given type.
"""
downloaders = available_downloaders()
if t... | [
"def",
"create_downloader_of_type",
"(",
"type_name",
")",
":",
"downloaders",
"=",
"available_downloaders",
"(",
")",
"if",
"type_name",
"not",
"in",
"downloaders",
".",
"keys",
"(",
")",
":",
"raise",
"UnknownDownloaderException",
"(",
"'Unknown downloader: %s'",
... | Create an instance of the downloader with the given name.
Args:
type_name: The name of a downloader.
Returns:
An instance of the downloader with the given type. | [
"Create",
"an",
"instance",
"of",
"the",
"downloader",
"with",
"the",
"given",
"name",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/corpus/io/__init__.py#L110-L125 | train |
ynop/audiomate | audiomate/corpus/io/__init__.py | create_reader_of_type | def create_reader_of_type(type_name):
"""
Create an instance of the reader with the given name.
Args:
type_name: The name of a reader.
Returns:
An instance of the reader with the given type.
"""
readers = available_readers()
if type_name not in readers.... | python | def create_reader_of_type(type_name):
"""
Create an instance of the reader with the given name.
Args:
type_name: The name of a reader.
Returns:
An instance of the reader with the given type.
"""
readers = available_readers()
if type_name not in readers.... | [
"def",
"create_reader_of_type",
"(",
"type_name",
")",
":",
"readers",
"=",
"available_readers",
"(",
")",
"if",
"type_name",
"not",
"in",
"readers",
".",
"keys",
"(",
")",
":",
"raise",
"UnknownReaderException",
"(",
"'Unknown reader: %s'",
"%",
"(",
"type_name... | Create an instance of the reader with the given name.
Args:
type_name: The name of a reader.
Returns:
An instance of the reader with the given type. | [
"Create",
"an",
"instance",
"of",
"the",
"reader",
"with",
"the",
"given",
"name",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/corpus/io/__init__.py#L128-L143 | train |
ynop/audiomate | audiomate/corpus/io/__init__.py | create_writer_of_type | def create_writer_of_type(type_name):
"""
Create an instance of the writer with the given name.
Args:
type_name: The name of a writer.
Returns:
An instance of the writer with the given type.
"""
writers = available_writers()
if type_name not in writers.... | python | def create_writer_of_type(type_name):
"""
Create an instance of the writer with the given name.
Args:
type_name: The name of a writer.
Returns:
An instance of the writer with the given type.
"""
writers = available_writers()
if type_name not in writers.... | [
"def",
"create_writer_of_type",
"(",
"type_name",
")",
":",
"writers",
"=",
"available_writers",
"(",
")",
"if",
"type_name",
"not",
"in",
"writers",
".",
"keys",
"(",
")",
":",
"raise",
"UnknownWriterException",
"(",
"'Unknown writer: %s'",
"%",
"(",
"type_name... | Create an instance of the writer with the given name.
Args:
type_name: The name of a writer.
Returns:
An instance of the writer with the given type. | [
"Create",
"an",
"instance",
"of",
"the",
"writer",
"with",
"the",
"given",
"name",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/corpus/io/__init__.py#L146-L161 | train |
ynop/audiomate | audiomate/corpus/subset/subview.py | Subview.serialize | def serialize(self):
"""
Return a string representing the subview with all of its filter criteria.
Returns:
str: String with subview definition.
"""
lines = []
for criterion in self.filter_criteria:
lines.append(criterion.name())
line... | python | def serialize(self):
"""
Return a string representing the subview with all of its filter criteria.
Returns:
str: String with subview definition.
"""
lines = []
for criterion in self.filter_criteria:
lines.append(criterion.name())
line... | [
"def",
"serialize",
"(",
"self",
")",
":",
"lines",
"=",
"[",
"]",
"for",
"criterion",
"in",
"self",
".",
"filter_criteria",
":",
"lines",
".",
"append",
"(",
"criterion",
".",
"name",
"(",
")",
")",
"lines",
".",
"append",
"(",
"criterion",
".",
"se... | Return a string representing the subview with all of its filter criteria.
Returns:
str: String with subview definition. | [
"Return",
"a",
"string",
"representing",
"the",
"subview",
"with",
"all",
"of",
"its",
"filter",
"criteria",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/corpus/subset/subview.py#L233-L246 | train |
ynop/audiomate | audiomate/processing/pipeline/spectral.py | stft_from_frames | def stft_from_frames(frames, window='hann', dtype=np.complex64):
"""
Variation of the librosa.core.stft function,
that computes the short-time-fourier-transfrom from frames instead from the signal.
See http://librosa.github.io/librosa/_modules/librosa/core/spectrum.html#stft
"""
win_length = f... | python | def stft_from_frames(frames, window='hann', dtype=np.complex64):
"""
Variation of the librosa.core.stft function,
that computes the short-time-fourier-transfrom from frames instead from the signal.
See http://librosa.github.io/librosa/_modules/librosa/core/spectrum.html#stft
"""
win_length = f... | [
"def",
"stft_from_frames",
"(",
"frames",
",",
"window",
"=",
"'hann'",
",",
"dtype",
"=",
"np",
".",
"complex64",
")",
":",
"win_length",
"=",
"frames",
".",
"shape",
"[",
"0",
"]",
"n_fft",
"=",
"win_length",
"fft_window",
"=",
"filters",
".",
"get_win... | Variation of the librosa.core.stft function,
that computes the short-time-fourier-transfrom from frames instead from the signal.
See http://librosa.github.io/librosa/_modules/librosa/core/spectrum.html#stft | [
"Variation",
"of",
"the",
"librosa",
".",
"core",
".",
"stft",
"function",
"that",
"computes",
"the",
"short",
"-",
"time",
"-",
"fourier",
"-",
"transfrom",
"from",
"frames",
"instead",
"from",
"the",
"signal",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/processing/pipeline/spectral.py#L10-L43 | train |
ynop/audiomate | audiomate/corpus/validation/combine.py | CombinedValidator.validate | def validate(self, corpus):
"""
Perform validation on the given corpus.
Args:
corpus (Corpus): The corpus to test/validate.
"""
passed = True
results = {}
for validator in self.validators:
sub_result = validator.validate(corpus)
... | python | def validate(self, corpus):
"""
Perform validation on the given corpus.
Args:
corpus (Corpus): The corpus to test/validate.
"""
passed = True
results = {}
for validator in self.validators:
sub_result = validator.validate(corpus)
... | [
"def",
"validate",
"(",
"self",
",",
"corpus",
")",
":",
"passed",
"=",
"True",
"results",
"=",
"{",
"}",
"for",
"validator",
"in",
"self",
".",
"validators",
":",
"sub_result",
"=",
"validator",
".",
"validate",
"(",
"corpus",
")",
"results",
"[",
"va... | Perform validation on the given corpus.
Args:
corpus (Corpus): The corpus to test/validate. | [
"Perform",
"validation",
"on",
"the",
"given",
"corpus",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/corpus/validation/combine.py#L48-L66 | train |
ynop/audiomate | audiomate/corpus/io/kaldi.py | KaldiWriter.feature_scp_generator | def feature_scp_generator(path):
""" Return a generator over all feature matrices defined in a scp. """
scp_entries = textfile.read_key_value_lines(path, separator=' ')
for utterance_id, rx_specifier in scp_entries.items():
yield utterance_id, KaldiWriter.read_float_matrix(rx_speci... | python | def feature_scp_generator(path):
""" Return a generator over all feature matrices defined in a scp. """
scp_entries = textfile.read_key_value_lines(path, separator=' ')
for utterance_id, rx_specifier in scp_entries.items():
yield utterance_id, KaldiWriter.read_float_matrix(rx_speci... | [
"def",
"feature_scp_generator",
"(",
"path",
")",
":",
"scp_entries",
"=",
"textfile",
".",
"read_key_value_lines",
"(",
"path",
",",
"separator",
"=",
"' '",
")",
"for",
"utterance_id",
",",
"rx_specifier",
"in",
"scp_entries",
".",
"items",
"(",
")",
":",
... | Return a generator over all feature matrices defined in a scp. | [
"Return",
"a",
"generator",
"over",
"all",
"feature",
"matrices",
"defined",
"in",
"a",
"scp",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/corpus/io/kaldi.py#L261-L267 | train |
ynop/audiomate | audiomate/corpus/io/kaldi.py | KaldiWriter.read_float_matrix | def read_float_matrix(rx_specifier):
""" Return float matrix as np array for the given rx specifier. """
path, offset = rx_specifier.strip().split(':', maxsplit=1)
offset = int(offset)
sample_format = 4
with open(path, 'rb') as f:
# move to offset
f.seek... | python | def read_float_matrix(rx_specifier):
""" Return float matrix as np array for the given rx specifier. """
path, offset = rx_specifier.strip().split(':', maxsplit=1)
offset = int(offset)
sample_format = 4
with open(path, 'rb') as f:
# move to offset
f.seek... | [
"def",
"read_float_matrix",
"(",
"rx_specifier",
")",
":",
"path",
",",
"offset",
"=",
"rx_specifier",
".",
"strip",
"(",
")",
".",
"split",
"(",
"':'",
",",
"maxsplit",
"=",
"1",
")",
"offset",
"=",
"int",
"(",
"offset",
")",
"sample_format",
"=",
"4"... | Return float matrix as np array for the given rx specifier. | [
"Return",
"float",
"matrix",
"as",
"np",
"array",
"for",
"the",
"given",
"rx",
"specifier",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/corpus/io/kaldi.py#L270-L303 | train |
ynop/audiomate | audiomate/feeding/partitioning.py | PartitioningContainerLoader.reload | def reload(self):
"""
Create a new partition scheme. A scheme defines which utterances are in which partition.
The scheme only changes after every call if ``self.shuffle == True``.
Returns:
list: List of PartitionInfo objects, defining the new partitions (same as ``self.part... | python | def reload(self):
"""
Create a new partition scheme. A scheme defines which utterances are in which partition.
The scheme only changes after every call if ``self.shuffle == True``.
Returns:
list: List of PartitionInfo objects, defining the new partitions (same as ``self.part... | [
"def",
"reload",
"(",
"self",
")",
":",
"utt_ids",
"=",
"sorted",
"(",
"self",
".",
"utt_ids",
")",
"if",
"self",
".",
"shuffle",
":",
"self",
".",
"rand",
".",
"shuffle",
"(",
"utt_ids",
")",
"partitions",
"=",
"[",
"]",
"current_partition",
"=",
"P... | Create a new partition scheme. A scheme defines which utterances are in which partition.
The scheme only changes after every call if ``self.shuffle == True``.
Returns:
list: List of PartitionInfo objects, defining the new partitions (same as ``self.partitions``) | [
"Create",
"a",
"new",
"partition",
"scheme",
".",
"A",
"scheme",
"defines",
"which",
"utterances",
"are",
"in",
"which",
"partition",
".",
"The",
"scheme",
"only",
"changes",
"after",
"every",
"call",
"if",
"self",
".",
"shuffle",
"==",
"True",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/feeding/partitioning.py#L91-L128 | train |
ynop/audiomate | audiomate/feeding/partitioning.py | PartitioningContainerLoader.load_partition_data | def load_partition_data(self, index):
"""
Load and return the partition with the given index.
Args:
index (int): The index of partition, that refers to the index in ``self.partitions``.
Returns:
PartitionData: A PartitionData object containing the data for the p... | python | def load_partition_data(self, index):
"""
Load and return the partition with the given index.
Args:
index (int): The index of partition, that refers to the index in ``self.partitions``.
Returns:
PartitionData: A PartitionData object containing the data for the p... | [
"def",
"load_partition_data",
"(",
"self",
",",
"index",
")",
":",
"info",
"=",
"self",
".",
"partitions",
"[",
"index",
"]",
"data",
"=",
"PartitionData",
"(",
"info",
")",
"for",
"utt_id",
"in",
"info",
".",
"utt_ids",
":",
"utt_data",
"=",
"[",
"c",... | Load and return the partition with the given index.
Args:
index (int): The index of partition, that refers to the index in ``self.partitions``.
Returns:
PartitionData: A PartitionData object containing the data for the partition with the given index. | [
"Load",
"and",
"return",
"the",
"partition",
"with",
"the",
"given",
"index",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/feeding/partitioning.py#L130-L148 | train |
ynop/audiomate | audiomate/feeding/partitioning.py | PartitioningContainerLoader._raise_error_if_container_is_missing_an_utterance | def _raise_error_if_container_is_missing_an_utterance(self):
""" Check if there is a dataset for every utterance in every container, otherwise raise an error. """
expected_keys = frozenset(self.utt_ids)
for cnt in self.containers:
keys = set(cnt.keys())
if not keys.issu... | python | def _raise_error_if_container_is_missing_an_utterance(self):
""" Check if there is a dataset for every utterance in every container, otherwise raise an error. """
expected_keys = frozenset(self.utt_ids)
for cnt in self.containers:
keys = set(cnt.keys())
if not keys.issu... | [
"def",
"_raise_error_if_container_is_missing_an_utterance",
"(",
"self",
")",
":",
"expected_keys",
"=",
"frozenset",
"(",
"self",
".",
"utt_ids",
")",
"for",
"cnt",
"in",
"self",
".",
"containers",
":",
"keys",
"=",
"set",
"(",
"cnt",
".",
"keys",
"(",
")",... | Check if there is a dataset for every utterance in every container, otherwise raise an error. | [
"Check",
"if",
"there",
"is",
"a",
"dataset",
"for",
"every",
"utterance",
"in",
"every",
"container",
"otherwise",
"raise",
"an",
"error",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/feeding/partitioning.py#L150-L158 | train |
ynop/audiomate | audiomate/feeding/partitioning.py | PartitioningContainerLoader._scan | def _scan(self):
""" For every utterance, calculate the size it will need in memory. """
utt_sizes = {}
for dset_name in self.utt_ids:
per_container = []
for cnt in self.containers:
dset = cnt._file[dset_name]
dtype_size = dset.dtype.item... | python | def _scan(self):
""" For every utterance, calculate the size it will need in memory. """
utt_sizes = {}
for dset_name in self.utt_ids:
per_container = []
for cnt in self.containers:
dset = cnt._file[dset_name]
dtype_size = dset.dtype.item... | [
"def",
"_scan",
"(",
"self",
")",
":",
"utt_sizes",
"=",
"{",
"}",
"for",
"dset_name",
"in",
"self",
".",
"utt_ids",
":",
"per_container",
"=",
"[",
"]",
"for",
"cnt",
"in",
"self",
".",
"containers",
":",
"dset",
"=",
"cnt",
".",
"_file",
"[",
"ds... | For every utterance, calculate the size it will need in memory. | [
"For",
"every",
"utterance",
"calculate",
"the",
"size",
"it",
"will",
"need",
"in",
"memory",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/feeding/partitioning.py#L160-L181 | train |
ynop/audiomate | audiomate/feeding/partitioning.py | PartitioningContainerLoader._get_all_lengths | def _get_all_lengths(self):
""" For every utterance, get the length of the data in every container. Return a list of tuples. """
utt_lengths = {}
for utt_idx in self.utt_ids:
per_container = [c._file[utt_idx].shape[0] for c in self.containers]
utt_lengths[utt_idx] = tupl... | python | def _get_all_lengths(self):
""" For every utterance, get the length of the data in every container. Return a list of tuples. """
utt_lengths = {}
for utt_idx in self.utt_ids:
per_container = [c._file[utt_idx].shape[0] for c in self.containers]
utt_lengths[utt_idx] = tupl... | [
"def",
"_get_all_lengths",
"(",
"self",
")",
":",
"utt_lengths",
"=",
"{",
"}",
"for",
"utt_idx",
"in",
"self",
".",
"utt_ids",
":",
"per_container",
"=",
"[",
"c",
".",
"_file",
"[",
"utt_idx",
"]",
".",
"shape",
"[",
"0",
"]",
"for",
"c",
"in",
"... | For every utterance, get the length of the data in every container. Return a list of tuples. | [
"For",
"every",
"utterance",
"get",
"the",
"length",
"of",
"the",
"data",
"in",
"every",
"container",
".",
"Return",
"a",
"list",
"of",
"tuples",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/feeding/partitioning.py#L183-L191 | train |
ynop/audiomate | audiomate/processing/pipeline/base.py | Buffer.update | def update(self, data, offset, is_last, buffer_index=0):
"""
Update the buffer at the given index.
Args:
data (np.ndarray): The frames.
offset (int): The index of the first frame in `data` within the sequence.
is_last (bool): Whether this is the last block of... | python | def update(self, data, offset, is_last, buffer_index=0):
"""
Update the buffer at the given index.
Args:
data (np.ndarray): The frames.
offset (int): The index of the first frame in `data` within the sequence.
is_last (bool): Whether this is the last block of... | [
"def",
"update",
"(",
"self",
",",
"data",
",",
"offset",
",",
"is_last",
",",
"buffer_index",
"=",
"0",
")",
":",
"if",
"buffer_index",
">=",
"self",
".",
"num_buffers",
":",
"raise",
"ValueError",
"(",
"'Expected buffer index < {} but got index {}.'",
".",
"... | Update the buffer at the given index.
Args:
data (np.ndarray): The frames.
offset (int): The index of the first frame in `data` within the sequence.
is_last (bool): Whether this is the last block of frames in the sequence.
buffer_index (int): The index of the buf... | [
"Update",
"the",
"buffer",
"at",
"the",
"given",
"index",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/processing/pipeline/base.py#L113-L137 | train |
ynop/audiomate | audiomate/processing/pipeline/base.py | Buffer.get | def get(self):
"""
Get a new chunk if available.
Returns:
Chunk or list: If enough frames are available a chunk is returned. Otherwise None.
If ``self.num_buffer >= 1`` a list instead of single chunk is returned.
"""
chunk_size = self._smal... | python | def get(self):
"""
Get a new chunk if available.
Returns:
Chunk or list: If enough frames are available a chunk is returned. Otherwise None.
If ``self.num_buffer >= 1`` a list instead of single chunk is returned.
"""
chunk_size = self._smal... | [
"def",
"get",
"(",
"self",
")",
":",
"chunk_size",
"=",
"self",
".",
"_smallest_buffer",
"(",
")",
"all_full",
"=",
"self",
".",
"_all_full",
"(",
")",
"if",
"all_full",
":",
"right_context",
"=",
"0",
"num_frames",
"=",
"chunk_size",
"-",
"self",
".",
... | Get a new chunk if available.
Returns:
Chunk or list: If enough frames are available a chunk is returned. Otherwise None.
If ``self.num_buffer >= 1`` a list instead of single chunk is returned. | [
"Get",
"a",
"new",
"chunk",
"if",
"available",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/processing/pipeline/base.py#L139-L180 | train |
ynop/audiomate | audiomate/processing/pipeline/base.py | Buffer._smallest_buffer | def _smallest_buffer(self):
"""
Get the size of the smallest buffer.
"""
smallest = np.inf
for buffer in self.buffers:
if buffer is None:
return 0
elif buffer.shape[0] < smallest:
smallest = buffer.shape[0]
return... | python | def _smallest_buffer(self):
"""
Get the size of the smallest buffer.
"""
smallest = np.inf
for buffer in self.buffers:
if buffer is None:
return 0
elif buffer.shape[0] < smallest:
smallest = buffer.shape[0]
return... | [
"def",
"_smallest_buffer",
"(",
"self",
")",
":",
"smallest",
"=",
"np",
".",
"inf",
"for",
"buffer",
"in",
"self",
".",
"buffers",
":",
"if",
"buffer",
"is",
"None",
":",
"return",
"0",
"elif",
"buffer",
".",
"shape",
"[",
"0",
"]",
"<",
"smallest",... | Get the size of the smallest buffer. | [
"Get",
"the",
"size",
"of",
"the",
"smallest",
"buffer",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/processing/pipeline/base.py#L182-L195 | train |
ynop/audiomate | audiomate/processing/pipeline/base.py | Step.process_frames | def process_frames(self, data, sampling_rate, offset=0, last=False, utterance=None, corpus=None):
"""
Execute the processing of this step and all dependent parent steps.
"""
if offset == 0:
self.steps_sorted = list(nx.algorithms.dag.topological_sort(self.graph))
... | python | def process_frames(self, data, sampling_rate, offset=0, last=False, utterance=None, corpus=None):
"""
Execute the processing of this step and all dependent parent steps.
"""
if offset == 0:
self.steps_sorted = list(nx.algorithms.dag.topological_sort(self.graph))
... | [
"def",
"process_frames",
"(",
"self",
",",
"data",
",",
"sampling_rate",
",",
"offset",
"=",
"0",
",",
"last",
"=",
"False",
",",
"utterance",
"=",
"None",
",",
"corpus",
"=",
"None",
")",
":",
"if",
"offset",
"==",
"0",
":",
"self",
".",
"steps_sort... | Execute the processing of this step and all dependent parent steps. | [
"Execute",
"the",
"processing",
"of",
"this",
"step",
"and",
"all",
"dependent",
"parent",
"steps",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/processing/pipeline/base.py#L237-L264 | train |
ynop/audiomate | audiomate/processing/pipeline/base.py | Step._update_buffers | def _update_buffers(self, from_step, data, offset, is_last):
"""
Update the buffers of all steps that need data from ``from_step``.
If ``from_step`` is None it means the data is the input data.
"""
for to_step, buffer in self.target_buffers[from_step]:
parent_index =... | python | def _update_buffers(self, from_step, data, offset, is_last):
"""
Update the buffers of all steps that need data from ``from_step``.
If ``from_step`` is None it means the data is the input data.
"""
for to_step, buffer in self.target_buffers[from_step]:
parent_index =... | [
"def",
"_update_buffers",
"(",
"self",
",",
"from_step",
",",
"data",
",",
"offset",
",",
"is_last",
")",
":",
"for",
"to_step",
",",
"buffer",
"in",
"self",
".",
"target_buffers",
"[",
"from_step",
"]",
":",
"parent_index",
"=",
"0",
"if",
"isinstance",
... | Update the buffers of all steps that need data from ``from_step``.
If ``from_step`` is None it means the data is the input data. | [
"Update",
"the",
"buffers",
"of",
"all",
"steps",
"that",
"need",
"data",
"from",
"from_step",
".",
"If",
"from_step",
"is",
"None",
"it",
"means",
"the",
"data",
"is",
"the",
"input",
"data",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/processing/pipeline/base.py#L327-L340 | train |
ynop/audiomate | audiomate/processing/pipeline/base.py | Step._define_output_buffers | def _define_output_buffers(self):
"""
Prepare a dictionary so we know what buffers have to be update with the the output of every step.
"""
# First define buffers that need input data
self.target_buffers = {
None: [(step, self.buffers[step]) for step in self._get_inp... | python | def _define_output_buffers(self):
"""
Prepare a dictionary so we know what buffers have to be update with the the output of every step.
"""
# First define buffers that need input data
self.target_buffers = {
None: [(step, self.buffers[step]) for step in self._get_inp... | [
"def",
"_define_output_buffers",
"(",
"self",
")",
":",
"self",
".",
"target_buffers",
"=",
"{",
"None",
":",
"[",
"(",
"step",
",",
"self",
".",
"buffers",
"[",
"step",
"]",
")",
"for",
"step",
"in",
"self",
".",
"_get_input_steps",
"(",
")",
"]",
"... | Prepare a dictionary so we know what buffers have to be update with the the output of every step. | [
"Prepare",
"a",
"dictionary",
"so",
"we",
"know",
"what",
"buffers",
"have",
"to",
"be",
"update",
"with",
"the",
"the",
"output",
"of",
"every",
"step",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/processing/pipeline/base.py#L342-L356 | train |
ynop/audiomate | audiomate/processing/pipeline/base.py | Step._get_input_steps | def _get_input_steps(self):
"""
Search and return all steps that have no parents. These are the steps that are get the input data.
"""
input_steps = []
for step in self.steps_sorted:
parent_steps = self._parent_steps(step)
if len(parent_steps) == 0:
... | python | def _get_input_steps(self):
"""
Search and return all steps that have no parents. These are the steps that are get the input data.
"""
input_steps = []
for step in self.steps_sorted:
parent_steps = self._parent_steps(step)
if len(parent_steps) == 0:
... | [
"def",
"_get_input_steps",
"(",
"self",
")",
":",
"input_steps",
"=",
"[",
"]",
"for",
"step",
"in",
"self",
".",
"steps_sorted",
":",
"parent_steps",
"=",
"self",
".",
"_parent_steps",
"(",
"step",
")",
"if",
"len",
"(",
"parent_steps",
")",
"==",
"0",
... | Search and return all steps that have no parents. These are the steps that are get the input data. | [
"Search",
"and",
"return",
"all",
"steps",
"that",
"have",
"no",
"parents",
".",
"These",
"are",
"the",
"steps",
"that",
"are",
"get",
"the",
"input",
"data",
"."
] | 61727920b23a708293c3d526fa3000d4de9c6c21 | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/processing/pipeline/base.py#L358-L370 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.