MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / build_request_from_cli

Function build_request_from_cli

app/cli/request.cpp:232–342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

230 };
231}
232
233std::string json_option_string(const engine::io::json::Value & value) {
234 if (value.is_string()) {
235 return value.as_string();
236 }
237 if (value.is_bool()) {
238 return value.as_bool() ? "true" : "false";
239 }
240 if (value.is_number()) {
241 const double number = value.as_number();
242 constexpr double kMaxExactJsonInteger = 9007199254740992.0; // 2^53
243 if (std::isfinite(number) && std::trunc(number) == number && std::fabs(number) < kMaxExactJsonInteger) {
244 std::ostringstream out;
245 out << std::fixed << std::setprecision(0) << number;
246 return out.str();
247 }
248 return engine::io::json::stringify_number(number);
249 }
250 return engine::io::json::stringify(value);
251}
252
253std::unordered_map<std::string, std::string> json_options_map(const engine::io::json::Value * value) {
254 std::unordered_map<std::string, std::string> options;
255 if (value == nullptr || value->is_null()) {
256 return options;
257 }
258 for (const auto & [key, child] : value->as_object()) {
259 options[key] = json_option_string(child);
260 }
261 return options;
262}
263
264std::optional<std::string> json_optional_string(
265 const engine::io::json::Value & object,
266 const std::string & key) {
267 const auto * value = object.find(key);
268 if (value == nullptr || value->is_null()) {
269 return std::nullopt;
270 }
271 return value->as_string();
272}
273
274std::optional<float> json_optional_float(
275 const engine::io::json::Value & object,
276 const std::string & key) {
277 const auto * value = object.find(key);
278 if (value == nullptr || value->is_null()) {
279 return std::nullopt;
280 }
281 return value->as_f32();
282}
283
284std::vector<engine::runtime::VoiceArtifact> json_request_artifacts(
285 const engine::io::json::Value * value,
286 const std::filesystem::path & base_dir) {
287 std::vector<engine::runtime::VoiceArtifact> artifacts;
288 if (value == nullptr || value->is_null()) {
289 return artifacts;

Callers 1

mainFunction · 0.85

Calls 7

parse_optional_float_argFunction · 0.85
collect_key_value_argsFunction · 0.85
set_optionFunction · 0.85
set_option_from_argFunction · 0.85
find_argFunction · 0.70
read_audio_bufferFunction · 0.70
emptyMethod · 0.45

Tested by

no test coverage detected