Miscellaneous

Commands

opensoundscape.commands.run_command(cmd)

Run a command returning output, error

Parameters:cmd – A string containing some command
Returns:A tuple of standard out and standard error
Return type:(stdout, stderr)
opensoundscape.commands.run_command_return_code(cmd)

Run a command returning the return code

Parameters:cmd – A string containing some command
Returns:The return code of the function
Return type:return_code

Completions

Config

opensoundscape.config.get_default_config()

Get the default configuration file as a dictionary

Returns:A dictionary containing the default Opensoundscape configuration
Return type:dict
opensoundscape.config.validate(config)

Validate a configuration string

Parameters:config – A string containing an Opensoundscape configuration
Returns:A dictionary of the validated Opensoundscape configuration
Return type:dict
opensoundscape.config.validate_file(fname)

Validate a configuration file

Parameters:fname – A filename containing an Opensoundscape configuration
Returns:A dictionary of the validated Opensoundscape configuration
Return type:dict

Console

console.py: Entrypoint for opensoundscape

opensoundscape.console.build_docs()

Run sphinx-build for our project

opensoundscape.console.entrypoint()

The Opensoundscape entrypoint for console interaction

Console Checks

Utilities related to console checks on docopt args

Helpers

opensoundscape.helpers.binarize(x, threshold)

return a list of 0, 1 by thresholding vector x

opensoundscape.helpers.bound(x, bounds)

restrict x to a range of bounds = [min, max]

opensoundscape.helpers.file_name(path)

get file name without extension from a path

opensoundscape.helpers.hex_to_time(s)

convert a hexidecimal, Unix time string to a datetime timestamp

opensoundscape.helpers.isNan(x)

check for nan by equating x to itself

opensoundscape.helpers.jitter(x, width, distribution='gaussian')

Jitter (add random noise to) each value of x

Parameters:
  • x – scalar, array, or nd-array of numeric type
  • width – multiplier for random variable (stdev for ‘gaussian’ or r for ‘uniform’)
  • distribution – ‘gaussian’ (default) or ‘uniform’ if ‘gaussian’: draw jitter from gaussian with mu = 0, std = width if ‘uniform’: draw jitter from uniform on [-width, width]
Returns:

x + random jitter

Return type:

jittered_x

opensoundscape.helpers.linear_scale(array, in_range=(0, 1), out_range=(0, 255))

Translate from range in_range to out_range

Inputs:
in_range: The starting range [default: (0, 1)] out_range: The output range [default: (0, 255)]
Outputs:
new_array: A translated array
opensoundscape.helpers.min_max_scale(array, feature_range=(0, 1))

rescale vaues in an a array linearly to feature_range

opensoundscape.helpers.rescale_features(X, rescaling_vector=None)

rescale all features by dividing by the max value for each feature

optionally provide the rescaling vector (1xlen(X) np.array), so that you can rescale a new dataset consistently with an old one

returns rescaled feature set and rescaling vector

opensoundscape.helpers.run_command(cmd)

run a bash command with Popen, return response

opensoundscape.helpers.sigmoid(x)

sigmoid function