Hi JM,<br><br>I ran your code on my Fedora 16 box and I ran into a segfault but after looking at the code and noticing a few things you did differently than me I narrowed down the issue to the asr_partial_result and asr_result functions. Specifically, the segfault was coming when trying to set the value for &quot;uttid&quot; with gststruct.set_value(&quot;uttid&quot;, uttid);. I changed the parameter type for uttid in the method definition to string instead of GLib.Value and bingo it worked. Then I added my language model and dictionary to the code in the init_gst method and PocketSphinx is now printing out my limited language definition when I speak it!  That was a huge help to me! Thanks a lot. Are you the original author of the tutorial? It would be great if we could add this Vala port to the article so that people can take advantage of it easily. Do you have the contacts to get that done or should I try? <br>
<br>I&#39;m attaching the code with my small changes, including 1)adding the language model and dictionary 2)changing the parameter types for uttid and 3) my revised pipeline definition which shows how I got gstreamer to recognize my usb microphone using the device keyword. If you have access to edit the article then I think it is worth mentioning the <a href="http://www.speech.cs.cmu.edu/tools/lmtool-new.html">lmtool </a> from CMU which makes it really easy to define a language model and dictionary and include them with your code. <br>
<br>Regards<br><br>Brian  <br><br><div class="gmail_quote">On Thu, Mar 22, 2012 at 6:39 PM, JM <span dir="ltr">&lt;<a href="mailto:interflug1@gmx.net">interflug1@gmx.net</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello Brian<br>
I tried porting that python example to vala (attached file) and it<br>
doesn&#39;t work here (Fails at runtime during asr.set_property(&quot;configured&quot;, true) ).<br>
Your version crashes at the same point here.<br>
<br>
I&#39;m on ubuntu 11.10<br>
<br>
I tested the pipeline with<br>
gst-launch fakesrc ! audioconvert ! audioresample ! vader name=vad<br>
<div class="im">auto-threshold=true ! pocketsphinx name=asr ! fakesink<br>
</div>and it fails with &#39;SIGSEGV accessing address 0x2c&#39; as soon as it is<br>
(automatically)set to PAUSED.<br>
Funny thing is that the python example seems to work. Just had a look at<br>
the console. I didn&#39;t do further tests because my computer lacks a<br>
microphone.<br>
Your code looks fine, so far. On my machine I just don&#39;t get to the point where you have the issues.<br>
Regards<br>
<br>
<br>
Am Mittwoch, den 21.03.2012, 22:01 -0400 schrieb Brian Duffy:<br>
<div><div class="h5">&gt; Just speaking the words that are defined in my language model and<br>
&gt; dictionary. I think my problem is more severe than the words I am choosing<br>
&gt; to speak. Besides, if PocketSphinx segfaults just because you say hmmm then<br>
&gt; I am wasting my time.<br>
&gt;<br>
&gt; On Wed, Mar 21, 2012 at 6:40 PM, JM &lt;<a href="mailto:interflug1@gmx.net">interflug1@gmx.net</a>&gt; wrote:<br>
&gt;<br>
&gt; &gt; What exactly are you speaking into the microphone?<br>
&gt; &gt; Saying &quot;null&quot; or &quot;hmm&quot; may lead to segfauls ;)<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; Am Mittwoch, den 21.03.2012, 14:38 -0400 schrieb Brian Duffy:<br>
&gt; &gt; &gt; Sorry, forgot to mention that the segfault happens when I speak into the<br>
&gt; &gt; &gt; microphone; so my pipeline and asr are working well enough to pick up<br>
&gt; &gt; &gt; utterances from my microphone.<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; ---------- Forwarded message ----------<br>
&gt; &gt; &gt; From: Brian Duffy &lt;<a href="mailto:brduffy@gmail.com">brduffy@gmail.com</a>&gt;<br>
&gt; &gt; &gt; Date: Wed, Mar 21, 2012 at 2:30 PM<br>
&gt; &gt; &gt; Subject: Porting &quot;Using PocketSphinx with GStreamer and python&quot; to Vala<br>
&gt; &gt; &gt; To: vala-list &lt;<a href="mailto:vala-list@gnome.org">vala-list@gnome.org</a>&gt;,<br>
&gt; &gt; &gt; <a href="mailto:clutter-app-devel-list@clutter-project.org">clutter-app-devel-list@clutter-project.org</a><br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Hello all, I am trying to port<br>
&gt; &gt; &gt; &lt;<a href="http://goog_1501870203" target="_blank">http://goog_1501870203</a>&gt;this&lt;<br>
&gt; &gt; <a href="http://cmusphinx.sourceforge.net/wiki/gstreamer" target="_blank">http://cmusphinx.sourceforge.net/wiki/gstreamer</a>&gt;example<br>
&gt; &gt; &gt; &quot;Using PocketSphinx with GStreamer and Python&quot; to Vala. I have an<br>
&gt; &gt; &gt; example compiling but I am getting some warnings that I don&#39;t understand<br>
&gt; &gt; &gt; and a segmentation fault when running. Also, I am not sure what data<br>
&gt; &gt; types<br>
&gt; &gt; &gt; I should be using for the &quot;text&quot; and &quot;uttid&quot; params in the asrResult ,<br>
&gt; &gt; &gt; asrPartialResult, partialResult and finalResult methods. My environment<br>
&gt; &gt; is<br>
&gt; &gt; &gt; Fedora 16. PocketSphinx .7, latest gstreamer that comes with Fedora 16. I<br>
&gt; &gt; &gt; am using Clutter (1.8) for the main loop because my application UI will<br>
&gt; &gt; &gt; ultimately be written in Clutter. Any help would be greatly appreciated.<br>
</div></div>&gt; &gt; &gt; Here are my compile warnings and code .... thanks. [brian@duffybr2foodie]$<br>
<div class="HOEnZb"><div class="h5">&gt; &gt; &gt; valac -X -O2 -g --pkg clutter-1.0 --pkg gstreamer-0.10 --pkg<br>
&gt; &gt; &gt; gstreamer-interfaces-0.10 --pkg clutter-gst-1.0 cmu.vala<br>
&gt; &gt; &gt; cmu.vala:25.24-25.48: warning: unhandled error `GLib.Error&#39; pipeline =<br>
&gt; &gt; &gt; (Pipeline)Gst.parse_launch(pipeDef); ^^^^^^^^^^^^^^^^^^^^^^^^^<br>
&gt; &gt; &gt; cmu.vala:11.2-11.26: warning: field `Sphinx.vader&#39; never used private<br>
&gt; &gt; &gt; Gst.Element vader; ^^^^^^^^^^^^^^^^^^^^^^^^^ cmu.vala:112.6-112.26:<br>
&gt; &gt; &gt; warning: local variable `sphinx&#39; declared but never used var sphinx = new<br>
&gt; &gt; &gt; Sphinx(); ^^^^^^^^^^^^^^^^^^^^^<br>
&gt; &gt; /home/brian/BitBucketRepos/foodie/cmu.vala:<br>
&gt; &gt; &gt; In function ‘sphinx_asrPartialResult’:<br>
&gt; &gt; &gt; /home/brian/BitBucketRepos/foodie/cmu.vala:51:2: warning: passing<br>
&gt; &gt; argument<br>
&gt; &gt; &gt; 1 of ‘gst_structure_set_value’ discards ‘const’ qualifier from pointer<br>
&gt; &gt; &gt; target type [enabled by default]<br>
&gt; &gt; &gt; /usr/include/gstreamer-0.10/gst/gststructure.h:117:25: note: expected<br>
&gt; &gt; &gt; ‘struct GstStructure *’ but argument is of type ‘const struct<br>
&gt; &gt; GstStructure<br>
&gt; &gt; &gt; *’ /home/brian/BitBucketRepos/foodie/cmu.vala:52:2: warning: passing<br>
&gt; &gt; &gt; argument 1 of ‘gst_structure_set_value’ discards ‘const’ qualifier from<br>
&gt; &gt; &gt; pointer target type [enabled by default]<br>
&gt; &gt; &gt; /usr/include/gstreamer-0.10/gst/gststructure.h:117:25: note: expected<br>
&gt; &gt; &gt; ‘struct GstStructure *’ but argument is of type ‘const struct<br>
&gt; &gt; GstStructure<br>
&gt; &gt; &gt; *’ /home/brian/BitBucketRepos/foodie/cmu.vala:54:2: warning: passing<br>
&gt; &gt; &gt; argument 1 of ‘_gst_structure_copy0’ discards ‘const’ qualifier from<br>
&gt; &gt; &gt; pointer target type [enabled by default] cmu.vala.c:287:17: note:<br>
&gt; &gt; expected<br>
&gt; &gt; &gt; ‘gpointer’ but argument is of type ‘const struct GstStructure *’<br>
&gt; &gt; &gt; /home/brian/BitBucketRepos/foodie/cmu.vala: In function<br>
&gt; &gt; ‘sphinx_asrResult’:<br>
&gt; &gt; &gt; /home/brian/BitBucketRepos/foodie/cmu.vala:65:2: warning: passing<br>
&gt; &gt; argument<br>
&gt; &gt; &gt; 1 of ‘gst_structure_set_value’ discards ‘const’ qualifier from pointer<br>
&gt; &gt; &gt; target type [enabled by default]<br>
&gt; &gt; &gt; /usr/include/gstreamer-0.10/gst/gststructure.h:117:25: note: expected<br>
&gt; &gt; &gt; ‘struct GstStructure *’ but argument is of type ‘const struct<br>
&gt; &gt; GstStructure<br>
&gt; &gt; &gt; *’ /home/brian/BitBucketRepos/foodie/cmu.vala:66:2: warning: passing<br>
&gt; &gt; &gt; argument 1 of ‘gst_structure_set_value’ discards ‘const’ qualifier from<br>
&gt; &gt; &gt; pointer target type [enabled by default]<br>
&gt; &gt; &gt; /usr/include/gstreamer-0.10/gst/gststructure.h:117:25: note: expected<br>
&gt; &gt; &gt; ‘struct GstStructure *’ but argument is of type ‘const struct<br>
&gt; &gt; GstStructure<br>
&gt; &gt; &gt; *’ /home/brian/BitBucketRepos/foodie/cmu.vala:68:2: warning: passing<br>
&gt; &gt; &gt; argument 1 of ‘_gst_structure_copy0’ discards ‘const’ qualifier from<br>
&gt; &gt; &gt; pointer target type [enabled by default] cmu.vala.c:287:17: note:<br>
&gt; &gt; expected<br>
&gt; &gt; &gt; ‘gpointer’ but argument is of type ‘const struct GstStructure *’<br>
&gt; &gt; &gt; /home/brian/BitBucketRepos/foodie/cmu.vala: In function<br>
&gt; &gt; &gt; ‘sphinx_app_message’: /home/brian/BitBucketRepos/foodie/cmu.vala:77:2:<br>
&gt; &gt; &gt; warning: passing argument 1 of ‘_gst_structure_copy0’ discards ‘const’<br>
&gt; &gt; &gt; qualifier from pointer target type [enabled by default]<br>
&gt; &gt; cmu.vala.c:287:17:<br>
&gt; &gt; &gt; note: expected ‘gpointer’ but argument is of type ‘const struct<br>
&gt; &gt; &gt; GstStructure *’ cmu.vala.c: In function ‘_vala_main’:<br>
&gt; &gt; &gt; /home/brian/BitBucketRepos/foodie/cmu.vala:107:15: warning: ignoring<br>
&gt; &gt; return<br>
&gt; &gt; &gt; value of ‘clutter_init’, declared with attribute warn_unused_result<br>
&gt; &gt; &gt; [-Wunused-result] Compilation succeeded - 3 warning(s)<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; [code]<br>
&gt; &gt; &gt; using Clutter;<br>
&gt; &gt; &gt; using ClutterGst;<br>
&gt; &gt; &gt; using Gst;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; class Sphinx : GLib.Object {<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; // experimenting with gstreamer pocketsphinx<br>
&gt; &gt; &gt; private Gst.Pipeline pipeline;<br>
&gt; &gt; &gt;  private Gst.Element vader;<br>
&gt; &gt; &gt; dynamic Gst.Element asr;<br>
&gt; &gt; &gt; private Gst.Bus bus;<br>
&gt; &gt; &gt;  private Gst.Structure msg;<br>
&gt; &gt; &gt; private Gst.Structure my_struct;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;  public Sphinx() {<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; string a = &quot;&quot;&quot;pulsesrc<br>
&gt; &gt; &gt; device=&quot;alsa_input.usb-AKM_AK5370-00-AK5370.analog-mono&quot; ! audioconvert<br>
&gt; &gt; &gt; !&quot;&quot;&quot;;<br>
&gt; &gt; &gt;  string b = &quot;&quot;&quot; audioresample ! vader name=vad auto-threshold=true !<br>
&gt; &gt; &gt; pocketsphinx name=asr ! fakesink&quot;&quot;&quot;;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; string pipeDef = a + b;<br>
&gt; &gt; &gt; pipeline = (Pipeline)Gst.parse_launch(pipeDef);<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; asr = pipeline.get_by_name(&quot;asr&quot;);<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; asr.set_property(&quot;lm&quot;, &quot;4038.lm&quot;);<br>
&gt; &gt; &gt;         asr.set_property(&quot;dict&quot;, &quot;4038.dic&quot;);<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; asr.partial_result.connect(asrPartialResult);<br>
&gt; &gt; &gt; asr.result.connect(asrResult);<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; asr.set_property(&quot;configured&quot;, true);<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; bus = pipeline.get_bus();<br>
&gt; &gt; &gt;         bus.add_signal_watch();<br>
&gt; &gt; &gt; bus.message.connect(app_message);<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; pipeline.set_state(Gst.State.PLAYING);<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; }<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; private void asrPartialResult(Gst.Element asr, GLib.Value text,<br>
&gt; &gt; GLib.Value<br>
&gt; &gt; &gt; uttid) {<br>
&gt; &gt; &gt;          my_struct = new Gst.Structure.empty(&quot;partial_result&quot;);<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;         my_struct.set_value(&quot;hyp&quot;, text);<br>
&gt; &gt; &gt;         my_struct.set_value(&quot;uttid&quot;, uttid);<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;         asr.post_message(new Gst.Message.application(asr, my_struct));<br>
&gt; &gt; &gt;  }<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; private void asrResult(Gst.Element asr, GLib.Value text, GLib.Value<br>
&gt; &gt; uttid) {<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; stdout.printf(&quot;%s&quot;, &quot;inside asrResult&quot;);<br>
&gt; &gt; &gt;          my_struct = new Gst.Structure.empty(&quot;result&quot;);<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;         my_struct.set_value(&quot;hyp&quot;, text);<br>
&gt; &gt; &gt;         my_struct.set_value(&quot;uttid&quot;, uttid);<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;         asr.post_message(new Gst.Message.application(asr, my_struct));<br>
&gt; &gt; &gt;  }<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; private void app_message(Gst.Bus bus, Gst.Message p_msg) {<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;  //stdout.printf(&quot;%s&quot;, &quot;inside app_message&quot;);<br>
&gt; &gt; &gt; msg = p_msg.get_structure();<br>
&gt; &gt; &gt;  string msgType = msg.get_name();<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; if (msgType == &quot;partial_result&quot;) {<br>
&gt; &gt; &gt;  partialResult(msg[&quot;hyp&quot;], msg[&quot;uttid&quot;]);<br>
&gt; &gt; &gt; }else if (msgType == &quot;result&quot;) {<br>
&gt; &gt; &gt;  finalResult(msg[&quot;hyp&quot;], msg[&quot;uttid&quot;]);<br>
&gt; &gt; &gt; pipeline.set_state(Gst.State.PAUSED);<br>
&gt; &gt; &gt;  }<br>
&gt; &gt; &gt;   }<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; private void partialResult(GLib.Value hyp, GLib.Value uttid) {<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; stdout.printf(&quot;%s&quot;, (string)hyp);<br>
&gt; &gt; &gt; }<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;  private void finalResult(GLib.Value hyp, GLib.Value uttid) {<br>
&gt; &gt; &gt; stdout.printf(&quot;%s&quot;, (string)hyp);<br>
&gt; &gt; &gt;  }<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; }<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; int main (string[] args) {<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Clutter.init(ref args);<br>
&gt; &gt; &gt;  Gst.init(ref args);<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; //ClutterGst.init(ref args);<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;  var sphinx = new Sphinx();<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Clutter.main();<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; return 0;<br>
&gt; &gt; &gt; }<br>
&gt; &gt; &gt; [/code]<br>
&gt; &gt; &gt; --<br>
&gt; &gt; &gt; Duff<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; _______________________________________________<br>
&gt; &gt; &gt; vala-list mailing list<br>
&gt; &gt; &gt; <a href="mailto:vala-list@gnome.org">vala-list@gnome.org</a><br>
&gt; &gt; &gt; <a href="http://mail.gnome.org/mailman/listinfo/vala-list" target="_blank">http://mail.gnome.org/mailman/listinfo/vala-list</a><br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; _______________________________________________<br>
&gt; &gt; vala-list mailing list<br>
&gt; &gt; <a href="mailto:vala-list@gnome.org">vala-list@gnome.org</a><br>
&gt; &gt; <a href="http://mail.gnome.org/mailman/listinfo/vala-list" target="_blank">http://mail.gnome.org/mailman/listinfo/vala-list</a><br>
&gt; &gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
<br>
<br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Duff<br>