Logo
ApraPipes 1.0
Loading...
Searching...
No Matches
AudioToTextXForm.h
1#pragma once
2
3#include "Module.h"
4#include "declarative/PropertyMacros.h"
5
6// size of audio to process should be a parameter.
7// Cache variable to collect frames for processing
8
10{
11public:
16
18 std::string modelPath;
20
21 // Default constructor for declarative pipeline
25
27 DecoderSamplingStrategy _samplingStrategy,
28 std::string _modelPath,
29 int _bufferSize);
30 size_t getSerializeSize();
31
32 // ============================================================
33 // Property Binding for Declarative Pipeline
34 // ============================================================
35 template<typename PropsT>
36 static void applyProperties(
37 PropsT& props,
38 const std::map<std::string, apra::ScalarPropertyValue>& values,
39 std::vector<std::string>& missingRequired
40 ) {
41 apra::applyProp(props.modelPath, "modelPath", values, true, missingRequired);
42 apra::applyProp(props.bufferSize, "bufferSize", values, false, missingRequired);
43
44 // Handle enum via string
45 auto it = values.find("samplingStrategy");
46 if (it != values.end()) {
47 if (auto* val = std::get_if<std::string>(&it->second)) {
48 if (*val == "GREEDY") {
49 props.samplingStrategy = GREEDY;
50 } else if (*val == "BEAM_SEARCH") {
51 props.samplingStrategy = BEAM_SEARCH;
52 }
53 }
54 }
55 }
56
57 apra::ScalarPropertyValue getProperty(const std::string& propName) const {
58 if (propName == "modelPath") return modelPath;
59 if (propName == "bufferSize") return static_cast<int64_t>(bufferSize);
60 if (propName == "samplingStrategy") {
61 return samplingStrategy == GREEDY ? std::string("GREEDY") : std::string("BEAM_SEARCH");
62 }
63 throw std::runtime_error("Unknown property: " + propName);
64 }
65
66 bool setProperty(const std::string& propName, const apra::ScalarPropertyValue& value) {
67 return false; // All properties are static
68 }
69
70 static std::vector<std::string> dynamicPropertyNames() {
71 return {};
72 }
73
74private:
76
77 template <class Archive>
78 void serialize(Archive& ar, const unsigned int version);
79};
80
82{
83
84public:
86 virtual ~AudioToTextXForm();
87 bool init();
88 bool term();
91
92protected:
93 bool process(frame_container& frames);
94 bool processSOS(frame_sp& frame);
95 bool validateInputPins();
96 bool validateOutputPins();
97 void addInputPin(framemetadata_sp& metadata, string& pinId);
98 bool handlePropsChange(frame_sp& frame);
99 bool processEOS(string &pinId);
101
102private:
103 void setMetadata(framemetadata_sp& metadata);
104 class Detail;
105 boost::shared_ptr<Detail> mDetail;
106};
Definition AudioToTextXForm.h:10
void serialize(Archive &ar, const unsigned int version)
Definition AudioToTextXForm.cpp:26
int bufferSize
Definition AudioToTextXForm.h:19
static void applyProperties(PropsT &props, const std::map< std::string, apra::ScalarPropertyValue > &values, std::vector< std::string > &missingRequired)
Definition AudioToTextXForm.h:36
static std::vector< std::string > dynamicPropertyNames()
Definition AudioToTextXForm.h:70
bool setProperty(const std::string &propName, const apra::ScalarPropertyValue &value)
Definition AudioToTextXForm.h:66
DecoderSamplingStrategy samplingStrategy
Definition AudioToTextXForm.h:17
size_t getSerializeSize()
Definition AudioToTextXForm.cpp:18
DecoderSamplingStrategy
Definition AudioToTextXForm.h:12
@ GREEDY
Definition AudioToTextXForm.h:13
@ BEAM_SEARCH
Definition AudioToTextXForm.h:14
apra::ScalarPropertyValue getProperty(const std::string &propName) const
Definition AudioToTextXForm.h:57
friend class boost::serialization::access
Definition AudioToTextXForm.h:75
std::string modelPath
Definition AudioToTextXForm.h:18
AudioToTextXFormProps()
Definition AudioToTextXForm.h:22
Definition AudioToTextXForm.cpp:34
Definition AudioToTextXForm.h:82
void setMetadata(framemetadata_sp &metadata)
Definition AudioToTextXForm.cpp:187
void setProps(AudioToTextXFormProps &props)
Definition AudioToTextXForm.cpp:217
bool process(frame_container &frames)
Definition AudioToTextXForm.cpp:154
bool handleFlushingBuffer()
Definition AudioToTextXForm.cpp:231
AudioToTextXForm(AudioToTextXFormProps _props)
Definition AudioToTextXForm.cpp:74
bool term()
Definition AudioToTextXForm.cpp:146
AudioToTextXFormProps getProps()
Definition AudioToTextXForm.cpp:202
bool init()
Definition AudioToTextXForm.cpp:137
bool validateInputPins()
Definition AudioToTextXForm.cpp:81
bool validateOutputPins()
Definition AudioToTextXForm.cpp:110
void addInputPin(framemetadata_sp &metadata, string &pinId)
Definition AudioToTextXForm.cpp:129
bool processEOS(string &pinId)
Definition AudioToTextXForm.cpp:225
bool processSOS(frame_sp &frame)
Definition AudioToTextXForm.cpp:195
boost::shared_ptr< Detail > mDetail
Definition AudioToTextXForm.h:105
bool handlePropsChange(frame_sp &frame)
Definition AudioToTextXForm.cpp:208
virtual ~AudioToTextXForm()
Definition AudioToTextXForm.cpp:79
Definition Module.h:33
Definition Module.h:151
void applyProp(T &member, const char *propName, const std::map< std::string, ScalarPropertyValue > &values, bool isRequired, std::vector< std::string > &missingRequired)
Definition PropertyMacros.h:36
std::variant< int64_t, double, bool, std::string > ScalarPropertyValue
Definition ModuleRegistry.h:30