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 set_option_from_json_field(request.options, value, "num_beams", "num_beams");
231 set_option_from_json_field(request.options, value, "guidance_scale", "guidance_scale");
232 set_option_from_json_field(request.options, value, "num_inference_steps", "num_inference_steps");
233 set_option_from_json_field(request.options, value, "text_chunk_size", "text_chunk_size");
234 set_option_from_json_field(request.options, value, "text_chunk_mode", "text_chunk_mode");
235 set_option_from_json_field(request.options, value, "audio_chunk_seconds", "audio_chunk_seconds");
236 set_option_from_json_field(request.options, value, "audio_chunk_mode", "audio_chunk_mode");
237 set_option_from_json_field(request.options, value, "return_timestamps", "return_timestamps");
238 set_option_from_json_field(request.options, value, "use_prosody_code", "use_prosody_code");
239 set_option_from_json_field(request.options, value, "predict_target_prosody", "predict_target_prosody");
240 set_option_from_json_field(request.options, value, "use_pitch_shift", "use_pitch_shift");
241 set_option_from_json_field(request.options, value, "source_shift_steps", "source_shift_steps");
242 set_option_from_json_field(request.options, value, "prosody_shift_steps", "prosody_shift_steps");
243 set_option_from_json_field(request.options, value, "style_shift_steps", "style_shift_steps");
244 set_option_from_json_field(request.options, value, "target_duration_seconds", "target_duration_seconds");
245 set_option_from_json_field(request.options, value, "reference_duration_seconds", "reference_duration_seconds");
246 if (const auto reference_text = json_optional_string(value, "reference_text")) {
247 set_option(request.options, "reference_text", *reference_text);
248 }
249 if (const auto instruct = json_optional_string(value, "instruct")) {
250 set_option(request.options, "instruct", *instruct);
251 }
252 return request;
253}
254
255engine::runtime::TaskRequest build_request_from_cli(int argc, char ** argv) {
256 engine::runtime::TaskRequest request;
257 const auto language = find_arg(argc, argv, "--language").value_or("");
258 if (const auto text = find_arg(argc, argv, "--text")) {
259 request.text_input = engine::runtime::Transcript{*text, language};
260 }
261 if (const auto audio_path = find_arg(argc, argv, "--audio")) {
262 request.audio_input = read_audio_buffer(std::filesystem::path(*audio_path));
263 }
264 engine::runtime::VoiceCondition voice;
265 bool has_voice = false;
266 if (const auto voice_id = find_arg(argc, argv, "--voice-id")) {
267 engine::runtime::VoiceReference reference;
268 reference.cached_voice_id = *voice_id;
269 voice.speaker = std::move(reference);
270 has_voice = true;
271 }
272 if (const auto voice_ref = find_arg(argc, argv, "--voice-ref")) {
273 if (!voice.speaker.has_value()) {
274 voice.speaker = engine::runtime::VoiceReference{};
275 }
276 voice.speaker->audio = read_audio_buffer(std::filesystem::path(*voice_ref));
277 has_voice = true;
278 }
279 engine::runtime::StyleCondition style;
280 if (const auto style_language = find_arg(argc, argv, "--style-language")) {
281 style.language = *style_language;
282 has_voice = true;
283 }
284 if (const auto emotion = find_arg(argc, argv, "--emotion")) {
285 style.emotion = *emotion;
286 has_voice = true;
287 }
288 if (const auto speaking_rate = parse_optional_float_arg(argc, argv, "--speaking-rate")) {
289 style.speaking_rate = *speaking_rate;

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