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

Method handle_transcription_multipart

app/server/runtime.cpp:640–675  ·  view source on GitHub ↗

Accepts the same multipart/form-data shape OpenAI's Whisper API (and clients built against it, e.g. Open WebUI) send: a "file" part with the audio bytes, plus "model" and optional "language" fields. audio.cpp's native JSON request only takes a server-local path, so the uploaded bytes are spooled to a temp file and routed through the existing JSON request builder.

Source from the content-addressed store, hash-verified

638 (void) it;
639 }
640 if (model.config.default_voice_preset_id.has_value()) {
641 const auto it = model.voice_presets.find(*model.config.default_voice_preset_id);
642 if (it == model.voice_presets.end()) {
643 throw std::runtime_error(
644 "default_voice_preset for model " + model.config.id +
645 " was not loaded: " +
646 *model.config.default_voice_preset_id);
647 }
648 model.default_voice_preset = it->second;
649 } else if (model.config.default_voice_preset.has_value()) {
650 model.default_voice_preset = load_runtime_voice_preset(*model.config.default_voice_preset);
651 }
652}
653
654void ServerState::ensure_model_loaded_locked(LoadedModel & model) {
655 if (model.session != nullptr) {
656 return;
657 }
658 auto registry = engine::runtime::make_default_registry();
659
660 engine::runtime::ModelLoadRequest load_request;
661 load_request.model_path = model.config.path;
662 load_request.model_spec_override = model.config.model_spec_override.has_value()
663 ? model.config.model_spec_override
664 : config_.model_spec_override;
665 load_request.family_hint = model.config.family;
666 load_request.config_id = model.config.config_id;
667 load_request.weight_id = model.config.weight_id;
668 load_request.options = model.config.load_options;
669
670 engine::runtime::SessionOptions session_options;
671 session_options.backend.type = config_.backend;
672 session_options.backend.device = config_.device;
673 session_options.backend.threads = config_.threads;
674 session_options.options = model.config.session_options;
675
676 auto loaded_model = registry.load(load_request);
677 auto session = loaded_model->create_task_session(model.task, session_options);
678 auto * offline = dynamic_cast<engine::runtime::IOfflineVoiceTaskSession *>(session.get());

Callers

nothing calls this directly

Calls 4

parse_multipart_bodyFunction · 0.85
write_temp_uploadFunction · 0.85
emptyMethod · 0.45

Tested by

no test coverage detected