Skip to content

Commit b9fb16b

Browse files
committed
Started work on capture-only audio device, delegated asynchronous callbacks to the class to manage | Removed parakeetcpp since it was merged to master branch of whispercpp (see ggml-org/whisper.cpp#3735) | added cpm usage using FetchCPM.cmake to avoid the same dependency being fetched multiple times - Does cause problems with version-control, but this is the least I can do for now
1 parent 60e59e9 commit b9fb16b

9 files changed

Lines changed: 881 additions & 58 deletions

File tree

CMakeLists.txt

Lines changed: 24 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,30 @@ else()
88
set(STTSERVER_IS_TOP_LEVEL OFF)
99
endif()
1010

11+
include(cmake/FetchCPM.cmake)
1112
include(cmake/SubmoduleUpdate.cmake)
1213
include(cmake/UseCCache.cmake)
1314
include(cmake/ColouredOutput.cmake)
1415
include(cmake/OutputDir.cmake)
1516
include(cmake/WorkspaceOptions.cmake)
1617
include(cmake/BuildDiagnostics.cmake)
18+
include_cpm()
19+
1720

1821
# 1. Workspace/Project-Wide Specific Configurations
1922
enable_coloured_diagnostics_if_available()
2023
use_ccache_program_if_exists()
2124
define_aggregate_output_artifact_directory()
22-
2325
update_submodules_on_cmake_configure("dependencies")
2426

27+
2528
# 2. Workspace/Project-Wide Options
26-
OPTION(STTSERVER_FORCE_COLOURED_OUTPUT "Always produce ANSI-colored output (GNU/Clang only) (Platform Agnostic)" ON)
2729
OPTION(STTSERVER_ENABLE_SANITIZER_ADDRESS "Enable AddressSanitizer" OFF)
2830
OPTION(STTSERVER_ENABLE_SANITIZER_UNDEFINED "Enable UndefinedBehaviorSanitizer" OFF)
2931
OPTION(STTSERVER_ENABLE_SANITIZER_MEMORY "Enable MemorySanitizer" OFF)
3032
OPTION(STTSERVER_ENABLE_LINK_TIME_OPTIMIZATION "Enable Link-Time/Interprocedural Optimization (LTO/IPO)" OFF)
3133
OPTION(STTSERVER_ENABLE_TRACY_PROFILING "Enable Code-paths for the Tracy Profiler" OFF)
3234
OPTION(STTSERVER_BUILD_LIBRARY_BACKEND_WHISPER "Build the server with the master branch of https://github.com/ggml-org/whisper.cpp" OFF)
33-
OPTION(STTSERVER_BUILD_LIBRARY_BACKEND_PARAKEET "Build the server with the feature-parakeet branch" OFF)
3435
OPTION(STTSERVER_BUILD_LIBRARY_BACKEND_SHERPA_ONNX "Build the server with the sherpa-onnx" OFF)
3536
OPTION(STTSERVER_BUILD_LIBRARY "Build The actual Speech-To-Text [ASR] Server" OFF)
3637

@@ -43,88 +44,59 @@ if(STTSERVER_ENABLE_SANITIZER_ADDRESS AND STTSERVER_ENABLE_SANITIZER_MEMORY)
4344
message(FATAL_ERROR "ASan and MSan are mutually exclusive. Please choose only one\n")
4445
endif()
4546

46-
if(NOT STTSERVER_BUILD_LIBRARY_BACKEND_WHISPER
47-
AND
48-
NOT STTSERVER_BUILD_LIBRARY_BACKEND_PARAKEET
49-
AND
50-
NOT STTSERVER_BUILD_LIBRARY_BACKEND_SHERPA_ONNX
51-
)
47+
if(NOT STTSERVER_BUILD_LIBRARY_BACKEND_WHISPER AND NOT STTSERVER_BUILD_LIBRARY_BACKEND_SHERPA_ONNX)
5248
message(FATAL_ERROR "Must Select Atleast 1 Backend to build the project with")
5349
endif()
5450

51+
5552
# 3. Declare interface libraries - Sanitizer Interface Library depends on these
5653
declare_optional_interface_library_different_sanitizers()
5754
declare_optional_interface_library_lto()
5855
declare_optional_interface_default_project_configuration()
56+
enable_coloured_diagnostics_if_available()
5957

60-
# 4. Process Actions related to the options above.
61-
# 4. Process Actions related to the options above.
62-
if(STTSERVER_FORCE_COLOURED_OUTPUT)
63-
set(CMAKE_COLOR_DIAGNOSTICS ON)
64-
enable_coloured_diagnostics_if_available()
65-
endif()
66-
67-
if(STTSERVER_ENABLE_SANITIZER_ADDRESS)
68-
add_link_options(STTSERVER_WORKSPACE_CONFIG::AddressSanitizerInterface)
69-
endif()
70-
71-
if(STTSERVER_ENABLE_SANITIZER_UNDEFINED)
72-
add_link_options(STTSERVER_WORKSPACE_CONFIG::UBSanInterface)
73-
endif()
74-
75-
if(STTSERVER_ENABLE_SANITIZER_MEMORY)
76-
add_link_options(STTSERVER_WORKSPACE_CONFIG::MemorySanitizerInterface)
77-
endif()
78-
79-
if(STTSERVER_ENABLE_LINK_TIME_OPTIMIZATION)
80-
add_link_options(STTSERVER_WORKSPACE_CONFIG::LTO)
81-
endif()
8258

8359
# 5. Print Enabled/Disabled Flags For Verbose Diagnostics
84-
if(STTSERVER_BUILD_LIBRARY_BACKEND_WHISPER OR STTSERVER_BUILD_LIBRARY_BACKEND_PARAKEET)
60+
if(STTSERVER_BUILD_LIBRARY_BACKEND_WHISPER)
8561
setup_whisper_backend_defaults()
8662
endif()
63+
8764
if(STTSERVER_BUILD_LIBRARY_BACKEND_SHERPA_ONNX)
8865
setup_sherpa_onnx_backend_defaults()
8966
endif()
67+
9068
print_all_workspace_flags_and_vars()
9169

9270
# 6. Actual Start
9371
if(STTSERVER_ENABLE_TRACY_PROFILING)
94-
message(STATUS "[STTSERVER_ENABLE_TRACY_PROFILING] Building with Tracy for Profiling!")
95-
set(TRACY_ENABLE ON)
96-
set(TRACY_VERBOSE ON)
97-
add_subdirectory(dependencies/tracy)
72+
safe_cpm_add_package(NAME tracy SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/tracy")
9873
endif()
99-
10074
if(STTSERVER_BUILD_LIBRARY_BACKEND_WHISPER)
101-
message(STATUS "[STTSERVER_BUILD_LIBRARY_BACKEND_WHISPER] Building with backend whisper.cpp (master branch)")
102-
add_subdirectory(dependencies/whispercpp)
75+
safe_cpm_add_package(NAME whispercpp SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/whispercpp")
10376
endif()
104-
10577
if(STTSERVER_BUILD_LIBRARY_BACKEND_PARAKEET)
106-
message(STATUS "[STTSERVER_BUILD_LIBRARY_BACKEND_PARAKEET] Building with backend whisper.cpp (parakeet feature-branch [dan-bev])")
107-
add_subdirectory(dependencies/parakeetcpp)
78+
safe_cpm_add_package(NAME parakeetcpp SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/parakeetcpp")
10879
endif()
109-
11080
if(STTSERVER_BUILD_LIBRARY_BACKEND_SHERPA_ONNX)
111-
message(STATUS "[STTSERVER_BUILD_LIBRARY_BACKEND_SHERPA_ONNX] Building with backend sherpa-onnx")
112-
add_subdirectory(dependencies/sherpa-onnx)
81+
safe_cpm_add_package(NAME sherpa-onnx SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/sherpa-onnx")
11382
endif()
11483

115-
add_subdirectory(dependencies/cxxopts)
116-
add_subdirectory(dependencies/miniaudio)
117-
add_subdirectory(dependencies/util2)
84+
safe_cpm_add_package(NAME cxxopts SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/cxxopts")
85+
safe_cpm_add_package(NAME miniaudio SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/miniaudio")
86+
safe_cpm_add_package(NAME util2 SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/util2")
87+
11888

119-
if(STTSERVER_BUILD_LIBRARY)
89+
if(STTSERVER_BUILD_LIBRARY AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/sttserv")
12090
add_subdirectory(sttserv)
12191
endif()
12292

12393
if(STTSERVER_BUILD_TESTS)
124-
add_subdirectory(dependencies/googletest)
125-
add_subdirectory(test)
94+
safe_cpm_add_package(NAME googletest SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/googletest")
95+
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test")
96+
add_subdirectory(test)
97+
endif()
12698
endif()
12799

128-
if(STTSERVER_BUILD_BENCHMARKS)
100+
if(STTSERVER_BUILD_BENCHMARKS AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/benchmark")
129101
add_subdirectory(benchmark)
130102
endif()

benchmark/CMakeLists.txt

Whitespace-only changes.

build.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ PROJECT_NAME="all"
1717
# For More options see BuildDiagnostics.cmake
1818
CMAKE_ARGLIST="\
1919
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
20-
-DSTTSERVER_BUILD_LIBRARY_BACKEND_PARAKEET=ON \
20+
-DSTTSERVER_BUILD_LIBRARY_BACKEND_WHISPER=ON \
2121
-DSTTSERVER_BUILD_LIBRARY_BACKEND_SHERPA_ONNX=ON \
2222
-DSTTSERVER_BUILD_LIBRARY=ON \
23-
-DSTTSERVER_BUILD_TESTS=ON \
23+
-DSTTSERVER_BUILD_TESTS=ON
24+
STTSERVER_BUILD_BENCHMARKS=OFF \
2425
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
2526
"
2627

cmake/FetchCPM.cmake

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
cmake_minimum_required(VERSION 3.16)
2+
3+
4+
macro(include_cpm)
5+
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM.cmake")
6+
if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
7+
message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}")
8+
file(DOWNLOAD https://github.com/cpm-cmake/CPM.cmake/releases/latest/download/get_cpm.cmake ${CPM_DOWNLOAD_LOCATION})
9+
endif()
10+
include(${CPM_DOWNLOAD_LOCATION})
11+
endmacro()
12+
13+
14+
macro(safe_cpm_add_package)
15+
set(options)
16+
set(oneValueArgs NAME)
17+
set(multiValueArgs)
18+
# Parse the arguments to extract the NAME parameter
19+
cmake_parse_arguments(SAFE_CPM "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
20+
21+
if(NOT SAFE_CPM_NAME)
22+
message(FATAL_ERROR "[SafeCPM] NAME argument is required.")
23+
endif()
24+
25+
# Check both standard target and namespace alias
26+
if(NOT TARGET ${SAFE_CPM_NAME} AND NOT TARGET ${SAFE_CPM_NAME}::${SAFE_CPM_NAME})
27+
CPMAddPackage(${ARGN})
28+
else()
29+
message(WARNING "[SafeCPM] Target '${SAFE_CPM_NAME}' already exists. Skipping fetch.")
30+
endif()
31+
endmacro()

dependencies/whispercpp

Submodule whispercpp updated 655 files

sttserv/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ target_compile_features(${PROJECT_NAME} PRIVATE
6565
cxx_std_17
6666
)
6767
target_link_libraries(${PROJECT_NAME} PUBLIC
68-
WORKSPACE_CONFIG::ProjectDefaultConfig
68+
STTSERVER_WORKSPACE_CONFIG::ProjectDefaultConfig
6969
${RUNTIME_BACKEND_LIBRARY_NAME}
7070
miniaudio
7171
UTIL2::util2

0 commit comments

Comments
 (0)