1 #ifndef RAPP_CLOUD_PATH_PLANNING
2 #define RAPP_CLOUD_PATH_PLANNING
23 const std::string map_name,
24 const std::string robot_type,
25 const std::string algorithm,
27 std::function<
void(std::unique_ptr<wav_file>)> callback,
28 const std::string token
32 boost::property_tree::ptree tree;
33 tree.put(
"text", text);
34 tree.put(
"language", language);
36 boost::property_tree::write_json(ss, tree,
false);
38 header_ =
"POST /hop/text_to_speech HTTP/1.1\r\n";
47 std::stringstream ss(json);
48 std::vector<rapp::types::byte> bytearray;
50 boost::property_tree::ptree tree;
51 boost::property_tree::read_json(ss, tree);
54 for (
auto child : tree.get_child(
"payload")) {
56 std::string result = child.second.get_value<std::string>();
57 std::string decoded =
decode64(result);
58 std::copy(decoded.begin(), decoded.end(), std::back_inserter(bytearray));
60 for (
auto child : tree.get_child(
"error")) {
61 const std::string value = child.second.get_value<std::string>();
63 std::cerr <<
"text_to_speech JSON error: " << value << std::endl;
67 catch (boost::property_tree::json_parser::json_parser_error & je) {
68 std::cerr <<
"text_to_speech::handle_reply Error parsing: " << je.filename()
69 <<
" on line: " << je.line() << std::endl;
70 std::cerr << je.message() << std::endl;
73 auto wav = std::unique_ptr<rapp::object::microphone_wav>(
79 std::function<void(std::unique_ptr<wav_file> wav)>
delegate_;
std::string header_
Header that will be used.
std::string decode64(const std::string &val)
decode base64
rapp::object::microphone_wav wav_file
std::string post_
Actual post Data.
WAV Single channel 16Khz > Headset audio source.
plan_path_d2(const std::string map_name, const std::string robot_type, const std::string algorithm, std::function< void(std::unique_ptr< wav_file >)> callback, const std::string token)
void handle_reply(std::string json)
handle platform's JSON reply
std::function< void(std::string)> callback_
Callback Handler - use with std::bind or boost variant.
std::function< void(std::unique_ptr< wav_file > wav)> delegate_
void handle_reply(std::string json)
handle platform's JSON reply
base class for asynchronous http websockets used for connecting to cloud services ...