Skip to content

Commit

Permalink
format fixes
Browse files Browse the repository at this point in the history
  - adding this
  - removing unused params
  • Loading branch information
mgonzs13 committed Dec 26, 2024
1 parent eddfe07 commit 73ac3cb
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 20 deletions.
1 change: 0 additions & 1 deletion audio_common/include/audio_common/tts_node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class TtsNode : public rclcpp::Node {
private:
int chunk_;
std::string frame_id_;
std::string espeak_cmd_;
rclcpp::Publisher<audio_common_msgs::msg::AudioStamped>::SharedPtr
player_pub_;
rclcpp_action::Server<TTS>::SharedPtr action_server_;
Expand Down
10 changes: 5 additions & 5 deletions audio_common/src/audio_common/audio_capturer_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,23 +102,23 @@ void AudioCapturerNode::work() {

switch (this->format_) {
case paFloat32: {
msg.audio.audio_data.float32_data = read_data<float>();
msg.audio.audio_data.float32_data = this->read_data<float>();
break;
}
case paInt32: {
msg.audio.audio_data.int32_data = read_data<int32_t>();
msg.audio.audio_data.int32_data = this->read_data<int32_t>();
break;
}
case paInt16: {
msg.audio.audio_data.int16_data = read_data<int16_t>();
msg.audio.audio_data.int16_data = this->read_data<int16_t>();
break;
}
case paInt8: {
msg.audio.audio_data.int8_data = read_data<int8_t>();
msg.audio.audio_data.int8_data = this->read_data<int8_t>();
break;
}
case paUInt8: {
msg.audio.audio_data.uint8_data = read_data<uint8_t>();
msg.audio.audio_data.uint8_data = this->read_data<uint8_t>();
break;
}
default:
Expand Down
12 changes: 6 additions & 6 deletions audio_common/src/audio_common/audio_player_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void AudioPlayerNode::audio_callback(
std::to_string(this->channels_);

// Check if stream already exists, if not, create one
if (stream_dict_.find(stream_key) == stream_dict_.end()) {
if (this->stream_dict_.find(stream_key) == this->stream_dict_.end()) {
PaStreamParameters outputParameters;
outputParameters.device =
(this->device_ >= 0) ? this->device_ : Pa_GetDefaultOutputDevice();
Expand All @@ -90,17 +90,17 @@ void AudioPlayerNode::audio_callback(
Pa_GetDeviceInfo(outputParameters.device)->defaultLowOutputLatency;
outputParameters.hostApiSpecificStreamInfo = nullptr;

PaError err =
Pa_OpenStream(&stream_dict_[stream_key], nullptr, &outputParameters,
msg->audio.info.rate, paFramesPerBufferUnspecified,
paClipOff, nullptr, nullptr);
PaError err = Pa_OpenStream(&this->stream_dict_[stream_key], nullptr,
&outputParameters, msg->audio.info.rate,
paFramesPerBufferUnspecified, paClipOff,
nullptr, nullptr);

if (err != paNoError) {
RCLCPP_ERROR(this->get_logger(), "Failed to open audio stream: %s",
Pa_GetErrorText(err));
return;
}
Pa_StartStream(stream_dict_[stream_key]);
Pa_StartStream(this->stream_dict_[stream_key]);
}

// Convert ROS message to array
Expand Down
15 changes: 7 additions & 8 deletions audio_common/src/audio_common/tts_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,20 @@ using namespace std::chrono_literals;
using std::placeholders::_1;
using std::placeholders::_2;

TtsNode::TtsNode() : Node("tts_node"), chunk_(4096), frame_id_("") {
TtsNode::TtsNode() : Node("tts_node") {

this->declare_parameter("chunk", 4096);
this->declare_parameter("frame_id", "");

chunk_ = this->get_parameter("chunk").as_int();
frame_id_ = this->get_parameter("frame_id").as_string();
this->chunk_ = this->get_parameter("chunk").as_int();
this->frame_id_ = this->get_parameter("frame_id").as_string();

espeak_cmd_ = "espeak -v%s -s%d -a%d -w %s '%s'";

player_pub_ = this->create_publisher<audio_common_msgs::msg::AudioStamped>(
"audio", rclcpp::SensorDataQoS());
this->player_pub_ =
this->create_publisher<audio_common_msgs::msg::AudioStamped>(
"audio", rclcpp::SensorDataQoS());

// Action server
action_server_ = rclcpp_action::create_server<TTS>(
this->action_server_ = rclcpp_action::create_server<TTS>(
this, "say", std::bind(&TtsNode::handle_goal, this, _1, _2),
std::bind(&TtsNode::handle_cancel, this, _1),
std::bind(&TtsNode::handle_accepted, this, _1));
Expand Down

0 comments on commit 73ac3cb

Please sign in to comment.