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 "uttid" with gststruct.set_value("uttid", 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'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"><<a href="mailto:interflug1@gmx.net">interflug1@gmx.net</a>></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't work here (Fails at runtime during asr.set_property("configured", true) ).<br>
Your version crashes at the same point here.<br>
<br>
I'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 'SIGSEGV accessing address 0x2c' 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't do further tests because my computer lacks a<br>
microphone.<br>
Your code looks fine, so far. On my machine I just don'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">> Just speaking the words that are defined in my language model and<br>
> dictionary. I think my problem is more severe than the words I am choosing<br>
> to speak. Besides, if PocketSphinx segfaults just because you say hmmm then<br>
> I am wasting my time.<br>
><br>
> On Wed, Mar 21, 2012 at 6:40 PM, JM <<a href="mailto:interflug1@gmx.net">interflug1@gmx.net</a>> wrote:<br>
><br>
> > What exactly are you speaking into the microphone?<br>
> > Saying "null" or "hmm" may lead to segfauls ;)<br>
> ><br>
> ><br>
> > Am Mittwoch, den 21.03.2012, 14:38 -0400 schrieb Brian Duffy:<br>
> > > Sorry, forgot to mention that the segfault happens when I speak into the<br>
> > > microphone; so my pipeline and asr are working well enough to pick up<br>
> > > utterances from my microphone.<br>
> > ><br>
> > ><br>
> > ><br>
> > > ---------- Forwarded message ----------<br>
> > > From: Brian Duffy <<a href="mailto:brduffy@gmail.com">brduffy@gmail.com</a>><br>
> > > Date: Wed, Mar 21, 2012 at 2:30 PM<br>
> > > Subject: Porting "Using PocketSphinx with GStreamer and python" to Vala<br>
> > > To: vala-list <<a href="mailto:vala-list@gnome.org">vala-list@gnome.org</a>>,<br>
> > > <a href="mailto:clutter-app-devel-list@clutter-project.org">clutter-app-devel-list@clutter-project.org</a><br>
> > ><br>
> > ><br>
> > > Hello all, I am trying to port<br>
> > > <<a href="http://goog_1501870203" target="_blank">http://goog_1501870203</a>>this<<br>
> > <a href="http://cmusphinx.sourceforge.net/wiki/gstreamer" target="_blank">http://cmusphinx.sourceforge.net/wiki/gstreamer</a>>example<br>
> > > "Using PocketSphinx with GStreamer and Python" to Vala. I have an<br>
> > > example compiling but I am getting some warnings that I don't understand<br>
> > > and a segmentation fault when running. Also, I am not sure what data<br>
> > types<br>
> > > I should be using for the "text" and "uttid" params in the asrResult ,<br>
> > > asrPartialResult, partialResult and finalResult methods. My environment<br>
> > is<br>
> > > Fedora 16. PocketSphinx .7, latest gstreamer that comes with Fedora 16. I<br>
> > > am using Clutter (1.8) for the main loop because my application UI will<br>
> > > ultimately be written in Clutter. Any help would be greatly appreciated.<br>
</div></div>> > > Here are my compile warnings and code .... thanks. [brian@duffybr2foodie]$<br>
<div class="HOEnZb"><div class="h5">> > > valac -X -O2 -g --pkg clutter-1.0 --pkg gstreamer-0.10 --pkg<br>
> > > gstreamer-interfaces-0.10 --pkg clutter-gst-1.0 cmu.vala<br>
> > > cmu.vala:25.24-25.48: warning: unhandled error `GLib.Error' pipeline =<br>
> > > (Pipeline)Gst.parse_launch(pipeDef); ^^^^^^^^^^^^^^^^^^^^^^^^^<br>
> > > cmu.vala:11.2-11.26: warning: field `Sphinx.vader' never used private<br>
> > > Gst.Element vader; ^^^^^^^^^^^^^^^^^^^^^^^^^ cmu.vala:112.6-112.26:<br>
> > > warning: local variable `sphinx' declared but never used var sphinx = new<br>
> > > Sphinx(); ^^^^^^^^^^^^^^^^^^^^^<br>
> > /home/brian/BitBucketRepos/foodie/cmu.vala:<br>
> > > In function ‘sphinx_asrPartialResult’:<br>
> > > /home/brian/BitBucketRepos/foodie/cmu.vala:51:2: warning: passing<br>
> > argument<br>
> > > 1 of ‘gst_structure_set_value’ discards ‘const’ qualifier from pointer<br>
> > > target type [enabled by default]<br>
> > > /usr/include/gstreamer-0.10/gst/gststructure.h:117:25: note: expected<br>
> > > ‘struct GstStructure *’ but argument is of type ‘const struct<br>
> > GstStructure<br>
> > > *’ /home/brian/BitBucketRepos/foodie/cmu.vala:52:2: warning: passing<br>
> > > argument 1 of ‘gst_structure_set_value’ discards ‘const’ qualifier from<br>
> > > pointer target type [enabled by default]<br>
> > > /usr/include/gstreamer-0.10/gst/gststructure.h:117:25: note: expected<br>
> > > ‘struct GstStructure *’ but argument is of type ‘const struct<br>
> > GstStructure<br>
> > > *’ /home/brian/BitBucketRepos/foodie/cmu.vala:54:2: warning: passing<br>
> > > argument 1 of ‘_gst_structure_copy0’ discards ‘const’ qualifier from<br>
> > > pointer target type [enabled by default] cmu.vala.c:287:17: note:<br>
> > expected<br>
> > > ‘gpointer’ but argument is of type ‘const struct GstStructure *’<br>
> > > /home/brian/BitBucketRepos/foodie/cmu.vala: In function<br>
> > ‘sphinx_asrResult’:<br>
> > > /home/brian/BitBucketRepos/foodie/cmu.vala:65:2: warning: passing<br>
> > argument<br>
> > > 1 of ‘gst_structure_set_value’ discards ‘const’ qualifier from pointer<br>
> > > target type [enabled by default]<br>
> > > /usr/include/gstreamer-0.10/gst/gststructure.h:117:25: note: expected<br>
> > > ‘struct GstStructure *’ but argument is of type ‘const struct<br>
> > GstStructure<br>
> > > *’ /home/brian/BitBucketRepos/foodie/cmu.vala:66:2: warning: passing<br>
> > > argument 1 of ‘gst_structure_set_value’ discards ‘const’ qualifier from<br>
> > > pointer target type [enabled by default]<br>
> > > /usr/include/gstreamer-0.10/gst/gststructure.h:117:25: note: expected<br>
> > > ‘struct GstStructure *’ but argument is of type ‘const struct<br>
> > GstStructure<br>
> > > *’ /home/brian/BitBucketRepos/foodie/cmu.vala:68:2: warning: passing<br>
> > > argument 1 of ‘_gst_structure_copy0’ discards ‘const’ qualifier from<br>
> > > pointer target type [enabled by default] cmu.vala.c:287:17: note:<br>
> > expected<br>
> > > ‘gpointer’ but argument is of type ‘const struct GstStructure *’<br>
> > > /home/brian/BitBucketRepos/foodie/cmu.vala: In function<br>
> > > ‘sphinx_app_message’: /home/brian/BitBucketRepos/foodie/cmu.vala:77:2:<br>
> > > warning: passing argument 1 of ‘_gst_structure_copy0’ discards ‘const’<br>
> > > qualifier from pointer target type [enabled by default]<br>
> > cmu.vala.c:287:17:<br>
> > > note: expected ‘gpointer’ but argument is of type ‘const struct<br>
> > > GstStructure *’ cmu.vala.c: In function ‘_vala_main’:<br>
> > > /home/brian/BitBucketRepos/foodie/cmu.vala:107:15: warning: ignoring<br>
> > return<br>
> > > value of ‘clutter_init’, declared with attribute warn_unused_result<br>
> > > [-Wunused-result] Compilation succeeded - 3 warning(s)<br>
> > ><br>
> > ><br>
> > ><br>
> > ><br>
> > > [code]<br>
> > > using Clutter;<br>
> > > using ClutterGst;<br>
> > > using Gst;<br>
> > ><br>
> > ><br>
> > > class Sphinx : GLib.Object {<br>
> > ><br>
> > ><br>
> > > // experimenting with gstreamer pocketsphinx<br>
> > > private Gst.Pipeline pipeline;<br>
> > > private Gst.Element vader;<br>
> > > dynamic Gst.Element asr;<br>
> > > private Gst.Bus bus;<br>
> > > private Gst.Structure msg;<br>
> > > private Gst.Structure my_struct;<br>
> > ><br>
> > > public Sphinx() {<br>
> > ><br>
> > ><br>
> > > string a = """pulsesrc<br>
> > > device="alsa_input.usb-AKM_AK5370-00-AK5370.analog-mono" ! audioconvert<br>
> > > !""";<br>
> > > string b = """ audioresample ! vader name=vad auto-threshold=true !<br>
> > > pocketsphinx name=asr ! fakesink""";<br>
> > ><br>
> > ><br>
> > > string pipeDef = a + b;<br>
> > > pipeline = (Pipeline)Gst.parse_launch(pipeDef);<br>
> > ><br>
> > > asr = pipeline.get_by_name("asr");<br>
> > ><br>
> > > asr.set_property("lm", "4038.lm");<br>
> > > asr.set_property("dict", "4038.dic");<br>
> > ><br>
> > > asr.partial_result.connect(asrPartialResult);<br>
> > > asr.result.connect(asrResult);<br>
> > ><br>
> > > asr.set_property("configured", true);<br>
> > ><br>
> > > bus = pipeline.get_bus();<br>
> > > bus.add_signal_watch();<br>
> > > bus.message.connect(app_message);<br>
> > ><br>
> > > pipeline.set_state(Gst.State.PLAYING);<br>
> > ><br>
> > > }<br>
> > ><br>
> > ><br>
> > > private void asrPartialResult(Gst.Element asr, GLib.Value text,<br>
> > GLib.Value<br>
> > > uttid) {<br>
> > > my_struct = new Gst.Structure.empty("partial_result");<br>
> > ><br>
> > > my_struct.set_value("hyp", text);<br>
> > > my_struct.set_value("uttid", uttid);<br>
> > ><br>
> > > asr.post_message(new Gst.Message.application(asr, my_struct));<br>
> > > }<br>
> > ><br>
> > ><br>
> > > private void asrResult(Gst.Element asr, GLib.Value text, GLib.Value<br>
> > uttid) {<br>
> > ><br>
> > > stdout.printf("%s", "inside asrResult");<br>
> > > my_struct = new Gst.Structure.empty("result");<br>
> > ><br>
> > > my_struct.set_value("hyp", text);<br>
> > > my_struct.set_value("uttid", uttid);<br>
> > ><br>
> > > asr.post_message(new Gst.Message.application(asr, my_struct));<br>
> > > }<br>
> > ><br>
> > ><br>
> > > private void app_message(Gst.Bus bus, Gst.Message p_msg) {<br>
> > ><br>
> > > //stdout.printf("%s", "inside app_message");<br>
> > > msg = p_msg.get_structure();<br>
> > > string msgType = msg.get_name();<br>
> > ><br>
> > > if (msgType == "partial_result") {<br>
> > > partialResult(msg["hyp"], msg["uttid"]);<br>
> > > }else if (msgType == "result") {<br>
> > > finalResult(msg["hyp"], msg["uttid"]);<br>
> > > pipeline.set_state(Gst.State.PAUSED);<br>
> > > }<br>
> > > }<br>
> > ><br>
> > > private void partialResult(GLib.Value hyp, GLib.Value uttid) {<br>
> > ><br>
> > > stdout.printf("%s", (string)hyp);<br>
> > > }<br>
> > ><br>
> > > private void finalResult(GLib.Value hyp, GLib.Value uttid) {<br>
> > > stdout.printf("%s", (string)hyp);<br>
> > > }<br>
> > ><br>
> > ><br>
> > > }<br>
> > ><br>
> > ><br>
> > > int main (string[] args) {<br>
> > ><br>
> > > Clutter.init(ref args);<br>
> > > Gst.init(ref args);<br>
> > ><br>
> > > //ClutterGst.init(ref args);<br>
> > ><br>
> > > var sphinx = new Sphinx();<br>
> > ><br>
> > > Clutter.main();<br>
> > ><br>
> > > return 0;<br>
> > > }<br>
> > > [/code]<br>
> > > --<br>
> > > Duff<br>
> > ><br>
> > ><br>
> > ><br>
> > > _______________________________________________<br>
> > > vala-list mailing list<br>
> > > <a href="mailto:vala-list@gnome.org">vala-list@gnome.org</a><br>
> > > <a href="http://mail.gnome.org/mailman/listinfo/vala-list" target="_blank">http://mail.gnome.org/mailman/listinfo/vala-list</a><br>
> ><br>
> ><br>
> > _______________________________________________<br>
> > vala-list mailing list<br>
> > <a href="mailto:vala-list@gnome.org">vala-list@gnome.org</a><br>
> > <a href="http://mail.gnome.org/mailman/listinfo/vala-list" target="_blank">http://mail.gnome.org/mailman/listinfo/vala-list</a><br>
> ><br>
><br>
><br>
><br>
<br>
<br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Duff<br>