_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 31 13.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q249200 | LabelList.join | train | 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 | {
"resource": ""
} |
q249201 | LabelList.separated | train | 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 | {
"resource": ""
} |
q249202 | LabelList.labels_in_range | train | 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 | {
"resource": ""
} |
q249203 | LabelList.ranges | train | 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 | {
"resource": ""
} |
q249204 | LabelList.create_single | train | def create_single(cls, value, idx='default'):
""" Create a label-list with a single label | python | {
"resource": ""
} |
q249205 | MailabsReader.get_folders | train | 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)
| python | {
"resource": ""
} |
q249206 | MailabsReader.load_tag | train | 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 | {
"resource": ""
} |
q249207 | MailabsReader.load_speaker | train | 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 | {
"resource": ""
} |
q249208 | MailabsReader.load_books_of_speaker | train | 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 | {
"resource": ""
} |
q249209 | Container.open | train | 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 | {
"resource": ""
} |
q249210 | Container.open_if_needed | train | 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 | {
"resource": ""
} |
q249211 | Container.get | train | 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 | {
"resource": ""
} |
q249212 | Container.remove | train | 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.
| python | {
"resource": ""
} |
q249213 | Utterance.end_abs | train | def end_abs(self):
"""
Return the absolute end of the utterance relative to the signal.
| python | {
"resource": ""
} |
q249214 | Utterance.num_samples | train | 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
"""
| python | {
"resource": ""
} |
q249215 | Utterance.read_samples | train | 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 | {
"resource": ""
} |
q249216 | Utterance.set_label_list | train | 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:
| python | {
"resource": ""
} |
q249217 | Utterance.all_label_values | train | 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 | {
"resource": ""
} |
q249218 | Utterance.label_count | train | 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 | {
"resource": ""
} |
q249219 | Utterance.all_tokens | train | 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 | {
"resource": ""
} |
q249220 | Utterance.label_total_duration | train | 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 | {
"resource": ""
} |
q249221 | FeatureContainer.stats | train | 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.
| python | {
"resource": ""
} |
q249222 | FeatureContainer.stats_per_key | train | 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 | {
"resource": ""
} |
q249223 | CorpusView.all_label_values | train | 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 | {
"resource": ""
} |
q249224 | CorpusView.label_count | train | 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 | {
"resource": ""
} |
q249225 | CorpusView.label_durations | train | 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 | {
"resource": ""
} |
q249226 | CorpusView.all_tokens | train | 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 | {
"resource": ""
} |
q249227 | CorpusView.total_duration | train | def total_duration(self):
"""
Return the total amount of audio summed over all utterances in the corpus in seconds. | python | {
"resource": ""
} |
q249228 | CorpusView.stats | train | 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.
| python | {
"resource": ""
} |
q249229 | CorpusView.stats_per_utterance | train | 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 | {
"resource": ""
} |
q249230 | CorpusView.split_utterances_to_max_time | train | 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 | {
"resource": ""
} |
q249231 | MultiFrameDataset.get_utt_regions | train | 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 | {
"resource": ""
} |
q249232 | AudioContainer.get | train | 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 | {
"resource": ""
} |
q249233 | AudioContainer.set | train | 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 | {
"resource": ""
} |
q249234 | AudioContainer.append | train | 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 | {
"resource": ""
} |
q249235 | VoxforgeDownloader.available_files | train | 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 | {
"resource": ""
} |
q249236 | VoxforgeDownloader.download_files | train | 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 | {
"resource": ""
} |
q249237 | VoxforgeDownloader.extract_files | train | 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 | {
"resource": ""
} |
q249238 | index_name_if_in_list | train | 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 | {
"resource": ""
} |
q249239 | generate_name | train | 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 | {
"resource": ""
} |
q249240 | create_downloader_of_type | train | 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()
| python | {
"resource": ""
} |
q249241 | create_reader_of_type | train | 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 = | python | {
"resource": ""
} |
q249242 | create_writer_of_type | train | 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 = | python | {
"resource": ""
} |
q249243 | Subview.serialize | train | 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: | python | {
"resource": ""
} |
q249244 | stft_from_frames | train | 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 | {
"resource": ""
} |
q249245 | CombinedValidator.validate | train | 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 | python | {
"resource": ""
} |
q249246 | KaldiWriter.feature_scp_generator | train | def feature_scp_generator(path):
""" Return a generator over all feature matrices defined in a scp. """
scp_entries = | python | {
"resource": ""
} |
q249247 | KaldiWriter.read_float_matrix | train | 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 | {
"resource": ""
} |
q249248 | PartitioningContainerLoader.reload | train | 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 | {
"resource": ""
} |
q249249 | PartitioningContainerLoader.load_partition_data | train | 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 | {
"resource": ""
} |
q249250 | PartitioningContainerLoader._raise_error_if_container_is_missing_an_utterance | train | 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:
| python | {
"resource": ""
} |
q249251 | PartitioningContainerLoader._scan | train | 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 | {
"resource": ""
} |
q249252 | PartitioningContainerLoader._get_all_lengths | train | 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:
| python | {
"resource": ""
} |
q249253 | Buffer.update | train | 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 | {
"resource": ""
} |
q249254 | Buffer.get | train | 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 | {
"resource": ""
} |
q249255 | Buffer._smallest_buffer | train | def _smallest_buffer(self):
"""
Get the size of the smallest buffer.
"""
smallest = np.inf
for buffer in self.buffers:
if buffer is None:
| python | {
"resource": ""
} |
q249256 | Step.process_frames | train | 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 | {
"resource": ""
} |
q249257 | Step._update_buffers | train | 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 | {
"resource": ""
} |
q249258 | Step._define_output_buffers | train | 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 | {
"resource": ""
} |
q249259 | Step._get_input_steps | train | 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:
| python | {
"resource": ""
} |
q249260 | Step._create_buffers | train | def _create_buffers(self):
"""
Create a buffer for every step in the pipeline.
"""
self.buffers = {}
for step in self.graph.nodes():
num_buffers = 1
if isinstance(step, Reduction):
| python | {
"resource": ""
} |
q249261 | Corpus.save | train | def save(self, writer=None):
"""
If self.path is defined, it tries to save the corpus at the given path.
"""
if self.path is None:
| python | {
"resource": ""
} |
q249262 | Corpus.save_at | train | def save_at(self, path, writer=None):
"""
Save this corpus at the given path. If the path differs from the current path set, the path
gets updated.
Parameters:
path (str): Path to save the data set to.
writer (str, CorpusWriter): The writer or the name of the rea... | python | {
"resource": ""
} |
q249263 | Corpus.new_file | train | def new_file(self, path, track_idx, copy_file=False):
"""
Adds a new audio file to the corpus with the given data.
Parameters:
path (str): Path of the file to add.
track_idx (str): The id to associate the file-track with.
copy_file (bool): If True the file is... | python | {
"resource": ""
} |
q249264 | Corpus.new_utterance | train | def new_utterance(self, utterance_idx, track_idx, issuer_idx=None, start=0, end=float('inf')):
"""
Add a new utterance to the corpus with the given data.
Parameters:
track_idx (str): The track id the utterance is in.
utterance_idx (str): The id to associate with the utte... | python | {
"resource": ""
} |
q249265 | Corpus.new_issuer | train | def new_issuer(self, issuer_idx, info=None):
"""
Add a new issuer to the dataset with the given data.
Parameters:
issuer_idx (str): The id to associate the issuer with. If None or already exists, one is
generated.
info (dict, list): Addition... | python | {
"resource": ""
} |
q249266 | Corpus.new_feature_container | train | def new_feature_container(self, idx, path=None):
"""
Add a new feature container with the given data.
Parameters:
idx (str): An unique identifier within the dataset.
path (str): The path to store the feature file. If None a default path is used.
Returns:
... | python | {
"resource": ""
} |
q249267 | Corpus.import_subview | train | def import_subview(self, idx, subview):
"""
Add the given subview to the corpus.
Args:
idx (str): An idx that is unique in the corpus for identifying the subview.
If already a subview exists with the given id | python | {
"resource": ""
} |
q249268 | Corpus.relocate_audio_to_single_container | train | def relocate_audio_to_single_container(self, target_path):
"""
Copies every track to a single container.
Afterwards all tracks in the container are linked against
this single container.
"""
cont = containers.AudioContainer(target_path)
cont.open()
new_tr... | python | {
"resource": ""
} |
q249269 | Corpus.from_corpus | train | def from_corpus(cls, corpus):
"""
Create a new modifiable corpus from any other CorpusView.
This for example can be used to create a independent modifiable corpus from a subview.
Args:
corpus (CorpusView): The corpus to create a copy from.
Returns:
Corpu... | python | {
"resource": ""
} |
q249270 | Corpus.merge_corpora | train | def merge_corpora(cls, corpora):
"""
Merge a list of corpora into one.
Args:
corpora (Iterable): An iterable of :py:class:`audiomate.corpus.CorpusView`.
Returns:
Corpus: A corpus with the data from all given corpora merged into one.
| python | {
"resource": ""
} |
q249271 | CommonVoiceReader.load_subset | train | def load_subset(corpus, path, subset_idx):
""" Load subset into corpus. """
csv_file = os.path.join(path, '{}.tsv'.format(subset_idx))
subset_utt_ids = []
entries = textfile.read_separated_lines_generator(
csv_file,
separator='\t',
max_columns=8,
... | python | {
"resource": ""
} |
q249272 | CommonVoiceReader.map_age | train | def map_age(age):
""" Map age to correct age-group. """
if age in [None, '']:
return issuers.AgeGroup.UNKNOWN
elif age == 'teens':
return issuers.AgeGroup.YOUTH
| python | {
"resource": ""
} |
q249273 | CommonVoiceReader.map_gender | train | def map_gender(gender):
""" Map gender to correct value. """
if gender == 'male':
return issuers.Gender.MALE
elif gender == 'female': | python | {
"resource": ""
} |
q249274 | FrameSettings.num_frames | train | def num_frames(self, num_samples):
"""
Return the number of frames that will be used for a signal with the length of ``num_samples``.
"""
| python | {
"resource": ""
} |
q249275 | FrameSettings.frame_to_seconds | train | def frame_to_seconds(self, frame_index, sr):
"""
Return a tuple containing the start and end of the frame in seconds.
"""
start_sample, | python | {
"resource": ""
} |
q249276 | FrameSettings.time_range_to_frame_range | train | def time_range_to_frame_range(self, start, end, sr):
"""
Calculate the frames containing samples from the given time range in seconds.
Args:
start (float): Start time in seconds.
end (float): End time in seconds.
| python | {
"resource": ""
} |
q249277 | Processor._process_corpus | train | def _process_corpus(self, corpus, output_path, processing_func, frame_size=400, hop_size=160, sr=None):
""" Utility function for processing a corpus with a separate processing function. """
feat_container = containers.FeatureContainer(output_path)
feat_container.open()
sampling_rate = -... | python | {
"resource": ""
} |
q249278 | process_buffer | train | def process_buffer(buffer, n_channels):
"""
Merge the read blocks and resample if necessary.
Args:
buffer (list): A list of blocks of samples.
n_channels (int): The number of channels of the input data.
Returns:
np.array: The samples
"""
samples = | python | {
"resource": ""
} |
q249279 | read_blocks | train | def read_blocks(file_path, start=0.0, end=float('inf'), buffer_size=5760000):
"""
Read an audio file block after block. The blocks are yielded one by one.
Args:
file_path (str): Path to the file to read.
start (float): Start in seconds to read from.
end (float): End in seconds to re... | python | {
"resource": ""
} |
q249280 | read_frames | train | def read_frames(file_path, frame_size, hop_size, start=0.0,
end=float('inf'), buffer_size=5760000):
"""
Read an audio file frame by frame. The frames are yielded one after another.
Args:
file_path (str): Path to the file to read.
frame_size (int): The number of samples per f... | python | {
"resource": ""
} |
q249281 | write_wav | train | def write_wav(path, samples, sr=16000):
"""
Write to given samples to a wav file.
The samples are expected to be floating point numbers
in the range of -1.0 to 1.0.
Args:
path (str): The path to write the wav to.
samples (np.array): A float array .
| python | {
"resource": ""
} |
q249282 | DataStats.to_dict | train | def to_dict(self):
"""
Return the stats as a dictionary.
"""
return {
'mean': self.mean,
'var': self.var,
| python | {
"resource": ""
} |
q249283 | DataStats.concatenate | train | def concatenate(cls, list_of_stats):
"""
Take a list of stats from different sets of data points and
merge the stats for getting stats overall data points.
Args:
list_of_stats (iterable): A list containing stats for different sets of data points.
Returns:
... | python | {
"resource": ""
} |
q249284 | generate_corpus | train | def generate_corpus(n_issuers,
n_tracks_per_issuer,
n_utts_per_track,
n_ll_per_utt,
n_label_per_ll,
rand=None):
"""
Generate a corpus with mock data.
"""
corpus = audiomate.Corpus()
for issuer in gen... | python | {
"resource": ""
} |
q249285 | SpeechCommandsReader._create_subviews | train | def _create_subviews(path, corpus):
""" Load the subviews based on testing_list.txt and validation_list.txt """
test_list_path = os.path.join(path, 'testing_list.txt')
dev_list_path = os.path.join(path, 'validation_list.txt')
test_list = textfile.read_separated_lines(test_list_path, sep... | python | {
"resource": ""
} |
q249286 | write_label_list | train | def write_label_list(path, label_list):
"""
Writes the given `label_list` to an audacity label file.
Args:
path (str): Path to write the file to.
label_list (audiomate.annotations.LabelList): Label list
"""
entries = []
for label in label_list:
| python | {
"resource": ""
} |
q249287 | read_label_file | train | def read_label_file(path):
"""
Read the labels from an audacity label file.
Args:
path (str): Path to the label file.
Returns:
list: List of labels (start [sec], end [sec], label)
Example::
>>> read_label_file('/path/to/label/file.txt')
| python | {
"resource": ""
} |
q249288 | extract_zip | train | def extract_zip(zip_path, target_folder):
"""
Extract the content of the zip-file at `zip_path` into `target_folder`.
""" | python | {
"resource": ""
} |
q249289 | extract_tar | train | def extract_tar(tar_path, target_folder):
"""
Extract the content of the tar-file at `tar_path` into `target_folder`.
""" | python | {
"resource": ""
} |
q249290 | read_separated_lines | train | def read_separated_lines(path, separator=' ', max_columns=-1, keep_empty=False):
"""
Reads a text file where each line represents a record with some separated columns.
Parameters:
path (str): Path to the file to read.
separator (str): Separator that is used to split the columns.
max... | python | {
"resource": ""
} |
q249291 | read_separated_lines_with_first_key | train | def read_separated_lines_with_first_key(path: str, separator: str = ' ', max_columns: int = -1,
keep_empty: bool = False):
"""
Reads the separated lines of a file and return a dictionary with the first column as keys, value
is a list with the rest of the columns.
... | python | {
"resource": ""
} |
q249292 | write_separated_lines | train | def write_separated_lines(path, values, separator=' ', sort_by_column=0):
"""
Writes list or dict to file line by line. Dict can have list as value then they written
separated on the line.
Parameters:
path (str): Path to write file to.
values (dict, list): A dictionary or a list to writ... | python | {
"resource": ""
} |
q249293 | read_separated_lines_generator | train | def read_separated_lines_generator(path, separator=' ', max_columns=-1,
ignore_lines_starting_with=[], keep_empty=False):
"""
Creates a generator through all lines of a file and returns the splitted line.
Parameters:
path: Path to the file.
separator: Sepa... | python | {
"resource": ""
} |
q249294 | Forms.update | train | def update(self, uid: str, patch=False, data: any = {}) -> typing.Union[str, dict]:
"""
Updates an existing form.
Defaults to `put`.
`put` will return the modified form as | python | {
"resource": ""
} |
q249295 | Storage.configure | train | def configure(self, app):
'''
Load configuration from application configuration.
For each storage, the configuration is loaded with the following pattern::
FS_{BACKEND_NAME}_{KEY} then
{STORAGE_NAME}_FS_{KEY}
If no configuration is set for a given key, global c... | python | {
"resource": ""
} |
q249296 | Storage.base_url | train | def base_url(self):
'''The public URL for this storage'''
config_value = self.config.get('url')
if config_value:
return self._clean_url(config_value)
default_url = current_app.config.get('FS_URL')
| python | {
"resource": ""
} |
q249297 | Storage.url | train | def url(self, filename, external=False):
'''
This function gets the URL a file uploaded to this set would be
accessed at. It doesn't check whether said file exists.
:param string filename: The filename to return the URL for.
:param bool external: If True, returns an absolute URL... | python | {
"resource": ""
} |
q249298 | Storage.path | train | def path(self, filename):
'''
This returns the absolute path of a file uploaded to this set. It
doesn't actually check whether said file exists.
:param filename: The filename to return the path for.
:param folder: The subfolder within the upload set previously used
... | python | {
"resource": ""
} |
q249299 | Storage.read | train | def read(self, filename):
'''
Read a file content.
:param string filename: The storage root-relative filename
| python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.