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

Function generation_options_from_request

src/models/vibevoice/session.cpp:69–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67}
68
69VibeVoiceGenerationOptions generation_options_from_request(
70 const runtime::TaskRequest & request,
71 const VibeVoiceAssets & assets) {
72 VibeVoiceGenerationOptions options;
73 options.num_inference_steps = assets.config.diffusion_head.ddpm_num_inference_steps;
74 if (const auto value = runtime::parse_i64_option(request.options, {"max_tokens"})) {
75 if (*value < 0) {
76 throw std::runtime_error("VibeVoice max_tokens must be non-negative");
77 }
78 options.max_tokens = *value;
79 }
80 if (const auto value = runtime::parse_finite_float_option(request.options, {"guidance_scale"})) {
81 if (*value < 0.0F) {
82 throw std::runtime_error("VibeVoice guidance_scale must be non-negative");
83 }
84 options.guidance_scale = *value;
85 }
86 if (const auto value = runtime::parse_finite_float_option(request.options, {"max_length_times"})) {
87 if (*value <= 0.0F) {
88 throw std::runtime_error("VibeVoice max_length_times must be positive");
89 }
90 options.max_length_times = *value;
91 }
92 if (const auto value = runtime::parse_i64_option(request.options, {"num_inference_steps"})) {
93 if (*value <= 0) {
94 throw std::runtime_error("VibeVoice num_inference_steps must be positive");
95 }
96 options.num_inference_steps = *value;
97 }
98 if (const auto value = runtime::find_option(request.options, {"do_sample"})) {
99 options.do_sample = runtime::parse_bool_option(*value, "do_sample");
100 }
101 if (const auto value = runtime::parse_finite_float_option(request.options, {"temperature"})) {
102 if (*value <= 0.0F) {
103 throw std::runtime_error("VibeVoice temperature must be positive");
104 }
105 options.temperature = *value;
106 }
107 if (const auto value = runtime::parse_i64_option(request.options, {"top_k"})) {
108 if (*value < 0) {
109 throw std::runtime_error("VibeVoice top_k must be non-negative");
110 }
111 options.top_k = *value;
112 }
113 if (const auto value = runtime::parse_finite_float_option(request.options, {"top_p"})) {
114 if (*value <= 0.0F || *value > 1.0F) {
115 throw std::runtime_error("VibeVoice top_p must be in (0, 1]");
116 }
117 options.top_p = *value;
118 }
119 options.seed = runtime::parse_u32_option(request.options, {"seed"}).value_or(options.seed);
120 options.prompt_noise_file =
121 runtime::find_option(request.options, {"prompt_noise_file"})
122 .value_or("");
123 options.diffusion_noise_file =
124 runtime::find_option(request.options, {"diffusion_noise_file"})
125 .value_or("");
126 return options;

Callers 3

make_requestMethod · 0.70
runMethod · 0.50
run_streamingMethod · 0.50

Calls 5

parse_i64_optionFunction · 0.85
find_optionFunction · 0.85
parse_bool_optionFunction · 0.85
parse_u32_optionFunction · 0.85

Tested by

no test coverage detected