View Single Post
Posts: 7 | Thanked: 17 times | Joined on Jun 2012
#258
taixzo,
you can download the patched gstpocketsphinx-plugin
here.
md5sum: 84fd12b19df535177870920c29615789

Here are the appropriate saera-code snippets to make use of the scored result:

Code:
class Saera:
	def __init__(self):
		self.result_score = False
Code:
	def init_gst(self):
		"""Initialize the speech components"""
		self.pipeline = gst.parse_launch('pulsesrc ! audioconvert ! audioresample '
										 + '! vader name=vad  auto-threshold=true '
										 + '! pocketsphinx name=asr ! fakesink')
		asr = self.pipeline.get_by_name('asr')
		asr.connect('partial_result', self.asr_partial_result)
		asr.connect('result', self.asr_result)
		asr.connect('result_score', self.asr_result_score)
		asr.set_property('configured', True)
Code:
	def asr_result_score(self, asr, text, score):
		"""Forward result signals on the bus to the main thread."""
		struct = gst.Structure('result_score')
		struct.set_value('hyp', text)
		struct.set_value('score', score)
		asr.post_message(gst.message_new_application(asr, struct))
Code:
	def application_message(self, bus, msg):
		"""Receive application messages from the bus."""
		msgtype = msg.structure.get_name()
		if msgtype == 'partial_result':
			self.partial_result(msg.structure['hyp'], msg.structure['uttid'])
		elif msgtype == 'result_score':
			self.result_score = True
			self.final_result_score(msg.structure['hyp'], msg.structure['score'])
			# self.pipeline.set_state(gst.STATE_PAUSED)
		elif msgtype == 'result'  and  self.result_score == False:
			self.final_result(msg.structure['hyp'], msg.structure['uttid'])
Code:
	def final_result_score(self, hyp, score):
		"""Insert the final result."""
		# All this stuff appears as one single action
		print "Final Result: ", hyp, "  score: ", score
		if int(score) > -18500000:
			self.run_saera(None, "speech-event", hyp)
Regarding the minimum score, this depends on the device (on my laptop the score is much higher than on the N900) and on the pocketsphinx settings (min frequency, max frequency, num channels etc), so I suggest to stay with the default settings. (I tried to vary these settings in order to get a better accuracy, but no luck.)

BTW: How can I upload a file on talk.maemo.org ?
 

The Following 8 Users Say Thank You to myra For This Useful Post: