コード例 #1
0
    def speechToText(self, send_socket):
        print('Starting Recognizer thread')
        sphinx = Sphinx()

        while True:
            frames = self.AUDIO_QUEUE.get()

            if frames == None:
                break

            result = self.sphinx_recognize(frames, sphinx)

            self.log.debug("[LISTEN FOR SPEECH] FINISHED RECOGNIZER THREADS")

            formatted_commands = []

            if result:
                c = Command(result)
                formatted_commands.append(c.format_command())
                self.log.info(str(formatted_commands[-1]))
            else:
                formatted_commands.append(['', '', '', '', ''])

            command_list = self.analyze_commands(formatted_commands)
            text = encode_command(command_list)

            if text:
                self.log.info("Command: \n\n" + text)
                send_socket.send_message(text)
            else:
                send_socket.send_message('invalid/')
コード例 #2
0
ファイル: link.py プロジェクト: haoyett/somai_web
	def connectSphinx(self):
		"""
		连接Sphinx

		Returns:
			sphinx instance.
		"""
		cf = ConfigParser()
		cf.read('conf/config.ini')
		sphinxconfig = {
			'host': cf.get('sphinx', 'host'), 
			'port': cf.get('sphinx', 'port')
		}
		sp = Sphinx(sphinxconfig)
		return sp
コード例 #3
0
ファイル: views.py プロジェクト: Aimsam/vd
def get_update_number(request):
    if 'follow_dict' not in request.GET:
        return HttpResponse("json({'code' : 501, 'message' : 'follow_dict not given'})")
    follow_dict = request.GET['follow_dict']
    s = Sphinx()
    return HttpResponse("jsonp5(" + s.get_author_update_number(follow_dict) + ")")
コード例 #4
0
ファイル: views.py プロジェクト: Aimsam/vd
def test(request):
    s = Sphinx()
    return HttpResponse(s.get_author_update_number(["蓝"], 1284652800))
    #callback = request.GET['callback']
    return HttpResponse("j(" + str({"code" :400}) +")")