Hello,
I am trying to use CMU's PocketSphinx plugin for Gstreamer from Vala and I am running into a problem getting access to the message structure in my bus callback function (app_message). For some reason when I use the get_structure method to return the structure of the message and then call a method on that structure such as get_name() or get_string(), I get a critical Gstreamer error :
(cmu:26958): GStreamer-CRITICAL **: gst_structure_get_string: assertion `structure != NULL' failed I just can't figure out why my message structure would be null. Any ideas? Here is my code ...
using Gst; class Sphinx : GLib.Object { // experimenting with gstreamer pocketsphinx
private Gst.Pipeline pipeline; private Gst.Element vader; dynamic Gst.Element asr;
private Gst.Bus bus; private Gst.Structure msg; private Gst.Structure my_struct;
private Gst.Structure my_struct2; private Gst.Message message;
private MainLoop loop; public Sphinx() { string a = """pulsesrc device="alsa_input.usb-AKM_AK5370-00-AK5370.analog-mono" ! audioconvert !"""; string b = """ audioresample ! vader name=vad auto-threshold=true ! pocketsphinx name=asr ! fakesink""";
string pipeDef = a + b; try {
pipeline = (Pipeline)Gst.parse_launch(pipeDef); } catch (Error e) {
stdout.printf("Error: %s\n", e.message); } bus = pipeline.get_bus(); bus.add_signal_watch(); bus.message.connect(app_message);
asr = pipeline.get_by_name("asr"); asr.set_property("lm", "4038.lm"); asr.set_property("dict", "4038.dic");
asr.partial_result.connect(asrPartialResult); asr.result.connect(asrResult);
asr.set_property("configured", true); bus = pipeline.get_bus();
bus.add_signal_watch(); bus.message.connect(app_message); pipeline.set_state(Gst.State.PLAYING);
loop = new MainLoop (); loop.run(); }
private void asrPartialResult(Gst.Element asr, string text, string uttid) { my_struct = new Gst.Structure.empty("partial_result"); my_struct.set_value("hyp", text); my_struct.set_value("uttid", uttid);
asr.post_message(new Gst.Message.application(asr, my_struct)); }
private void asrResult(Gst.Element asr, string text, string uttid) { //stdout.printf("%s", "inside asrResult");
my_struct2 = new Gst.Structure.empty("result"); my_struct2.set_value("hyp", text);
my_struct2.set_value("uttid", uttid); asr.post_message(new Gst.Message.application(asr, my_struct2)); } private void app_message(Gst.Bus bus, Gst.Message p_msg) {
// trying to get the string that PocketSphinx converts my voice to here
// but I keep getting : GStreamer-CRITICAL **: gst_structure_get_string: assertion `structure != NULL' failed string msg_string = p_msg.get_structure().get_string("hyp");
/* // Not using any of this for now if (msgType == null) {
stdout.printf("%s", "null"); }else{
stdout.printf("%s", "not null"); }
*/ //stdout.printf("%s", msgType);
//if (p_msg.type == MessageType.APPLICATION) { // stdout.printf("%s", "booyah");
//} /* if (msg["hyp"]) {
stdout.printf("%s", "true"); }else{ stdout.printf("%s", "false");
} */ /*
if (msgType == "partial_result") { //partialResult(msg["hyp"], msg["uttid"]);
}else if (msgType == "result") { //finalResult(msg["hyp"], msg["uttid"]);
//pipeline.set_state(Gst.State.PAUSED); } */
//return true; } private void partialResult(GLib.Value hyp, GLib.Value uttid) { stdout.printf("%s", (string)hyp);
} private void finalResult(GLib.Value hyp, GLib.Value uttid) {
stdout.printf("%s", (string)hyp); } }
int main (string[] args) { Gst.init(ref args); var sphinx = new Sphinx();
return 0; } Duff _______________________________________________ gstreamer-devel mailing list [hidden email] http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Free forum by Nabble | Edit this page |