Parlatype.Config¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
|---|---|---|---|
r/w/co |
|||
r |
|||
r |
|||
r |
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
|---|---|---|---|
parent_instance |
r |
Class Details¶
- class Parlatype.Config(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
- classmethod new(file)¶
- Parameters:
file (
Gio.File) – a file with configuration settings in .ini-like format- Returns:
a new
Parlatype.Config- Return type:
Returns a new configuration instance for the given file. The configuration is immediately checked for formal validity. This can be queried with
Parlatype.Config.is_valid() or the propertyParlatype.Config:is-valid. The property doesn’t change anymore.If the configuration is not valid, all methods are no-operations and return
FalseorNone.After use
GObject.Object.unref() it.New in version 3.0.
- apply(plugin)¶
- Parameters:
plugin (
GObject.Object) – the GStreamer ASR plugin- Raises:
- Returns:
- Return type:
Applies a configuration to a GStreamer plugin.
New in version 3.0.
- get_base_folder()¶
-
Gets the configuration’s base folder. If the model is not installed, the base folder is not set and the return value is
None. Another reason for returningNoneis an invalid configuration, checkParlatype.Config:is-validfor that.New in version 3.0.
- get_file()¶
- Returns:
the file this object is based on
- Return type:
The
Gio.Filethat storing the configuration.New in version 3.0.
- get_key(key)¶
- Parameters:
key (
str) – the name of a key in the [Model] group- Returns:
the key’s value as a string or
None- Return type:
Get other optional keys in the [Model] group. All keys are assumed to be strings. If the key is not set,
Noneis returned.New in version 3.0.
- get_lang_code()¶
- Returns:
the language code as a string
- Return type:
Gets the language the model was made for. It’s the ISO 639-1 code (2 letters) if available, otherwise ISO 639-2 (3 letters).
New in version 3.0.
- get_lang_name()¶
- Returns:
the language code as a string
- Return type:
Gets the localized name of the language the model was made for.
New in version 3.0.
- get_name()¶
- Returns:
the configuration’s name as a string
- Return type:
The human-visible name to identify a configuration.
New in version 3.0.
- get_plugin()¶
- Returns:
the plugin’s name as a string
- Return type:
Gets the name of the GStreamer plugin the configuration is intended for. It has to be exactly the string GStreamer uses to instantiate the plugin.
New in version 3.0.
- is_installed()¶
-
Checks whether the model is installed, that means the base folder exists and all files listed in the configuration are located inside the base folder.
New in version 3.0.
- is_valid()¶
-
Checks if a configuration is formally valid:
It has a version string of the form 1.x (major.minor). Major versions higher than 1 are not understood by this version of libparlatype. Minor numbers are supposed to be compatible and are checked only for existence
It has the following groups: [Model], [Files]. A [Parameters] group is optional.
[Model] has the following keys: Name, Plugin, BaseFolder, Language.
[Files] has at least one key.
All keys have non-empty values, except BaseFolder, which might be empty.
What is not tested:
Optional (URL) or unknown groups or keys
Order of groups and keys.
If BaseFolder is set.
If the language code exists.
If files and paths in [Files] are formally valid (relative paths with a slash as separator, e.g. subdir/subdir/file.name)
If files and paths exist on the file system.
If the plugin is installed.
If the plugin supports given parameters.
New in version 3.0.
- set_base_folder(name)¶
- Parameters:
name (
str) – the new base folder- Returns:
- Return type:
Sets the configuration’s base folder.
New in version 3.0.
Property Details¶
- Parlatype.Config.props.file¶
- Name:
file- Type:
- Default Value:
- Flags:
The file that was used to construct the object and contains the configuration settings. This property is immutable and the file can not be reloaded.
- Parlatype.Config.props.is_installed¶
-
Indicates whether the language model is installed.
- Parlatype.Config.props.is_valid¶
-
Indicates whether the configuration is formally valid. See
Parlatype.Config.is_valid() for the checks done. This property is available from the very beginning and is immutable. You can not recover from an invalid state.