Exemple #1
0
 def _on_pocketsphinx_result(self, sphinx, text, uttid):
     """Send recognized text as a message on the bus."""
     import gst
     struct = gst.Structure("text")
     struct.set_value("text", text)
     struct.set_value("uttid", uttid)
     sphinx.post_message(gst.message_new_application(sphinx, struct))
Exemple #2
0
 def __run_cmd__(self, listener, text, uttid):
     """We're inside __run_cmd__"""
     scarlett.log.debug(Fore.YELLOW + "Inside __run_cmd__")
     struct = gst.Structure('result')
     struct.set_value('hyp', text)
     struct.set_value('uttid', uttid)
     listener.post_message(gst.message_new_application(listener, struct))
Exemple #3
0
 def asr_result(self, asr, text, uttid):
     print "asr result ----------------"
     struct = gst.Structure("result")
     struct.set_value("hyp", text)
     struct.set_value("uttid", uttid)
     self.debugMsg("asr result: " + text, 0)
     asr.post_message(gst.message_new_application(asr, struct))
Exemple #4
0
 def _on_vader_stop(self, vader, pos):
     """Send stop position as a message on the bus."""
     import gst
     struct = gst.Structure("stop")
     pos = pos / 1000000000 # ns to s
     struct.set_value("stop", pos)
     vader.post_message(gst.message_new_application(vader, struct))
Exemple #5
0
    def asr_result(self, asr, text, uttid):
        """Forward result signals on the bus to the main thread."""

        struct = gst.Structure('result')
        struct.set_value('hyp', text)
        struct.set_value('uttid', uttid)
        asr.post_message(gst.message_new_application(asr, struct))
Exemple #6
0
 def __run_cmd__(self, listener, text, uttid):
     scarlett.log.debug(Fore.YELLOW + "Inside __run_cmd__")
     """We're inside __run_cmd__"""
     struct = gst.Structure('result')
     struct.set_value('hyp', text)
     struct.set_value('uttid', uttid)
     listener.post_message(gst.message_new_application(listener, struct))
Exemple #7
0
 def vader_stop(self, vader, ts):
     """
     Forward VADER stop signals on the bus to the main thread.
     """
     struct = gst.Structure('vader_stop')
     # Ignore the timestamp for now because gst-python is buggy
     vader.post_message(gst.message_new_application(vader, struct))
Exemple #8
0
 def vader_stop(self, vader, ts):
     """
     Forward VADER stop signals on the bus to the main thread.
     """
     struct = gst.Structure('vader_stop')
     # Ignore the timestamp for now because gst-python is buggy
     vader.post_message(gst.message_new_application(vader, struct))
Exemple #9
0
    def volume_change_cb(self, element, gspec):
        message = None
        self.lock.acquire()        
        vol = self.volume.get_property("volume")
        print "self.state = ", self.state
        print "volume change callback: ", vol

        # 通过音量检测fading 是否已经完成,通知上层
        # post app messages on the bus when fades complete.
        if self.state == FADING_IN and vol >= self.fade_end - 0.05:
            self.fading = False 
            self.state = PLAYING
            self.update_state()
            message = "FADE IN DONE AND PLAY"
                
        elif self.state == FADING_OUT and vol <= self.fade_end + 0.05:
            self.fading = False
            self.state = FADING_OUT_PAUSED
            self.update_state()
            message = "FADE OUT DONE AND DIE"                

        self.volume.set_passthrough(False)
        self.lock.release()
        # force the volume element out of passthrought mode so it
        # continues to update the controller (otherwise, if the 
        # fade out starts at 1.0, it never gets anywhere)
        # self.volume.set_passthrough(False)
        
        # emit the message
        if message:
            st = gst.Structure(message)
            msg = gst.message_new_application(element, st)
            self.volume.post_message(msg)
Exemple #10
0
 def _on_vader_start(self, vader, pos):
     scarlett.log.debug(Fore.YELLOW + "Inside _on_vader_start")
     """Send start position as a message on the bus."""
     import gst
     struct = gst.Structure("start")
     pos = pos / 1000000000  # ns to s
     struct.set_value("start", pos)
     vader.post_message(gst.message_new_application(vader, struct))
Exemple #11
0
 def _on_vader_start(self, vader, pos):
     scarlett.log.debug(Fore.YELLOW + "Inside _on_vader_start")
     """Send start position as a message on the bus."""
     import gst
     struct = gst.Structure("start")
     pos = pos / 1000000000  # ns to s
     struct.set_value("start", pos)
     vader.post_message(gst.message_new_application(vader, struct))
Exemple #12
0
 def process_handoff(self, fakesink, buffer_, pad):
     # When this function is called the first buffer has reached the end of
     # the pipeline, and we can continue with the next track. Since we're
     # in another thread, we send a message back to the main thread using
     # the bus.
     structure = gst.Structure('handoff')
     message = gst.message_new_application(fakesink, structure)
     bus = self.pipe.get_bus()
     bus.post(message)
Exemple #13
0
 def process_handoff(self, fakesink, buffer_, pad):
     # When this function is called the first buffer has reached the end of
     # the pipeline, and we can continue with the next track. Since we're
     # in another thread, we send a message back to the main thread using
     # the bus.
     structure = gst.Structure('handoff')
     message = gst.message_new_application(fakesink, structure)
     bus = self.pipe.get_bus()
     bus.post(message)
Exemple #14
0
 def blocked(x, is_blocked):
     if not x in self.pads_awaiting_block:
         return
     self.pads_awaiting_block.remove(x)
     if not self.pads_awaiting_block:
         s = gst.Structure('pads-blocked')
         m = gst.message_new_application(pipeline, s)
         # marshal to the main thread
         pipeline.post_message(m)
Exemple #15
0
	def asr_partial_result(self, asr, text, uttid):
		"""Forward partial result signals on the bus to the main thread."""
		struct = gst.Structure('partial_result')
		struct.set_value('hyp', text)
		struct.set_value('uttid', uttid)
		if text.lower()=="open":
			asr.set_property('lm', 'model_open/6521.lm')
			asr.set_property('dict', 'model_open/6521.dic')
		asr.post_message(gst.message_new_application(asr, struct))
Exemple #16
0
 def _dec_counter(self):
     self._lock.acquire()
     self.counter -= 1
     counter = self.counter
     self._lock.release()
     if counter == 0:
         self.prerolled = True
         m = gst.message_new_application(self.pipe, gst.Structure("Prerolled"))
         self.pipe.post_message(m)
Exemple #17
0
 def blocked(x, is_blocked):
     if not x in self.pads_awaiting_block:
         return
     self.pads_awaiting_block.remove(x)
     if not self.pads_awaiting_block:
         s = gst.Structure('pads-blocked')
         m = gst.message_new_application(pipeline, s)
         # marshal to the main thread
         pipeline.post_message(m)
Exemple #18
0
	def asr_result(self, asr, text, uttid):
	    """Forward result signals on the bus to the main thread."""
	    struct = gst.Structure('result')
	    struct.set_value('hyp', text)
	    struct.set_value('uttid', uttid)
	    asr.post_message(gst.message_new_application(asr, struct))
	    # print text
	    self.result=text.lower()
	    # self.notify("Recognized:{0}".format(self.result))
	    pub.sendMessage("Recognized", arg1=self.result)
Exemple #19
0
def _pad_added(element, pad, pipeline):
    sink = gst.element_factory_make("fakesink")
    sink.set_property("sync", False)

    pipeline.add(sink)
    sink.sync_state_with_parent()
    pad.link(sink.get_pad("sink"))

    if pad.get_caps().is_subset(_RAW_AUDIO):
        struct = gst.Structure("have-audio")
        element.get_bus().post(gst.message_new_application(element, struct))
Exemple #20
0
 def asr_partial_result(self, asr, text, uttid):
     """
     Forward partial result signals on the bus to the main thread.
     """
     #print text
     #send the hypothesis on the socket connection
     #self.conn.send(text)
     struct = gst.Structure('partial_result')
     struct.set_value('hyp', text)
     struct.set_value('uttid', uttid)
     asr.post_message(gst.message_new_application(asr, struct))
Exemple #21
0
    def asr_partial_result(self, asr, text, uttid):
        """
        Forward partial result signals on the bus to the main thread.
        """
	#print text
	#send the hypothesis on the socket connection
	#self.conn.send(text)
        struct = gst.Structure('partial_result')
        struct.set_value('hyp', text)
        struct.set_value('uttid', uttid)
        asr.post_message(gst.message_new_application(asr, struct))
Exemple #22
0
def _pad_added(element, pad, pipeline):
    sink = gst.element_factory_make('fakesink')
    sink.set_property('sync', False)

    pipeline.add(sink)
    sink.sync_state_with_parent()
    pad.link(sink.get_pad('sink'))

    if pad.get_caps().is_subset(_RAW_AUDIO):
        struct = gst.Structure('have-audio')
        element.get_bus().post(gst.message_new_application(element, struct))
Exemple #23
0
 def asr_result(self, asr, text, uttid):
     """
     Forward result signals on the bus to the main thread.
     """
     print text
     #send the hypothesis on the socket connection
     self.conn.send(text)
     struct = gst.Structure('result')
     struct.set_value('hyp', text)
     struct.set_value('uttid', uttid)
     #self.dag = pocketsphinx.Lattice(boxed=asr.get_property('lattice'))
     asr.post_message(gst.message_new_application(asr, struct))
Exemple #24
0
    def asr_result(self, asr, text, uttid):
        """
        Forward result signals on the bus to the main thread.
        """
	print text
	#send the hypothesis on the socket connection
	self.conn.send(text)
        struct = gst.Structure('result')
        struct.set_value('hyp', text)
        struct.set_value('uttid', uttid)
        #self.dag = pocketsphinx.Lattice(boxed=asr.get_property('lattice'))
        asr.post_message(gst.message_new_application(asr, struct))
	def asr_result(self, asr, text, uttid):
		struct = gst.Structure("result");
		struct.set_value("hyp", text);
		struct.set_value("uttid", uttid);
		self.debugMsg("asr result: " + text, 0);
		asr.post_message(gst.message_new_application(asr, struct));
Exemple #26
0
	def on_sphinx_result(self, sphinx, text, uttid, score=None):
		msg = gst.Structure('sphinx_result')
		msg['text'] = text

		self.bus.post(gst.message_new_application(sphinx, msg))
 def asr_partial_result(self, asr, text, uttid):
     struct = gst.Structure("partial_result")
     struct.set_value("hyp", text)
     struct.set_value("uttid", uttid)
     self.debugMsg("asr partial: " + text, 0)
     asr.post_message(gst.message_new_application(asr, struct))
Exemple #28
0
def _have_type(element, probability, caps, decodebin):
    decodebin.set_property('sink-caps', caps)
    msg = gst.message_new_application(element, caps.get_structure(0))
    element.get_bus().post(msg)
 def asr_result(self, asr, text, uttid):
     """ Forward result signals on the bus to the main thread. """
     struct = gst.Structure('result')
     struct.set_value('hyp', text)
     struct.set_value('uttid', uttid)
     asr.post_message(gst.message_new_application(asr, struct))
Exemple #30
0
def _have_type(element, probability, caps, decodebin):
    decodebin.set_property("sink-caps", caps)
    struct = gst.Structure("have-type")
    struct["caps"] = caps.get_structure(0)
    element.get_bus().post(gst.message_new_application(element, struct))
Exemple #31
0
 def stop_pipeline(self):
     msg = gst.message_new_application(self.pipeline,
                                       gst.Structure('aborded_playback'))
     self.pipeline.get_bus().post(msg)
Exemple #32
0
 def __post_msg(self, msg_txt):
     msg = gst.message_new_application(self.pipeline, gst.Structure(msg_txt))
     self.pipeline.get_bus().post(msg)
Exemple #33
0
 def asr_result(self, asr, text, uttid):
     # Printing the detected text
     struct = gst.Structure('result')
     struct.set_value('hyp', text)
     struct.set_value('uttid', uttid)
     asr.post_message(gst.message_new_application(asr, struct))
Exemple #34
0
 def asr_partial_result(self, asr, text, uttid):
     """Forward partial result signals on the bus to the main thread."""
     struct = gst.Structure("partial_result")
     struct.set_value("hyp", text)
     struct.set_value("uttid", uttid)
     asr.post_message(gst.message_new_application(asr, struct))
Exemple #35
0
 def asr_result(self, asr, text, uttid):
     struct = gst.Structure('result')
     struct.set_value('hyp', text)
     struct.set_value('uttid', uttid)
     asr.post_message(gst.message_new_application(asr, struct))
def tags_cb(playbin2, stream, data):
    # We are possibly in a GStreamer working thread, so we notify the main
    # thread of this event through a message in the bus */
    playbin2.post_message(gst.message_new_application(playbin2, gst.Structure("tags-changed")))
Exemple #37
0
def _have_type(element, probability, caps, decodebin):
    decodebin.set_property('sink-caps', caps)
    struct = gst.Structure('have-type')
    struct['caps'] = caps.get_structure(0)
    element.get_bus().post(gst.message_new_application(element, struct))
Exemple #38
0
 def asr_result(self, asr, text, uttid):
     """ 前线结果到主线程 """
     struct = gst.Structure('result')
     struct.set_value('hyp', text)
     struct.set_value('uttid', uttid)
     asr.post_message(gst.message_new_application(asr, struct))