Menu

Gstreamer tutorial: setting language model

Help
Name
2016-05-10
2019-02-02
  • Name

    Name - 2016-05-10

    Hi,

    I am trying to adapt gstreamer tutorial http://cmusphinx.sourceforge.net/wiki/gstreamer (the link to final code is broken, which is ok because there is full listing after the article)

    The recognition works, however I need to change language model.

    To use your improved language model with GStreamer, you just have to set the lm and dict properties on the pocketsphinx element. So, if your language model is in /home/user/mylanguagemodel.lm and the associated dictionary is /home/user/mylanguagemodel.dic, you would add these lines to the init_gst method.

        asr.set_property('lm', '/home/user/mylanguagemodel.lm')
        asr.set_property('dict', '/home/user/mylanguagemodel.dic')
    

    There is no mention of asr in code, but I've googled old version of this script that does

            self.pipeline = gst.parse_launch('autoaudiosrc ! audioconvert ! audioresample '
                                             + '! pocketsphinx name=asr ! fakesink')
            asr = self.pipeline.get_by_name('asr')
    

    However when I add lines

            asr.set_property('hmm', '/home/user/mylanguagemodel.hmm')
            asr.set_property('lm', '/home/user/mylanguagemodel.lm')
            asr.set_property('dict', '/home/user/mylanguagemodel.dic')
    

    Nothing happens -- I would expect my pocketsphinx to fall, however when it prints "current configuration" in stderr it's still the same one and the recognition works about the same.

    Here is the output of gst-detect-1.0 pocketsphinx: http://pastebin.com/Y9P1fdGy.

    Thanks!

     
    • Nickolay V. Shmyrev

      Hello

      Thank you for your notes, I have updated the manual

      There is no mention of asr in code, but I've googled old version of this script that does

      I have updated that part too, now it properly refers on how to set properties, please consider:

      http://cmusphinx.sourceforge.net/wiki/gstreamer?&#configuring_the_decoder_and_improving_accuracy

      Please note that properties are not applied until pipeline is started, you need to start the pipeline in order to see the effect of configuration.

      Please also make sure you are using latest pocketsphinx.

       
  • Name

    Name - 2016-05-15

    Thanks for response!

    Sorry, it still doens't seem to be working for me. I've installed and re-installed everything from recursive github clone of pocketsphinx-python, but it ignores my changes

    http://pastebin.com/UDPYwcNc I tried to run in on https://sourceforge.net/projects/cmusphinx/files/Acoustic%20and%20Language%20Models/Russian/ but it still produces english output.
    Could you please try it and say if the issue with code or with my setup?

     

    Last edit: Name 2016-05-15
    • Nickolay V. Shmyrev

      You are using outdated pocketsphinx. You need to clone latest pocketsphinx from http://github.com/cmusphinx/pocketsphinx

       

      Last edit: Nickolay V. Shmyrev 2016-05-16
  • Name

    Name - 2016-05-16

    Thanks.

    Had to copy libgstpocketsphinx.so
    to /usr/lib/x86_64-linux-gnu/gstreamer-1.0/ manually. Not sure how it got there in a first place, perhaps from apt-get install of gstreamer

    Now it lags and does nothing, but at least it seem to respect my changes to config :)

     
    • Vadim R

      Vadim R - 2016-10-18

      Have you finally solved this issue? If yes, can I ask you to provide solution?
      Thanks!

       
      • Vadim R

        Vadim R - 2016-10-19

        I found the solution.
        Maybe it sounds obvious, but there is two problems.
        The main problem that old pocketsphinx does not support acoustic model changing.
        The second problem - new pocketsphinx works with GStreamer version 1.0
        Hence, we should obtain both new pocketsphinx and GStreamer and compile them according to tutorial (be especially careful with fullfilling requirements to this command: gst-inspect-1.0 pocketsphinx)

         

        Last edit: Vadim R 2016-10-19
  • Cindy Chang

    Cindy Chang - 2019-02-02

    I have everal questions to ask:
    Q1: Where should I put my chinese.lm file? The official website says every language has its own directory under  /speech_recognition/pocketsphin-data/, but I don’t have this directory; for example, for the default English, the lm.bin file is at pocketsphinx/model/en-us/en-us.lm.bin, where pocketsphin/ is where I ran the make install command.
    Should I mkdir /speech_recognition/pocketsphin-data/zh-cn?
    Q2: Is dictionary file necessary or I can just only use .lm file for the gstreamer to work?
    Q3: Which should I use, the .lm file or .lm.bin file in the gstreamer integration?
    Thank you!

     

    Last edit: Cindy Chang 2019-02-03

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.