Parlatype.Config

g GObject.Object GObject.Object Parlatype.Config Parlatype.Config GObject.Object->Parlatype.Config

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new (file)

apply (plugin)

get_base_folder ()

get_file ()

get_key (key)

get_lang_code ()

get_lang_name ()

get_name ()

get_plugin ()

is_installed ()

is_valid ()

set_base_folder (name)

set_file (file)

set_name (name)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

file

Gio.File

r/w/co

is-installed

bool

r

is-valid

bool

r

name

str

r

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent_instance

GObject.Object

r

Class Details

class Parlatype.Config(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Parlatype.ConfigClass

classmethod new(file)
Parameters:

file (Gio.File) – a file with configuration settings in .ini-like format

Returns:

a new Parlatype.Config

Return type:

Parlatype.Config

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 property Parlatype.Config :is-valid. The property doesn’t change anymore.

If the configuration is not valid, all methods are no-operations and return False or None.

After use GObject.Object.unref() it.

New in version 3.0.

apply(plugin)
Parameters:

plugin (GObject.Object) – the GStreamer ASR plugin

Raises:

GLib.Error

Returns:

True on success, False if a parameter could not be set

Return type:

bool

Applies a configuration to a GStreamer plugin.

New in version 3.0.

get_base_folder()
Returns:

the configuaration’s base folder as a string or None

Return type:

str

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 returning None is an invalid configuration, check Parlatype.Config :is-valid for that.

New in version 3.0.

get_file()
Returns:

the file this object is based on

Return type:

Gio.File

The Gio.File that 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:

str

Get other optional keys in the [Model] group. All keys are assumed to be strings. If the key is not set, None is returned.

New in version 3.0.

get_lang_code()
Returns:

the language code as a string

Return type:

str

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:

str

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:

str

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:

str

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()
Returns:

True for an installed model, otherwise False

Return type:

bool

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()
Returns:

True for a formally valid configuration, otherwise False

Return type:

bool

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:

True on success, otherwise False

Return type:

bool

Sets the configuration’s base folder.

New in version 3.0.

set_file(file)
Parameters:

file (Gio.File) – the new file

Sets a new file, invalidating all fields and reevaluating status.

New in version 3.0.

set_name(name)
Parameters:

name (str) – the new name

Returns:

True on success, otherwise False

Return type:

bool

Sets the human-visible name of a configuration. It doesn’t have to be unique. This saves the new name immediately to the configuration file.

New in version 3.0.

Property Details

Parlatype.Config.props.file
Name:

file

Type:

Gio.File

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

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
Name:

is-installed

Type:

bool

Default Value:

False

Flags:

READABLE

Indicates whether the language model is installed.

Parlatype.Config.props.is_valid
Name:

is-valid

Type:

bool

Default Value:

False

Flags:

READABLE

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.

Parlatype.Config.props.name
Name:

name

Type:

str

Default Value:

None

Flags:

READABLE

The display name for the model.