Top |
PtConfig * | pt_config_new () |
gboolean | pt_config_is_valid () |
gboolean | pt_config_is_installed () |
gboolean | pt_config_apply () |
GFile * | pt_config_get_file () |
void | pt_config_set_file () |
gchar * | pt_config_get_name () |
gboolean | pt_config_set_name () |
gchar * | pt_config_get_base_folder () |
gboolean | pt_config_set_base_folder () |
gchar * | pt_config_get_plugin () |
gchar * | pt_config_get_lang_code () |
gchar * | pt_config_get_lang_name () |
gchar * | pt_config_get_key () |
A PtConfig represents a configuration for a GStreamer ASR plugin. Configuration files are written in .ini-like style. Each file holds one configuration that is used to instantiate a PtConfig.
Its main use is to be applied to a GStreamer plugin.
PtConfig is used for reading configurations in, not for writing them.
To add your own configuration, edit it yourself. Learn more about the file
format in the description of GKeyFile in general and in
pt_config_is_valid()
in particular.
To delete a configuration, get its “file” property, delete the file and unref the config object.
PtConfig *
pt_config_new (GFile *file
);
Returns a new configuration instance for the given file. The configuration
is immediately checked for formal validity. This can be queried with
pt_config_is_valid()
or the property “is-valid”. The property
doesn’t change anymore.
If the configuration is not valid, all methods are no-operations and return FALSE or NULL.
After use g_object_unref()
it.
Since: 3.0
gboolean
pt_config_is_valid (PtConfig *config
);
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.
Since: 3.0
gboolean
pt_config_is_installed (PtConfig *config
);
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.
Since: 3.0
gboolean pt_config_apply (PtConfig *config
,GObject *plugin
,GError **error
);
Applies a configuration to a GStreamer plugin.
config |
a configuration instance |
|
plugin |
the GStreamer ASR plugin |
|
error |
return location for an error, or NULL. |
[nullable] |
Since: 3.0
GFile *
pt_config_get_file (PtConfig *config
);
The GFile that storing the configuration.
Since: 3.0
void pt_config_set_file (PtConfig *config
,GFile *file
);
Sets a new file, invalidating all fields and reevaluating status.
Since: 3.0
gchar *
pt_config_get_name (PtConfig *config
);
The human-visible name to identify a configuration.
Since: 3.0
gboolean pt_config_set_name (PtConfig *config
,gchar *name
);
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.
Since: 3.0
gchar *
pt_config_get_base_folder (PtConfig *config
);
Gets the configuration’s base folder. If the model is not installed, the base folder is not set and the return value is NULL. Another reason for returning NULL is an invalid configuration, check “is-valid” for that.
Since: 3.0
gboolean pt_config_set_base_folder (PtConfig *config
,gchar *name
);
Sets the configuration’s base folder.
Since: 3.0
gchar *
pt_config_get_plugin (PtConfig *config
);
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.
Since: 3.0
gchar *
pt_config_get_lang_code (PtConfig *config
);
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).
Since: 3.0
gchar *
pt_config_get_lang_name (PtConfig *config
);
Gets the localized name of the language the model was made for.
Since: 3.0
struct PtConfig;
PtConfig contains only private fields and should not be directly accessed.
“file”
property“file” GFile *
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.
Owner: PtConfig
Flags: Read / Write / Construct Only
“is-installed”
property“is-installed” gboolean
Indicates whether the language model is installed.
Owner: PtConfig
Flags: Read
Default value: FALSE
“is-valid”
property“is-valid” gboolean
Indicates whether the configuration is formally valid. See
pt_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.
Owner: PtConfig
Flags: Read
Default value: FALSE