Skip to content

Commit

Permalink
Merge pull request #1 from locaal-ai/roy.timed_metadata
Browse files Browse the repository at this point in the history
Add timed metadata support and update dependencies in CMake configura…
  • Loading branch information
royshil authored Dec 5, 2024
2 parents ed19137 + ce98fcd commit 4c8ef32
Show file tree
Hide file tree
Showing 21 changed files with 489 additions and 91 deletions.
21 changes: 12 additions & 9 deletions .github/actions/build-plugin/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,9 @@ runs:
python-version: '3.10'

- name: Install Conan 🪓
if: runner.os == 'Linux' || runner.os == 'macOS'
id: conan
uses: turtlebrowser/get-conan@main

- name: Conan version
if: runner.os == 'Linux' || runner.os == 'macOS'
shell: bash
run: echo "${{ steps.conan.outputs.version }}"

- name: Install Dependencies 🛍️
if: runner.os == 'Linux'
shell: bash
Expand All @@ -50,16 +44,25 @@ runs:
brew install --quiet zsh
echo ::endgroup::
- name: Build gRPC 🛠️
- name: Build Dependencies 🛠️
if: runner.os == 'Linux' || runner.os == 'macOS'
shell: bash
run: |
: Build gRPC 🛠️
echo ::group::Build gRPC
: Build Dependencies 🛠️
echo ::group::Build Dependencies
conan profile detect --force
conan install ${{github.workspace}} --output-folder=${{github.workspace}}/build_conan --build=missing -g CMakeDeps
echo ::endgroup::
- name: Build Windows Dependencies 🛠️
if: runner.os == 'Windows'
shell: pwsh
run: |
Write-Host "::group::Build Windows Dependencies"
conan profile detect --force
conan install ${{github.workspace}}/conanfile_win.txt --output-folder=${{github.workspace}}/build_conan --build=missing -g CMakeDeps
Write-Host "::endgroup::"
- name: Run macOS Build
if: runner.os == 'macOS'
shell: zsh --no-rcs --errexit --pipefail {0}
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,16 @@ jobs:
- name: Create Release 🛫
if: fromJSON(steps.check.outputs.validTag)
id: create_release
uses: softprops/action-gh-release@9d7c94cfd0a1f3ed45544c887983e9fa900f0564
uses: softprops/action-gh-release@v2
with:
draft: true
prerelease: ${{ fromJSON(steps.check.outputs.prerelease) }}
tag_name: ${{ steps.check.outputs.version }}
name: ${{ needs.build-project.outputs.pluginName }} ${{ steps.check.outputs.version }}
name: CloudVocal ${{ steps.check.outputs.version }}
body_path: ${{ github.workspace }}/CHECKSUMS.txt
generate_release_notes: true
append_body: true
fail_on_unmatched_files: false
files: |
${{ github.workspace }}/*.exe
${{ github.workspace }}/*.zip
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
!LICENSE
!README.md
!conanfile.txt
!conanfile_win.txt

# Exclude lock files
*.lock.json
Expand Down
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ if(ENABLE_QT)
AUTORCC ON)
endif()

include(cmake/BuildGRPCpp.cmake)
include(cmake/BuildDependencies.cmake)
include(cmake/BuildClovaAPIs.cmake)
include(cmake/BuildGoogleAPIs.cmake)
include(cmake/FetchNlohmannJSON.cmake)
Expand Down Expand Up @@ -64,7 +64,8 @@ target_sources(
src/language-codes/language-codes.cpp
src/cloud-providers/cloud-provider.cpp
src/cloud-providers/clova/clova-provider.cpp
src/cloud-providers/google/google-provider.cpp)
src/cloud-providers/google/google-provider.cpp
src/timed-metadata/timed-metadata-utils.cpp)

add_subdirectory(src/cloud-translation)

Expand Down
27 changes: 18 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
[![Discord](https://img.shields.io/discord/1200229425141252116)](https://discord.gg/KbjGU2vvUz)
<br/>
Download:</br>
<a href="https://github.com/locaal-ai/cloudvocal/releases/latest/download/cloudvocal-windows-x64-Installer.exe"><img src="https://img.shields.io/badge/Windows-0078D6?style=for-the-badge&logo=windows&logoColor=white" /></a>
<a href="https://github.com/locaal-ai/cloudvocal/releases/latest/download/cloudvocal-macos-x86_64.pkg"><img src="https://img.shields.io/badge/mac-000000?style=for-the-badge" /></a>
<a href="https://github.com/locaal-ai/cloudvocal/releases/latest/download/cloudvocal-x86_64-linux-gnu.deb"><img src="https://img.shields.io/badge/Linux-FCC624?style=for-the-badge&logo=linux&logoColor=black"/></a>
<a href="https://github.com/locaal-ai/cloudvocal/releases/latest/download/cloudvocal-0.0.1-windows-x64-Installer.exe"><img src="https://img.shields.io/badge/Windows-0078D6?style=for-the-badge&logo=windows&logoColor=white" /></a>
<a href="https://github.com/locaal-ai/cloudvocal/releases/latest/download/cloudvocal-0.0.1-macos-universal.pkg"><img src="https://img.shields.io/badge/mac-000000?style=for-the-badge" /></a>
<a href="https://github.com/locaal-ai/cloudvocal/releases/latest/download/cloudvocal-0.0.1-x86_64-linux-gnu.deb"><img src="https://img.shields.io/badge/Linux-FCC624?style=for-the-badge&logo=linux&logoColor=black"/></a>
</div>

## Introduction
Expand All @@ -31,15 +31,15 @@ Current Features:
- Support for 100+ languages with dialect recognition
- Streaming-optimized performance with minimal latency
- Multiple cloud provider options for transcription and translation
- Caption output in multiple formats (.txt, .srt, .vtt)
- Caption output in multiple formats (.txt, .srt)
- Sync'ed captions with OBS recording timestamps
- Direct streaming to platforms (YouTube, Twitch) with embedded captions
- Advanced text filtering and customization options
- Partial transcriptions for a streaming-captions experience
- Custom vocabulary and pronunciation support
- Professional terminology handling for specific industries

Roadmap:
- Custom vocabulary and pronunciation support
- Professional terminology handling for specific industries
- Advanced text filtering and customization options
- Speaker diarization for multi-speaker environments
- Advanced profanity filtering options
- Custom translation glossaries
Expand Down Expand Up @@ -86,8 +86,17 @@ $ ./.github/scripts/build-linux

### Windows

Windows also needs Conan for OpenSSL. Run `conan` to get the dependency (make sure to run `conan` on the `conanfile_win.txt`):
```powershell
> pip install conan
> conan profile detect --force
> conan install .\conanfile_win.txt --output-folder=./build_conan --build=missing -g CMakeDeps
```

Build the plugin:

```powershell
> .github/scripts/Build-Windows.ps1 -Configuration Release
> .\.github\scripts\Build-Windows.ps1 -Configuration Release
```

If you're developing the plugin, I find this command to be useful for direct deploymet into OBS after building:
Expand All @@ -96,7 +105,7 @@ If you're developing the plugin, I find this command to be useful for direct dep
> .\.github\scripts\Build-Windows.ps1 -Configuration RelWithDebInfo -SkipDeps && Copy-Item -Force -Recurse .\release\RelWithDebInfo\* "C:\Program Files\obs-studio\"
```

### Other Plugins
### Other Plugins

Check out our other plugins:
- [LocalVocal](https://github.com/locaal-ai/obs-localvocal) for on-device real-time transcription and translation
Expand Down
9 changes: 4 additions & 5 deletions cmake/BuildClovaAPIs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ add_library(clova-apis ${CLOVA_SOURCE_DIR}/nest.pb.cc ${CLOVA_SOURCE_DIR}/nest.g

# disable conversion warnings from the generated files
if(MSVC)
target_compile_options(clova-apis PRIVATE /wd4244 /wd4267)
target_compile_options(clova-apis PRIVATE /wd4244 /wd4267 /wd4099)
else()
target_compile_options(
clova-apis
Expand All @@ -31,12 +31,11 @@ else()
endif()

# Add include directories
target_include_directories(clova-apis PUBLIC ${CLOVA_OUTPUT_DIR} ${GRPC_INCLUDE_DIR} ${PROTOBUF_INCLUDE_DIR}
${absl_INCLUDE_DIRS})
target_include_directories(clova-apis PUBLIC ${CLOVA_OUTPUT_DIR} ${DEPS_INCLUDE_DIRS})

# link the grpc libraries
target_link_libraries(clova-apis PRIVATE ${GRPC_LIBRARIES})
target_link_directories(clova-apis PRIVATE ${GRPC_LIB_DIR})
target_link_libraries(clova-apis PRIVATE ${DEPS_LIBRARIES})
target_link_directories(clova-apis PRIVATE ${DEPS_LIB_DIRS})

# link the library to the main project
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE clova-apis)
56 changes: 27 additions & 29 deletions cmake/BuildGRPCpp.cmake → cmake/BuildDependencies.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
cmake_minimum_required(VERSION 3.14)

set(GRPC_VERSION v1.68.0)
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_SOURCE_DIR}/build_conan)

if(WIN32)
set(GRPC_VERSION v1.68.0)

# get the prebuilt version from https://github.com/thommyho/Cpp-gRPC-Windows-PreBuilts/releases/
include(FetchContent)

Expand All @@ -11,26 +13,22 @@ if(WIN32)
FetchContent_Declare(grpc URL ${grpc_url} DOWNLOAD_EXTRACT_TIMESTAMP 1)
FetchContent_MakeAvailable(grpc)

find_package(OpenSSL CONFIG REQUIRED)

# Specify include directories and link libraries for your project
set(GRPC_INCLUDE_DIR ${grpc_SOURCE_DIR}/${CMAKE_BUILD_TYPE}/include)
set(PROTOBUF_INCLUDE_DIR ${grpc_SOURCE_DIR}/${CMAKE_BUILD_TYPE}/include)
set(GRPC_LIB_DIR ${grpc_SOURCE_DIR}/${CMAKE_BUILD_TYPE}/lib)
list(APPEND DEPS_INCLUDE_DIRS ${grpc_SOURCE_DIR}/${CMAKE_BUILD_TYPE}/include ${openssl_INCLUDE_DIRS_RELEASE})
set(DEPS_LIB_DIRS ${grpc_SOURCE_DIR}/${CMAKE_BUILD_TYPE}/lib)
set(PROTOC_EXECUTABLE ${grpc_SOURCE_DIR}/${CMAKE_BUILD_TYPE}/bin/protoc.exe)
set(GRPC_PLUGIN_EXECUTABLE ${grpc_SOURCE_DIR}/${CMAKE_BUILD_TYPE}/bin/grpc_cpp_plugin.exe)

# get all .lib files in the lib directory
file(GLOB GRPC_LIBRARIES ${GRPC_LIB_DIR}/*.lib)
set(GRPC_LIBRARIES
${GRPC_LIBRARIES}
CACHE STRING "gRPC libraries")
file(GLOB DEPS_LIBRARIES ${DEPS_LIB_DIRS}/*.lib)
else()
# get grpc from conan
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_SOURCE_DIR}/build_conan)
find_package(gRPC CONFIG REQUIRED)
find_package(protobuf CONFIG REQUIRED)
find_package(absl CONFIG REQUIRED)
find_package(ZLIB REQUIRED)
find_package(OpenSSL REQUIRED)
find_package(OpenSSL CONFIG REQUIRED)
find_package(c-ares CONFIG REQUIRED)
find_package(re2 CONFIG REQUIRED)

Expand All @@ -42,35 +40,38 @@ else()
CACHE STRING "gRPC plugin executable")
list(
APPEND
GRPC_LIBRARIES
DEPS_LIBRARIES
${grpc_LIBS_RELEASE}
${abseil_LIBS_RELEASE}
${protobuf_LIBS_RELEASE}
${ZLIB_LIBRARIES}
${OPENSSL_LIBRARIES}
${openssl_LIBS_RELEASE}
${c-ares_LIBS_RELEASE}
${re2_LIBS_RELEASE})
list(
APPEND
GRPC_LIB_DIR
DEPS_LIB_DIRS
${grpc_LIB_DIRS_RELEASE}
${abseil_LIB_DIRS_RELEASE}
${protobuf_LIB_DIRS_RELEASE}
${zlib_LIB_DIRS_RELEASE}
${openssl_LIB_DIRS_RELEASE}
${c-ares_LIB_DIRS_RELEASE}
${re2_LIB_DIRS_RELEASE})
set(GRPC_INCLUDE_DIR
${gRPC_INCLUDE_DIRS}
CACHE STRING "gRPC include directory")
set(PROTOBUF_INCLUDE_DIR
${protobuf_INCLUDE_DIRS}
CACHE STRING "Protobuf include directory")
list(
APPEND
DEPS_INCLUDE_DIRS
${gRPC_INCLUDE_DIRS}
${absl_INCLUDE_DIRS}
${protobuf_INCLUDE_DIRS_RELEASE}
${ZLIB_INCLUDE_DIRS}
${openssl_INCLUDE_DIRS_RELEASE}
${c-ares_INCLUDE_DIRS}
${re2_INCLUDE_DIRS})
endif()

message(STATUS "gRPC include directory: ${GRPC_INCLUDE_DIR}")
message(STATUS "protobuf include directory: ${PROTOBUF_INCLUDE_DIR}")
message(STATUS "gRPC library directory: ${GRPC_LIB_DIR}")
message(STATUS "Dependencies include directories: ${DEPS_INCLUDE_DIRS}")
message(STATUS "Dependencies library directories: ${DEPS_LIB_DIRS}")
message(STATUS "protoc executable: ${PROTOC_EXECUTABLE}")
message(STATUS "grpc_cpp_plugin executable: ${GRPC_PLUGIN_EXECUTABLE}")

Expand All @@ -79,11 +80,8 @@ if(NOT PROTOC_EXECUTABLE OR NOT GRPC_PLUGIN_EXECUTABLE)
endif()

# Add include directories
target_include_directories(
${CMAKE_PROJECT_NAME}
PRIVATE ${GRPC_INCLUDE_DIR}
PRIVATE ${PROTOBUF_INCLUDE_DIR})
target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE ${DEPS_INCLUDE_DIRS})

# Link libraries
target_link_directories(${CMAKE_PROJECT_NAME} PRIVATE ${GRPC_LIB_DIR})
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE ${GRPC_LIBRARIES})
target_link_directories(${CMAKE_PROJECT_NAME} PRIVATE ${DEPS_LIB_DIRS})
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE ${DEPS_LIBRARIES})
20 changes: 10 additions & 10 deletions cmake/BuildGoogleAPIs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ set(PROTO_FILES
${googleapis_SOURCE_DIR}/google/longrunning/operations.proto
${googleapis_SOURCE_DIR}/google/rpc/status.proto)

set(OUTPUT_FOLDER ${CMAKE_SOURCE_DIR}/src/cloud-providers/google)
set(GOOGLE_APIS_OUTPUT_FOLDER ${CMAKE_SOURCE_DIR}/src/cloud-providers/google)

set(GOOGLE_APIS_OUTPUT_FILES "")

Expand All @@ -44,13 +44,14 @@ foreach(PROTO_FILE ${PROTO_FILES})
get_filename_component(PROTO_FILE_DIR ${PROTO_FILE_RELATIVE} DIRECTORY)

# append the output files to the list
list(APPEND GOOGLE_APIS_OUTPUT_FILES ${OUTPUT_FOLDER}/${PROTO_FILE_DIR}/${PROTO_CC_FILE}
${OUTPUT_FOLDER}/${PROTO_FILE_DIR}/${PROTO_GRPC_FILE})
list(APPEND GOOGLE_APIS_OUTPUT_FILES ${GOOGLE_APIS_OUTPUT_FOLDER}/${PROTO_FILE_DIR}/${PROTO_CC_FILE}
${GOOGLE_APIS_OUTPUT_FOLDER}/${PROTO_FILE_DIR}/${PROTO_GRPC_FILE})

# Generate the grpc files
add_custom_command(
OUTPUT ${OUTPUT_FOLDER}/${PROTO_FILE_DIR}/${PROTO_CC_FILE} ${OUTPUT_FOLDER}/${PROTO_FILE_DIR}/${PROTO_GRPC_FILE}
COMMAND ${PROTOC_EXECUTABLE} --cpp_out=${OUTPUT_FOLDER} --grpc_out=${OUTPUT_FOLDER}
OUTPUT ${GOOGLE_APIS_OUTPUT_FOLDER}/${PROTO_FILE_DIR}/${PROTO_CC_FILE}
${GOOGLE_APIS_OUTPUT_FOLDER}/${PROTO_FILE_DIR}/${PROTO_GRPC_FILE}
COMMAND ${PROTOC_EXECUTABLE} --cpp_out=${GOOGLE_APIS_OUTPUT_FOLDER} --grpc_out=${GOOGLE_APIS_OUTPUT_FOLDER}
--plugin=protoc-gen-grpc=${GRPC_PLUGIN_EXECUTABLE} -I ${googleapis_SOURCE_DIR} ${PROTO_FILE}
DEPENDS ${PROTO_FILE})
endforeach()
Expand All @@ -60,7 +61,7 @@ add_library(google-apis ${GOOGLE_APIS_OUTPUT_FILES})

# disable conversion warnings from the generated files
if(MSVC)
target_compile_options(google-apis PRIVATE /wd4244 /wd4267)
target_compile_options(google-apis PRIVATE /wd4244 /wd4267 /wd4099)
else()
target_compile_options(
google-apis
Expand All @@ -74,12 +75,11 @@ else()
-Wno-error=conversion)
endif()

target_include_directories(google-apis PUBLIC ${OUTPUT_FOLDER} ${GRPC_INCLUDE_DIR} ${PROTOBUF_INCLUDE_DIR}
${absl_INCLUDE_DIRS})
target_include_directories(google-apis PUBLIC ${GOOGLE_APIS_OUTPUT_FOLDER} ${DEPS_INCLUDE_DIRS})

# link the grpc libraries
target_link_libraries(google-apis PRIVATE ${GRPC_LIBRARIES})
target_link_directories(google-apis PRIVATE ${GRPC_LIB_DIR})
target_link_libraries(google-apis PRIVATE ${DEPS_LIBRARIES})
target_link_directories(google-apis PRIVATE ${DEPS_LIB_DIRS})

# link the library to the main project
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE google-apis)
4 changes: 3 additions & 1 deletion cmake/windows/compilerconfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ add_compile_options(
/W3
/utf-8
/wd4267
/wd4099
"$<$<COMPILE_LANG_AND_ID:C,MSVC>:/MP>"
"$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/MP>"
"$<$<COMPILE_LANG_AND_ID:C,Clang>:${_obs_clang_c_options}>"
Expand All @@ -46,7 +47,8 @@ add_link_options($<$<NOT:$<CONFIG:Debug>>:/OPT:REF>
$<$<NOT:$<CONFIG:Debug>>:/OPT:ICF>
$<$<NOT:$<CONFIG:Debug>>:/INCREMENTAL:NO>
/DEBUG
/Brepro)
/Brepro
/IGNORE:4099)
# cmake-format: on

if(CMAKE_COMPILE_WARNING_AS_ERROR)
Expand Down
3 changes: 3 additions & 0 deletions conanfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
grpc/1.67.1
protobuf/5.27.0
abseil/20240116.2
openssl/3.3.2
c-ares/1.34.3
zlib/1.3.1

[generators]
CMakeDeps
5 changes: 5 additions & 0 deletions conanfile_win.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[requires]
openssl/1.1.1w

[generators]
CMakeDeps
8 changes: 7 additions & 1 deletion data/locale/en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,10 @@ log_words="Log words"
log_level="Log level"
partial_transcription="Partial transcription"
partial_transcription_info="Transcribe partial sentences"
partial_latency="Partial latency"
partial_latency="Partial latency"
timed_metadata_parameters="Timed metadata parameters"
timed_metadata_parameters_info="Timed metadata allows sending captions metadata to a cloud stream channel."
timed_metadata_channel_arn="Channel ARN"
timed_metadata_aws_access_key="AWS Access Key ID"
timed_metadata_aws_secret_key="AWS Secret Key"
timed_metadata_aws_region="AWS Region"
Loading

0 comments on commit 4c8ef32

Please sign in to comment.