Search code examples
pythonpocketsphinxpython-gstreamer

How to set configuration options in pocketsphinx using gstreamer


Probably a very silly question, but I cannot find a solution anywhere. When I run 'gst-inspect-1.0 pocketsphinx' I get something like:

Current configuration:
[NAME]          [DEFLT]     [VALUE]
-agc            none        none
-agcthresh      2.0     2.000000e+00
-allphone               
...

Element Properties:
  name                : The name of the object
                        flags: readable, writable
                        String. Default: "pocketsphinx0"
...

I know how to set values for the 'element properties', but how do I set values for the other configuration options? e.g. I'd like to set a value for 'keyphrase' but doing something like

asr.set_property("keyphrase", "test")

or

asr.set_property("-keyphrase", "test")

returns

TypeError: object of type `GstPocketSphinx' does not have property `keyphrase'

Solution

  • You need to modify plugin sources to introduce new properties:

    g_object_class_install_property
        (gobject_class, PROP_KEYPHRASE,
         g_param_spec_string("keyphrase", "Keyspotting phrase",
                             "Keyspotting phrase",
                             NULL,
                             G_PARAM_READWRITE));
    
     ....
    
    
    case PROP_KEYPHRASE:
        gst_pocketsphinx_set_string(ps, "-keyphrase", value);