MCPcopy Create free account
hub / github.com/Arm-Examples/ML-examples / main

Function main

kleidiai-examples/audiogen/app/audiogen.cpp:429–696  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

427}
428
429int main(int32_t argc, char** argv) {
430
431 // ----- Parse the cmd line arguments
432 // ----------------------------------
433 // Required arguments
434 std::string models_base_path = "";
435 std::string prompt = "";
436 std::string audio_input_path = "";
437 size_t num_threads = 0;
438 // Optional arguments
439 std::string output_file = "";
440 size_t seed = k_seed_default;
441 size_t num_steps = k_num_steps_default;
442 float audio_len_sec = static_cast<float>(k_audio_len_sec_default);
443 float sigma_max = static_cast<float>(k_sigma_max);
444
445 int opt;
446 while ((opt = getopt(argc, argv, "m:p:t:i:x:s:n:o:l:h")) != -1) {
447 switch (opt) {
448 case 'm': models_base_path = optarg; break;
449 case 'p': prompt = optarg; break;
450 case 't': num_threads = std::stoull(optarg); break;
451 case 'i': audio_input_path = optarg; break;
452 case 'x': sigma_max = static_cast<float>(std::stof(optarg)); break;
453 case 's': seed = std::stoull(optarg); break;
454 case 'n': num_steps = std::stoull(optarg); break;
455 case 'o': output_file = optarg; break;
456 case 'l': audio_len_sec = static_cast<float>(std::stoull(optarg)); break;
457 case 'h':
458 default:
459 print_usage(argv[0]);
460 return EXIT_FAILURE;
461 }
462 }
463
464 // Check the mandatory arguments
465 if (models_base_path.empty() || prompt.empty() || num_threads <= 0) {
466 fprintf(stderr, "ERROR: Missing required arguments.\n\n");
467 print_usage(argv[0]);
468 return EXIT_FAILURE;
469 }
470
471 if(sigma_max <= 0 || sigma_max > 1) {
472 fprintf(stderr, "noise_level (sigma_max) must be between (0,1] \n");
473 return EXIT_FAILURE;
474 }
475
476 std::string t5_tflite = models_base_path + "/conditioners_float32.tflite";
477 std::string dit_tflite = models_base_path + "/dit_model.tflite";
478 std::string autoencoder_tflite = models_base_path + "/autoencoder_model.tflite";
479 std::string autoencoder_encoder_tflite = models_base_path + "/autoencoder_encoder_model.tflite";
480 std::string sentence_model_path = models_base_path + "/spiece.model";
481
482 auto env = get_litert_value(litert::Environment::Create({}));
483
484 // If there is input audio, run the encoder model and release it, to avoid overloading memory
485 std::vector<float> encoded_audio;
486 if(!audio_input_path.empty()) {

Callers

nothing calls this directly

Calls 13

get_litert_valueFunction · 0.85
encode_audioFunction · 0.85
create_cpu_optionsFunction · 0.85
convert_prompt_to_idsFunction · 0.85
print_usageFunction · 0.70
get_num_elemsFunction · 0.70
fill_random_norm_distFunction · 0.70
fill_sigmasFunction · 0.70
time_in_msFunction · 0.70
sampler_ping_pongFunction · 0.70
get_filenameFunction · 0.70
save_as_wavFunction · 0.70

Tested by

no test coverage detected