audio_common for ROS 2
Loading...
Searching...
No Matches
tts_node.hpp
Go to the documentation of this file.
1// MIT License
2//
3// Copyright (c) 2024 Miguel Ángel González Santamarta
4//
5// Permission is hereby granted, free of charge, to any person obtaining a copy
6// of this software and associated documentation files (the "Software"), to deal
7// in the Software without restriction, including without limitation the rights
8// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9// copies of the Software, and to permit persons to whom the Software is
10// furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in
13// all copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21// SOFTWARE.
22
23#ifndef AUDIO_COMMON__TTS_NODE
24#define AUDIO_COMMON__TTS_NODE
25
26#include <atomic>
27#include <mutex>
28#include <string>
29#include <thread>
30
31#include <chrono>
32#include <mutex>
33#include <sstream>
34#include <string>
35#include <thread>
36#include <vector>
37
38#include <rclcpp/rclcpp.hpp>
39#include <rclcpp_action/rclcpp_action.hpp>
40
42#include "audio_common_msgs/action/tts.hpp"
43#include "audio_common_msgs/msg/audio_stamped.hpp"
44
45namespace audio_common {
46
47class TtsNode : public rclcpp::Node {
48public:
49 using TTS = audio_common_msgs::action::TTS;
50 using GoalHandleTTS = rclcpp_action::ServerGoalHandle<TTS>;
51
52 TtsNode();
53
54private:
55 int chunk_;
56 std::string frame_id_;
57 rclcpp::Publisher<audio_common_msgs::msg::AudioStamped>::SharedPtr
59 rclcpp_action::Server<TTS>::SharedPtr action_server_;
60 std::mutex goal_lock_;
61 std::shared_ptr<GoalHandleTTS> goal_handle_;
62
63 // Methods
64 rclcpp_action::GoalResponse
65 handle_goal(const rclcpp_action::GoalUUID &uuid,
66 std::shared_ptr<const TTS::Goal> goal);
67 rclcpp_action::CancelResponse
68 handle_cancel(const std::shared_ptr<GoalHandleTTS> goal_handle);
69 void handle_accepted(const std::shared_ptr<GoalHandleTTS> goal_handle);
70 void execute_callback(const std::shared_ptr<GoalHandleTTS> goal_handle);
71};
72
73} // namespace audio_common
74
75#endif
rclcpp_action::ServerGoalHandle< TTS > GoalHandleTTS
Definition tts_node.hpp:50
rclcpp_action::GoalResponse handle_goal(const rclcpp_action::GoalUUID &uuid, std::shared_ptr< const TTS::Goal > goal)
Definition tts_node.cpp:65
audio_common_msgs::action::TTS TTS
Definition tts_node.hpp:49
std::shared_ptr< GoalHandleTTS > goal_handle_
Definition tts_node.hpp:61
rclcpp::Publisher< audio_common_msgs::msg::AudioStamped >::SharedPtr player_pub_
Definition tts_node.hpp:58
void handle_accepted(const std::shared_ptr< GoalHandleTTS > goal_handle)
Definition tts_node.cpp:78
std::mutex goal_lock_
Definition tts_node.hpp:60
TtsNode()
Definition tts_node.cpp:43
rclcpp_action::CancelResponse handle_cancel(const std::shared_ptr< GoalHandleTTS > goal_handle)
Definition tts_node.cpp:72
void execute_callback(const std::shared_ptr< GoalHandleTTS > goal_handle)
Definition tts_node.cpp:91
std::string frame_id_
Definition tts_node.hpp:56
int chunk_
Definition tts_node.hpp:55
rclcpp_action::Server< TTS >::SharedPtr action_server_
Definition tts_node.hpp:59
Definition audio_capturer_node.hpp:32