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

Function ace_step_parse_request

src/models/ace_step/request_parser.cpp:118–282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116} // namespace
117
118AceStepRequest ace_step_parse_request(const runtime::TaskRequest &request) {
119 if (!request.text_input.has_value()) {
120 throw std::runtime_error("ACE-Step requires text_input");
121 }
122 AceStepRequest out;
123 out.prompt = request.text_input->text;
124 out.vocal_language = request.text_input->language.empty() ? "en" : request.text_input->language;
125 out.source_audio = request.audio_input;
126 if (const auto lyrics = runtime::find_option(request.options, {"lyrics"}); lyrics.has_value()) {
127 out.lyrics = *lyrics;
128 }
129 if (const auto negative = runtime::find_option(request.options, {"negative_prompt"}); negative.has_value()) {
130 out.negative_prompt = *negative;
131 }
132 if (const auto instruction = runtime::find_option(request.options, {"instruction"}); instruction.has_value()) {
133 out.instruction = *instruction;
134 }
135 const auto audio_codes = runtime::find_option(request.options, {"audio_codes"});
136 const auto audio_code_string = runtime::find_option(request.options, {"audio_code_string"});
137 const std::optional<std::string> audio_codes_value =
138 audio_codes.has_value() ? audio_codes : audio_code_string;
139 if (audio_codes_value.has_value() && !audio_codes_value->empty()) {
140 AceStepPlan codes_plan = ace_step_parse_lm_output(*audio_codes_value);
141 if (codes_plan.audio_code_ids.empty()) {
142 throw std::runtime_error("ACE-Step audio_codes contains no audio code tokens");
143 }
144 out.audio_codes_text = std::move(codes_plan.audio_codes_text);
145 out.audio_code_ids = std::move(codes_plan.audio_code_ids);
146 }
147 if (const auto track_name = runtime::find_option(request.options, {"track_name"}); track_name.has_value()) {
148 out.track_name = *track_name;
149 }
150 out.complete_track_classes = option_string_list(request, "complete_track_classes");
151 if (const auto route = runtime::find_option(request.options, {"route"}); route.has_value()) {
152 out.task_type = *route;
153 }
154 out.task = ace_step_parse_task_type(out.task_type);
155 out.task_type = std::string(ace_step_task_type_name(out.task));
156 if (out.task == AceStepTaskType::Extract) {
157 out.generation.thinking = false;
158 out.generation.use_cot_metas = false;
159 out.generation.use_cot_caption = false;
160 out.generation.use_cot_language = false;
161 out.generation.guidance_scale = 7.0F;
162 out.generation.shift = 3.0F;
163 }
164 if (const auto bpm = runtime::find_option(request.options, {"bpm"}); bpm.has_value()) {
165 out.bpm = runtime::parse_i64_option(request.options, {"bpm"}).value();
166 }
167 if (const auto keyscale = runtime::find_option(request.options, {"keyscale"}); keyscale.has_value()) {
168 out.keyscale = *keyscale;
169 }
170 if (const auto timesignature = runtime::find_option(request.options, {"timesignature"}); timesignature.has_value()) {
171 out.timesignature = *timesignature;
172 }
173 if (const auto chunk_mask_mode = runtime::find_option(request.options, {"chunk_mask_mode"});
174 chunk_mask_mode.has_value()) {
175 out.chunk_mask_mode = *chunk_mask_mode;

Callers 1

runMethod · 0.85

Calls 14

find_optionFunction · 0.85
ace_step_parse_lm_outputFunction · 0.85
option_string_listFunction · 0.85
ace_step_parse_task_typeFunction · 0.85
ace_step_task_type_nameFunction · 0.85
parse_i64_optionFunction · 0.85
parse_float_optionFunction · 0.85
parse_bool_optionFunction · 0.85
parse_u32_optionFunction · 0.85
random_u32_seedFunction · 0.85
option_f32_listFunction · 0.85

Tested by

no test coverage detected