Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.20)

project(AudioCpp LANGUAGES C CXX)

set(AUDIOCPP_VERSION "dev" CACHE STRING "audio.cpp version string")

set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)
Expand Down Expand Up @@ -116,6 +118,43 @@ set(AUDIOCPP_GGML_SOURCE_DIR
"${CMAKE_CURRENT_SOURCE_DIR}/external/ggml"
CACHE PATH "ggml source tree to build with AudioCPP")

set(AUDIOCPP_GIT_SHA "unknown")
set(AUDIOCPP_GIT_DATE "unknown")
find_package(Git QUIET)
if (GIT_FOUND)
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
OUTPUT_VARIABLE AUDIOCPP_GIT_SHA
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET)
execute_process(
COMMAND ${GIT_EXECUTABLE} show -s --format=%cs HEAD
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
OUTPUT_VARIABLE AUDIOCPP_GIT_DATE
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET)
endif()

set(AUDIOCPP_BUILD_BACKENDS "cpu")
if (ENGINE_ENABLE_CUDA)
string(APPEND AUDIOCPP_BUILD_BACKENDS ",cuda")
endif()
if (ENGINE_ENABLE_HIP)
string(APPEND AUDIOCPP_BUILD_BACKENDS ",hip")
endif()
if (ENGINE_ENABLE_VULKAN)
string(APPEND AUDIOCPP_BUILD_BACKENDS ",vulkan")
endif()
if (ENGINE_ENABLE_METAL)
string(APPEND AUDIOCPP_BUILD_BACKENDS ",metal")
endif()
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/app/common/build_info_config.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/generated/build_info_config.h"
@ONLY
)

# HIP compiles ggml's CUDA backend sources as HIP code, so the two options drive the
# same ggml backend and cannot coexist: enabling both starts CUDA backend setup and
# HIP backend setup in the same configure, which fails in confusing ways downstream.
Expand Down Expand Up @@ -1873,6 +1912,7 @@ if (ENGINE_ENABLE_CUDA AND NOT ENGINE_ENABLE_HIP)
endif()

add_executable(audiocpp_cli
app/common/build_info.cpp
app/cli/main.cpp
app/cli/args.cpp
app/cli/batch.cpp
Expand All @@ -1886,6 +1926,7 @@ add_executable(audiocpp_cli
)

target_link_libraries(audiocpp_cli PRIVATE engine_runtime ggml)
target_include_directories(audiocpp_cli PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/generated")
# MinGW selects the wmain() entry point only when linked with -municode;
# without it the CLI fails to link (undefined reference / ld error 5).
# MSVC detects wmain natively, so this is MinGW-only. Link option only:
Expand Down Expand Up @@ -1942,6 +1983,7 @@ configure_file(
)

add_executable(audiocpp_server
app/common/build_info.cpp
app/server/main.cpp
app/server/base64.cpp
app/server/config.cpp
Expand Down
14 changes: 12 additions & 2 deletions app/cli/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "batch.h"
#include "partial_render.h"
#include "request.h"
#include "../common/build_info.h"
#include "../streaming/pcm_source.h"
#include "../streaming/streaming.h"
#include "../workflow/execution.h"
Expand Down Expand Up @@ -51,6 +52,7 @@ void print_task_list_help() {
std::cout
<< "audiocpp_cli --task <task> --family <family> --model <path> --backend <backend> [options]\n"
<< " Global:\n"
<< " --version Print build version, commit, compiler, platform, and enabled backends\n"
<< " --task vad|asr|diar|sep|gen|tts|clon|vc|s2s|align|vdes|spk|svc|midi\n"
<< " --family <name>\n"
<< " --model <path>\n"
Expand Down Expand Up @@ -637,6 +639,10 @@ int audiocpp_cli_main(int argc, char ** argv) {
log_file,
});
const bool metrics_requested = has_arg(argc, argv, "--metrics");
if (has_arg(argc, argv, "--version")) {
minitts::app::print_build_info(std::cout);
return 0;
}

const auto registry_config = find_arg(argc, argv, "--registry-config");
auto registry = engine::runtime::make_default_registry(
Expand Down Expand Up @@ -769,6 +775,10 @@ int audiocpp_cli_main(int argc, char ** argv) {
return 0;
}
if (!model_arg) {
if (argc == 1) {
minitts::app::print_build_info_summary(std::cerr);
std::cerr << "Run audiocpp_cli --help for usage.\n";
}
throw std::runtime_error("missing required --model argument");
}

Expand Down Expand Up @@ -990,7 +1000,7 @@ int wmain(int argc, wchar_t ** wargv) {
}
argv.push_back(nullptr);
const int status = audiocpp_cli_main(argc, argv.data());
if (status == 0) {
if (status == 0 && !minitts::cli::has_arg(argc, argv.data(), "--version")) {
minitts::cli::warn_ignored_args(argc, argv.data());
}
return status;
Expand All @@ -1002,7 +1012,7 @@ int wmain(int argc, wchar_t ** wargv) {
#else
int main(int argc, char ** argv) {
const int status = audiocpp_cli_main(argc, argv);
if (status == 0) {
if (status == 0 && !minitts::cli::has_arg(argc, argv, "--version")) {
minitts::cli::warn_ignored_args(argc, argv);
}
return status;
Expand Down
53 changes: 53 additions & 0 deletions app/common/build_info.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#include "build_info.h"

#include "build_info_config.h"

#include <ostream>
#include <string>

namespace minitts::app {
namespace {

std::string build_type() {
std::string value = AUDIOCPP_BUILD_TYPE_STRING;
if (value.empty()) {
value = "unknown";
}
return value;
}

std::string compiler_name() {
const std::string id = AUDIOCPP_COMPILER_ID_STRING;
const std::string version = AUDIOCPP_COMPILER_VERSION_STRING;
if (id == "GNU") {
return "gcc " + version;
}
if (id == "Clang") {
return "clang " + version;
}
if (id == "AppleClang") {
return "apple-clang " + version;
}
if (id == "MSVC") {
return "msvc " + version;
}
return id.empty() ? "unknown" : id + " " + version;
}

} // namespace

void print_build_info(std::ostream & out) {
out << "audio.cpp " << AUDIOCPP_VERSION_STRING << "\n"
<< "git: " << AUDIOCPP_GIT_SHA_STRING << " " << AUDIOCPP_GIT_DATE_STRING << "\n"
<< "build: " << build_type() << ", " << compiler_name() << ", "
<< AUDIOCPP_SYSTEM_NAME_STRING << " " << AUDIOCPP_SYSTEM_PROCESSOR_STRING << "\n"
<< "backends: " << AUDIOCPP_BUILD_BACKENDS_STRING << "\n";
}

void print_build_info_summary(std::ostream & out) {
out << "audio.cpp " << AUDIOCPP_VERSION_STRING
<< " (git " << AUDIOCPP_GIT_SHA_STRING << ", " << build_type() << ")"
<< " [backends: " << AUDIOCPP_BUILD_BACKENDS_STRING << "]\n";
}

} // namespace minitts::app
10 changes: 10 additions & 0 deletions app/common/build_info.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#pragma once

#include <iosfwd>

namespace minitts::app {

void print_build_info(std::ostream & out);
void print_build_info_summary(std::ostream & out);

} // namespace minitts::app
11 changes: 11 additions & 0 deletions app/common/build_info_config.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once

#define AUDIOCPP_VERSION_STRING "@AUDIOCPP_VERSION@"
#define AUDIOCPP_GIT_SHA_STRING "@AUDIOCPP_GIT_SHA@"
#define AUDIOCPP_GIT_DATE_STRING "@AUDIOCPP_GIT_DATE@"
#define AUDIOCPP_BUILD_TYPE_STRING "@CMAKE_BUILD_TYPE@"
#define AUDIOCPP_COMPILER_ID_STRING "@CMAKE_CXX_COMPILER_ID@"
#define AUDIOCPP_COMPILER_VERSION_STRING "@CMAKE_CXX_COMPILER_VERSION@"
#define AUDIOCPP_SYSTEM_NAME_STRING "@CMAKE_SYSTEM_NAME@"
#define AUDIOCPP_SYSTEM_PROCESSOR_STRING "@CMAKE_SYSTEM_PROCESSOR@"
#define AUDIOCPP_BUILD_BACKENDS_STRING "@AUDIOCPP_BUILD_BACKENDS@"
7 changes: 7 additions & 0 deletions app/server/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include "http.h"
#include "runtime.h"

#include "../common/build_info.h"

#include "engine/framework/core/backend.h"
#include "engine/framework/debug/trace.h"

Expand Down Expand Up @@ -66,6 +68,7 @@ void print_help() {
<< " [--model-spec-override <json-or-directory>] [--voice-dir <directory>]\n"
<< " [--log] [--log-file <path>]\n"
<< " [--cors-origins <origins>]\n"
<< " --version print build version, commit, compiler, platform, and enabled backends\n"
<< " --ui serve the embedded WebUI\n"
<< " --no-ui disable the embedded WebUI\n"
<< " --ui-management allow WebUI model management and downloads; requires\n"
Expand Down Expand Up @@ -127,6 +130,10 @@ int main(int argc, char ** argv) {
engine::core::print_backend_devices(std::cout);
return 0;
}
if (has_arg(argc, argv, "--version")) {
minitts::app::print_build_info(std::cout);
return 0;
}
if (has_arg(argc, argv, "--help") || has_arg(argc, argv, "-h")) {
print_help();
return 0;
Expand Down
Loading