speechbrain.utils.superpowers moduleο
Superpowers which should be sparingly used.
This library contains functions for importing python files and for running shell commands. Remember, with great power comes great responsibility.
- Authors
Mirco Ravanelli 2020
Aku Rouhe 2021
Summaryο
Functions:
Import module from absolute path |
|
This function can be used to run a command in the bash shell. |
Referenceο
- speechbrain.utils.superpowers.import_from_path(path)[source]ο
Import module from absolute path
- Parameters:
path (str, pathlib.Path) β The path to the module to import
- Returns:
module β The loaded module
Implementation taken from
https (//docs.python.org/3/library/importlib.html#importing-a-source-file-directly)
- speechbrain.utils.superpowers.run_shell(cmd)[source]ο
This function can be used to run a command in the bash shell.
- Parameters:
cmd (str) β Shell command to run.
- Returns:
bytes β The captured standard output.
bytes β The captured standard error.
int β The returncode.
- Raises:
OSError β If returncode is not 0, i.e., command failed.
Example
>>> out, err, code = run_shell("echo 'hello world'") >>> _ = out.decode(errors="ignore")