FP Perception 0.1.2
Loading...
Searching...
No Matches
structs.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4#include <string>
5#include <rclcpp/rclcpp.hpp>
6#include <fp_perception_msgs/msg/perception_audio.hpp>
7#include <fp_perception_msgs/msg/perception_text.hpp>
8
9namespace fp_perception
10{
11
16{
17 std::vector<int16_t> samples;
18 int sample_rate = 44100;
19 int channels = 1;
20 int chunk_size = 256;
21 int chunk_count = 0;
22 bool override = false;
23};
24
26{
28 bool use_time_window = false;
29 rclcpp::Time start_time;
30};
31
33{
34 std::string text;
35 std::string voice;
36 std::string instructions;
37};
38
45fp_perception_msgs::msg::PerceptionAudio audio_data_to_msg(const audio_data& data)
46{
47 fp_perception_msgs::msg::PerceptionAudio msg;
48
49 msg.header.stamp = rclcpp::Clock().now();
50 msg.header.frame_id = "audio_frame"; // Default frame ID, can be changed as needed
51 msg.sample_rate = data.sample_rate;
52 msg.channels = data.channels;
53 msg.chunk_size = data.chunk_size;
54 msg.chunk_count = data.chunk_count;
55 msg.samples = data.samples;
56 msg.override = data.override;
57
58 return msg;
59}
60
67audio_data msg_to_audio_data(const fp_perception_msgs::msg::PerceptionAudio& msg)
68{
69 audio_data data;
70
71 data.samples = msg.samples;
72 data.sample_rate = msg.sample_rate;
73 data.channels = msg.channels;
74 data.chunk_size = msg.chunk_size;
75 data.chunk_count = msg.chunk_count;
76 data.override = msg.override;
77
78 return data;
79}
80
81fp_perception_msgs::msg::PerceptionText text_data_to_msg(const text_data& data)
82{
83 fp_perception_msgs::msg::PerceptionText msg;
84
85 msg.header.stamp = rclcpp::Clock().now();
86 msg.header.frame_id = "text_frame"; // Default frame ID, can be changed as needed
87 msg.text = data.text;
88 msg.voice = data.voice;
89 msg.instructions = data.instructions;
90
91 return msg;
92}
93
94text_data msg_to_text_data(const fp_perception_msgs::msg::PerceptionText& msg)
95{
96 text_data data;
97
98 data.text = msg.text;
99 data.voice = msg.voice;
100 data.instructions = msg.instructions;
101
102 return data;
103}
104
105} // namespace fp_perception
Definition audio_buffer.hpp:16
text_data msg_to_text_data(const fp_perception_msgs::msg::PerceptionText &msg)
Definition structs.hpp:94
fp_perception_msgs::msg::PerceptionText text_data_to_msg(const text_data &data)
Definition structs.hpp:81
fp_perception_msgs::msg::PerceptionAudio audio_data_to_msg(const audio_data &data)
Convert fp_perception::audio_data to fp_perception_msgs::msg::PerceptionAudio message.
Definition structs.hpp:45
audio_data msg_to_audio_data(const fp_perception_msgs::msg::PerceptionAudio &msg)
Convert fp_perception_msgs::msg::PerceptionAudio message to audio_data.
Definition structs.hpp:67
Definition structs.hpp:26
int duration_seconds
Definition structs.hpp:27
bool use_time_window
Definition structs.hpp:28
rclcpp::Time start_time
Definition structs.hpp:29
Struct to hold audio data.
Definition structs.hpp:16
int chunk_count
Number of chunks in the audio data.
Definition structs.hpp:21
std::vector< int16_t > samples
Audio samples.
Definition structs.hpp:17
int sample_rate
Sample rate in Hz.
Definition structs.hpp:18
int channels
Number of audio channels.
Definition structs.hpp:19
bool override
if the system sample_rate, channels, and chunk_size should be overridden by message data
Definition structs.hpp:22
int chunk_size
Size of each audio chunk in samples.
Definition structs.hpp:20
Definition structs.hpp:33
std::string instructions
Model to be used for processing.
Definition structs.hpp:36
std::string voice
Options for processing the text.
Definition structs.hpp:35
std::string text
Text data to be processed.
Definition structs.hpp:34