-
Notifications
You must be signed in to change notification settings - Fork 248
Incremental build optimizations #4082
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
2dd4e89
8c5590c
dd6571e
7bc73c2
08cd7e0
948229f
1aa6003
b7d3f4e
a09dd9f
a9699ee
c9e6bfb
10bc0ef
1e888cf
7ff32a5
f0daff0
12e505a
580ebd4
9601e4e
75aa6ce
10a31d9
130bda9
de93707
39d0c7b
318c3bc
6b1484d
de43e50
dec98e2
3c3ac5f
3ff6f2f
4c201ab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| //***************************************************************************** | ||
| // Copyright 2026 Intel Corporation | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
| //***************************************************************************** | ||
| #include <memory> | ||
| #include <string> | ||
| #include <utility> | ||
|
|
||
| #include "src/mediapipe_internal/graph_side_packets.hpp" | ||
| #include "src/mediapipe_internal/node_initializer.hpp" | ||
| #include "src/stringutils.hpp" | ||
| #include "s2t_servable.hpp" | ||
| #include "mediapipe/framework/calculator.pb.h" | ||
| #include "src/audio/speech_to_text/s2t_calculator.pb.h" | ||
|
|
||
| #include "src/logging.hpp" | ||
|
|
||
| namespace ovms { | ||
| class SttNodeInitializer : public NodeInitializer { | ||
| static constexpr const char* CALCULATOR_NAME = "S2tCalculator"; | ||
|
|
||
| public: | ||
| bool matches(const std::string& calculatorName) const override { | ||
| return endsWith(calculatorName, CALCULATOR_NAME); | ||
| } | ||
| Status initialize( | ||
| const ::mediapipe::CalculatorGraphConfig_Node& nodeConfig, | ||
| const std::string& graphName, | ||
| const std::string& basePath, | ||
| GraphSidePackets& sidePackets, | ||
| PythonBackend* /*pythonBackend*/) override { | ||
| auto& sttServableMap = sidePackets.sttServableMap; | ||
| if (!nodeConfig.node_options().size()) { | ||
| SPDLOG_ERROR("SpeechToText node missing options in graph: {}. ", graphName); | ||
| return StatusCode::LLM_NODE_MISSING_OPTIONS; | ||
| } | ||
| if (nodeConfig.name().empty()) { | ||
| SPDLOG_ERROR("SpeechToText node name is missing in graph: {}. ", graphName); | ||
| return StatusCode::LLM_NODE_MISSING_NAME; | ||
| } | ||
| std::string nodeName = nodeConfig.name(); | ||
| if (sttServableMap.find(nodeName) != sttServableMap.end()) { | ||
| SPDLOG_ERROR("SpeechToText node name: {} already used in graph: {}. ", nodeName, graphName); | ||
| return StatusCode::LLM_NODE_NAME_ALREADY_EXISTS; | ||
| } | ||
| mediapipe::S2tCalculatorOptions nodeOptions; | ||
| const auto& calculatorOptions = nodeConfig.node_options(0); | ||
| if (!calculatorOptions.UnpackTo(&nodeOptions)) { | ||
| SPDLOG_ERROR("Failed to unpack calculator options"); | ||
| return StatusCode::MEDIAPIPE_GRAPH_CONFIG_FILE_INVALID; | ||
| } | ||
| auto servable = std::make_shared<SttServable>(nodeOptions, basePath); | ||
| sttServableMap.insert(std::pair<std::string, std::shared_ptr<SttServable>>(nodeName, std::move(servable))); | ||
| return StatusCode::OK; | ||
| } | ||
| }; | ||
|
|
||
| static bool sttNodeInitializerRegistered = []() { | ||
| NodeInitializerRegistry::instance().add(std::make_unique<SttNodeInitializer>()); | ||
| return true; | ||
| }(); | ||
| } // namespace ovms | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| //***************************************************************************** | ||
| // Copyright 2026 Intel Corporation | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
| //***************************************************************************** | ||
| #include <memory> | ||
| #include <stdexcept> | ||
| #include <string> | ||
| #include <utility> | ||
|
|
||
| #include "src/mediapipe_internal/graph_side_packets.hpp" | ||
| #include "src/mediapipe_internal/node_initializer.hpp" | ||
| #include "src/stringutils.hpp" | ||
| #include "t2s_servable.hpp" | ||
| #include "mediapipe/framework/calculator.pb.h" | ||
| #include "src/audio/text_to_speech/t2s_calculator.pb.h" | ||
|
|
||
| #include "src/logging.hpp" | ||
|
|
||
| namespace ovms { | ||
| class TtsNodeInitializer : public NodeInitializer { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. plz TextToSpeechNodeInitializer
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am just following TtsServable/SttServable name convention here. |
||
| static constexpr const char* CALCULATOR_NAME = "T2sCalculator"; | ||
|
|
||
| public: | ||
| bool matches(const std::string& calculatorName) const override { | ||
| return endsWith(calculatorName, CALCULATOR_NAME); | ||
| } | ||
| Status initialize( | ||
| const ::mediapipe::CalculatorGraphConfig_Node& nodeConfig, | ||
| const std::string& graphName, | ||
| const std::string& basePath, | ||
| GraphSidePackets& sidePackets, | ||
| PythonBackend* /*pythonBackend*/) override { | ||
| auto& ttsServableMap = sidePackets.ttsServableMap; | ||
| if (!nodeConfig.node_options().size()) { | ||
| SPDLOG_ERROR("TextToSpeech node missing options in graph: {}. ", graphName); | ||
| return StatusCode::LLM_NODE_MISSING_OPTIONS; | ||
| } | ||
| if (nodeConfig.name().empty()) { | ||
| SPDLOG_ERROR("TextToSpeech node name is missing in graph: {}. ", graphName); | ||
| return StatusCode::LLM_NODE_MISSING_NAME; | ||
| } | ||
| std::string nodeName = nodeConfig.name(); | ||
| if (ttsServableMap.find(nodeName) != ttsServableMap.end()) { | ||
| SPDLOG_ERROR("TextToSpeech node name: {} already used in graph: {}. ", nodeName, graphName); | ||
| return StatusCode::LLM_NODE_NAME_ALREADY_EXISTS; | ||
| } | ||
| mediapipe::T2sCalculatorOptions nodeOptions; | ||
| const auto& calculatorOptions = nodeConfig.node_options(0); | ||
| if (!calculatorOptions.UnpackTo(&nodeOptions)) { | ||
| SPDLOG_ERROR("Failed to unpack calculator options"); | ||
| return StatusCode::MEDIAPIPE_GRAPH_CONFIG_FILE_INVALID; | ||
| } | ||
| try { | ||
| auto servable = std::make_shared<TtsServable>(nodeOptions.models_path(), nodeOptions.target_device(), nodeOptions.voices(), nodeOptions.plugin_config(), basePath); | ||
| ttsServableMap.insert(std::pair<std::string, std::shared_ptr<TtsServable>>(nodeName, std::move(servable))); | ||
| } catch (const std::runtime_error& e) { | ||
| SPDLOG_ERROR("TextToSpeech node name: {} initialization failed: {}. ", nodeName, e.what()); | ||
| return StatusCode::MEDIAPIPE_GRAPH_CONFIG_FILE_INVALID; | ||
| } | ||
| return StatusCode::OK; | ||
| } | ||
| }; | ||
|
|
||
| static bool ttsNodeInitializerRegistered = []() { | ||
| NodeInitializerRegistry::instance().add(std::make_unique<TtsNodeInitializer>()); | ||
| return true; | ||
| }(); | ||
| } // namespace ovms | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SttNodeInitializer - lets give it a meaningful name SpeechToTextNodeInitializer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am just following TtsServable/SttServable name convention here.