def Start(self): osc.osc_startup() osc.osc_udp_client(self._configuration.ipAddress, self._configuration.port, self._configuration.clientName) if self._transmitterThread is None: self._communicationQueue = queue.Queue() self._transmitterThread = threading.Thread(target=self.TransmitterLoop, args=[self._communicationQueue]) self._transmitterThread.start()
def main(sample_rate, device_name): # See http://g.co/cloud/speech/docs/languages # for a list of supported languages. language_code = 'en-US' # a BCP-47 language tag client = speech.SpeechClient() config = types.RecognitionConfig( encoding=enums.RecognitionConfig.AudioEncoding.LINEAR16, sample_rate_hertz=sample_rate, language_code=language_code, max_alternatives=1, enable_word_time_offsets=True) streaming_config = types.StreamingRecognitionConfig(config=config, interim_results=True) mic_manager = ResumableMicrophoneStream(sample_rate, int(sample_rate / 10), device_name, max_replay_secs=5) osc_startup() osc_udp_client('127.0.0.1', 2781, 'python-speech-to-text') msg = oscbuildparse.OSCMessage('/start', None, oscbuildparse.OSCbang()) osc_send(msg, 'python-speech-to-text') osc_process() with mic_manager as stream: resume = False while True: audio_generator = stream.generator(resume=resume) requests = (types.StreamingRecognizeRequest(audio_content=content) for content in audio_generator) responses = client.streaming_recognize(streaming_config, requests) try: # Now, put the transcription responses to use. listen_print_loop(responses, stream) # Teardown code should be executed here msg = oscbuildparse.OSCMessage('/stop', None, oscbuildparse.OSCbang()) osc_send(msg, 'python-speech-to-text') osc_process() osc_terminate() break except (exceptions.OutOfRange, exceptions.InvalidArgument) as e: if not ('maximum allowed stream duration' in e.message or 'deadline too short' in e.message): raise print('Resuming...') resume = True
def start(cls, host=None, port=None, client_name=None, debug=False): cls.debug = debug if host is not None: cls.host = host if port is not None: cls.port = port if client_name is not None: cls.client_name = client_name #osc_startup(logger=logging.getLogger(__name__)) osc_startup() osc_udp_client(cls.host, cls.port, cls.client_name) if not cls.running: cls.running = True return cls._run
def start(cls, port=9952): #osc_startup(logger=logging.getLogger(__name__)) osc_startup() cls.return_url = cls.host + ':' + str(port) osc_udp_server(cls.host, port, "osc_server") cls._register_handlers()
agentImage.header.stamp = rospy.Time.now() agentImage.header.frame_id = "unreal" agentImage.encoding = "rgba8" agentImage.height = 30 agentImage.width = 30 agentImage.data = data.tobytes() agentImage.is_bigendian = 0 agentImage.step = 30 * 4 rospy.loginfo("Publishing...") pubImage.publish(agentImage) rate.sleep() osc_startup() osc_udp_server("0.0.0.0", 7000, "UnrealGAMS") osc_method("/agent/0/pose", handleOSCPoseMessage) osc_method("/agent/0/pos", handleOSCPointMessage) osc_method("/agent/0/rgb", handleOSCImageMessage) pubPose = rospy.Publisher('agent/pose', PoseStamped, queue_size=10) pubPoint = rospy.Publisher('agent/point', PointStamped, queue_size=10) pubImage = rospy.Publisher('agent/rgb', Image, queue_size=10) rospy.init_node('agent', anonymous=True) rate = rospy.Rate(100) # 100hz if __name__ == '__main__': try: