/asr/set_locale
#
Caution
This documentation page has been auto-generated.
It may be missing some details.
/asr/set_locale
Quick Facts
- Category
- Message type
i18n_msgs/SetLocale
Sets the current language of the vosk speech recognition (ASR) engine. Returns immediately if the required language is already loaded.
See How-to: Automatic Speech Recognition (ASR) and Internationalisation and language support for details.
Quick snippets#
$ rostopic pub /asr/set_locale/goal i18n_msgs/SetLocaleActionGoal # press Tab to complete the message prototype
How to use in your code#
#!/usr/bin/env python
import rospy
import actionlib
from i18n_msgs.msg import *
if __name__ == "__main__":
client = actionlib.SimpleActionClient("/asr/set_locale", i18n_msgs.msg.SetLocaleAction)
client.wait_for_server()
# check the i18n_msgs/SetLocaleGoal message
# definition for the possible goal parameters
goal = i18n_msgs.msg.SetLocaleGoal(param1=..., param2=...)
client.send_goal(goal)
client.wait_for_result()
rospy.loginfo("Action returned: %s" % client.get_result())
#include <ros/ros.h>
#include <actionlib/client/simple_action_client.h>
#include <actionlib/client/terminal_state.h>
#include <i18n_msgs/SetLocaleAction.h>
int main (int argc, char **argv)
{
ros::init(argc, argv, "asr_set_locale_action_client");
// create the action client
// true causes the client to spin its own thread
actionlib::SimpleActionClient<:i18n_msgs::SetLocaleAction> ac("/asr/set_locale", true);
ROS_INFO("Waiting for action server to start.");
// wait for the action server to start
ac.waitForServer(); //will wait for infinite time
ROS_INFO("Action server started, sending goal.");
// send a goal to the action
i18n_msgs::SetLocaleGoal goal;
// check the i18n_msgs/SetLocaleGoal message
// definition for the possible goal parameters
// goal.... = ...;
ac.sendGoal(goal);
//wait for the action to return
bool finished_before_timeout = ac.waitForResult(ros::Duration(30.0));
if (finished_before_timeout)
{
actionlib::SimpleClientGoalState state = ac.getState();
ROS_INFO("Action finished: %s",state.toString().c_str());
}
else
{
ROS_INFO("Action did not finish before the time out.");
ac.cancelGoal();
}
return 0;
}