Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.
JavaScript aianthropiccross-platformgeminigroqlinuxmacosnvidiaopen-sourceopenaiparakeetspeech-to-texttranscribewhisperwindows
fix(meeting-aec): cross-platform build for linux, windows, and macOS x64
Gabriel Stein8de0662b7d36
diff --git a/native/meeting-aec-helper/CMakeLists.txt b/native/meeting-aec-helper/CMakeLists.txtindex fa10c75ad..8de495e95 100644--- a/native/meeting-aec-helper/CMakeLists.txt+++ b/native/meeting-aec-helper/CMakeLists.txt@@ -3,7 +3,6 @@ project(meeting_aec_helper LANGUAGES C CXX)set(CMAKE_C_STANDARD 11)set(CMAKE_C_STANDARD_REQUIRED ON)-set(CMAKE_C_EXTENSIONS OFF)set(CMAKE_CXX_STANDARD 20)set(CMAKE_CXX_STANDARD_REQUIRED ON)set(CMAKE_CXX_EXTENSIONS OFF)@@ -21,6 +20,7 @@ add_executable(src/null_aec_dump_factory.cc${MEETING_AEC_WEBRTC_SOURCES}${MEETING_AEC_ABSL_SOURCES}+ ${MEETING_AEC_AVX2_SOURCES})target_include_directories(@@ -33,3 +33,10 @@ target_include_directories(target_compile_definitions(meeting-aec-helper PRIVATE ${MEETING_AEC_DEFINES})target_compile_options(meeting-aec-helper PRIVATE ${MEETING_AEC_COMPILE_OPTIONS})target_link_options(meeting-aec-helper PRIVATE ${MEETING_AEC_LINK_OPTIONS})++if(MEETING_AEC_AVX2_SOURCES AND MEETING_AEC_AVX2_COMPILE_OPTIONS)+ set_source_files_properties(+ ${MEETING_AEC_AVX2_SOURCES}+ PROPERTIES COMPILE_OPTIONS "${MEETING_AEC_AVX2_COMPILE_OPTIONS}"+ )+endif()diff --git a/native/meeting-aec-helper/compat/rtc_base/win32.h b/native/meeting-aec-helper/compat/rtc_base/win32.hnew file mode 100644index 000000000..b223aeac4--- /dev/null+++ b/native/meeting-aec-helper/compat/rtc_base/win32.h@@ -0,0 +1,6 @@+// Stub: webrtc-apm omits rtc_base/win32.h but time_utils.cc includes it under+// WEBRTC_WIN. The symbols actually referenced (FILETIME, etc.) come from+// <minwinbase.h>, which is included separately.+#ifndef OPENWHISPR_COMPAT_RTC_BASE_WIN32_H_+#define OPENWHISPR_COMPAT_RTC_BASE_WIN32_H_+#endifdiff --git a/scripts/build-meeting-aec-helper.js b/scripts/build-meeting-aec-helper.jsindex 81ca6cb6a..43d5e9d00 100644--- a/scripts/build-meeting-aec-helper.js+++ b/scripts/build-meeting-aec-helper.js@@ -144,6 +144,7 @@ function buildDirect(manifest) {const includeArgs = manifest.includeDirs.flatMap((dir) => ["-I", dir]);const defineArgs = manifest.defines.map((define) => `-D${define}`);const commonArgs = [...manifest.compileOptions, ...includeArgs, ...defineArgs];+ const avx2Set = new Set(manifest.avx2Sources);const objectFiles = [];const localSources = [path.join(sourceDir, "main.cc"),@@ -156,9 +157,11 @@ function buildDirect(manifest) {const outputObject = path.join(objectDir, getSourceObjectName(source));const compiler = source.endsWith(".c") ? toolchain.cc : toolchain.cxx;const languageArgs = source.endsWith(".c") ? ["-std=c11"] : ["-std=c++20"];+ const perSourceArgs = avx2Set.has(source) ? manifest.avx2CompileOptions : [];const result = run(compiler, [...languageArgs,...commonArgs,+ ...perSourceArgs,"-c",source,"-o",diff --git a/scripts/lib/meeting-aec-build.js b/scripts/lib/meeting-aec-build.jsindex 305d51ca1..125c95cdc 100644--- a/scripts/lib/meeting-aec-build.js+++ b/scripts/lib/meeting-aec-build.js@@ -165,6 +165,7 @@ TARGET_ARCH = ${JSON.stringify(normalizeArch(targetArch))}want_arm64 = TARGET_ARCH == "arm64"want_arm32 = TARGET_ARCH.startswith("arm") and not want_arm64want_neon = want_arm64 or want_arm32+want_x86_64 = TARGET_ARCH == "x64"targets = {}loaded_packages = set()@@ -178,6 +179,8 @@ def select(options):return valueif (key == "//:neon_build" or key == ":neon_build") and want_neon:return value+ if key == "@platforms//cpu:x86_64" and want_x86_64:+ return valuereturn options.get("//conditions:default", [])def cc_library(**kwargs):@@ -262,6 +265,7 @@ def get_target(label):visited = set()collected = set()+avx2 = set()def walk(label, package_path=""):normalized = normalize_label(label, package_path)@@ -282,9 +286,11 @@ def walk(label, package_path=""):relative_path = str(Path(target_package_path) / source).replace("\\\\", "/")if relative_path in SKIPPED:continue+ resolved = str((ROOT / relative_path).resolve())if "avx2" in Path(relative_path).name:- continue- collected.add(str((ROOT / relative_path).resolve()))+ avx2.add(resolved)+ else:+ collected.add(resolved)for dependency in target.get("deps", []):if isinstance(dependency, str):walk(dependency, target_package_path)@@ -292,7 +298,7 @@ def walk(label, package_path=""):for root_label in ROOT_LABELS:walk(root_label)-print(json.dumps(sorted(collected)))+print(json.dumps({"regular": sorted(collected), "avx2": sorted(avx2)}))`;const output = execFileSync("python3", ["-c", pythonScript], {@@ -317,7 +323,7 @@ function getPlatformDefines(targetPlatform, targetArch) {if (targetPlatform === "darwin") {defines.push("WEBRTC_MAC=1");} else if (targetPlatform === "linux") {- defines.push("WEBRTC_LINUX=1");+ defines.push("WEBRTC_LINUX=1", "_GNU_SOURCE");}}@@ -348,9 +354,17 @@ function getLinkOptions(targetPlatform) {return ["-pthread", "-lm"];}+ if (targetPlatform === "darwin") {+ return ["-framework", "CoreFoundation"];+ }+return [];}+function getAvx2CompileOptions(targetPlatform) {+ return targetPlatform === "win32" ? ["/arch:AVX2"] : ["-mavx2", "-mfma"];+}+function quoteCmake(value) {return `"${String(value).replace(/\\/g, "/")@@ -369,37 +383,46 @@ function writeCmakeManifest(manifest, outputPath) {writeList("MEETING_AEC_WEBRTC_SOURCES", manifest.webrtcSources);writeList("MEETING_AEC_ABSL_SOURCES", manifest.abslSources);+ writeList("MEETING_AEC_AVX2_SOURCES", manifest.avx2Sources);writeList("MEETING_AEC_INCLUDE_DIRS", manifest.includeDirs);writeList("MEETING_AEC_DEFINES", manifest.defines);writeList("MEETING_AEC_COMPILE_OPTIONS", manifest.compileOptions);+ writeList("MEETING_AEC_AVX2_COMPILE_OPTIONS", manifest.avx2CompileOptions);writeList("MEETING_AEC_LINK_OPTIONS", manifest.linkOptions);fs.writeFileSync(outputPath, `${lines.join("\n")}\n`);}function buildManifest({ helperRoot, webrtcApmRoot, abslRoot, targetPlatform, targetArch }) {+ const { regular, avx2 } = buildWebrtcSourceList(webrtcApmRoot, targetArch);const webrtcSources = [...new Set([- ...buildWebrtcSourceList(webrtcApmRoot, targetArch),+ ...regular,...EXTRA_WEBRTC_SOURCES.map((source) => path.join(webrtcApmRoot, source)),]),];+ const avx2Sources = [...avx2];const abslSources = ABSL_SOURCES.map((source) => path.join(abslRoot, source));const defines = getPlatformDefines(targetPlatform, targetArch);- const compileOptions = ["-O2", ...getArchOptions(targetPlatform, targetArch)];+ const baseCompileOptions = targetPlatform === "win32" ? [] : ["-O2"];+ const compileOptions = [...baseCompileOptions, ...getArchOptions(targetPlatform, targetArch)];+ const avx2CompileOptions = avx2Sources.length ? getAvx2CompileOptions(targetPlatform) : [];const linkOptions = getLinkOptions(targetPlatform);+ const allRegularSources = [...webrtcSources, ...abslSources];return {helperRoot,webrtcSources,abslSources,- includeDirs: [helperRoot, webrtcApmRoot, abslRoot],+ avx2Sources,+ includeDirs: [helperRoot, path.join(helperRoot, "compat"), webrtcApmRoot, abslRoot],defines,compileOptions,+ avx2CompileOptions,linkOptions,- cSources: [...webrtcSources, ...abslSources].filter((source) => source.endsWith(".c")),- cxxSources: [...webrtcSources, ...abslSources].filter((source) => source.endsWith(".cc")),- allSources: [...webrtcSources, ...abslSources],+ cSources: allRegularSources.filter((source) => source.endsWith(".c")),+ cxxSources: [...allRegularSources, ...avx2Sources].filter((source) => source.endsWith(".cc")),+ allSources: [...allRegularSources, ...avx2Sources],};}