cli.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 # Copyright: Yuki Furuta <furushchev@jsk.imi.i.u-tokyo.ac.jp>
4 
5 import os
6 import rospy
7 from speech_recognition_msgs.msg import Vocabulary
8 from speech_recognition_msgs.msg import Grammar
9 from julius_ros.utils import load_grammar
10 
11 
12 def register_isolated(name, words):
13  pub = rospy.Publisher("/vocabulary", Vocabulary, queue_size=1)
14  for i in range(10):
15  if rospy.is_shutdown() or pub.get_num_connections() > 0:
16  break
17  rospy.sleep(1)
18  rospy.loginfo("Waiting /vocabulary is advertised")
19  if pub.get_num_connections() == 0:
20  rospy.logerr("/vocabulary is not advertised")
21  return
22  voca = Vocabulary(words=words)
23  if name:
24  voca.name = name
25  pub.publish(voca)
26 
27 
28 def register_grammar(name, path):
29  root_dir, name = os.path.dirname(path), os.path.basename(path)
30  pub = rospy.Publisher("/grammar", Grammar, queue_size=1)
31  for i in range(10):
32  if rospy.is_shutdown() or pub.get_num_connections() > 0:
33  break
34  rospy.sleep(1)
35  rospy.loginfo("Waiting /grammar is advertised")
36  if pub.get_num_connections() == 0:
37  rospy.logerr("/grammar is not advertised")
38  return
39  gram = load_grammar(root_dir, name)
40  if name:
41  gram.name = name
42  pub.publish(gram)
def load_grammar(path, name)
Definition: utils.py:37
def register_isolated(name, words)
Definition: cli.py:12
def register_grammar(name, path)
Definition: cli.py:28


julius_ros
Author(s): Yuki Furuta
autogenerated on Tue May 11 2021 02:55:36