refactor: Add filter-replace-utils for serializing and deserializing (#170)

- Add filter-replace-utils for serializing and deserializing in the src/ui directory.
- Update CMakeLists.txt to include the new files in the target_sources.
- Update FindLibAvObs.cmake to read buildspec.json from the CMAKE_SOURCE_DIR.
- Update model-infos.cpp to include two new Whisper models.
- Add a new CMakeLists.txt file in the src/tests directory.
- Add localvocal-offline-test.cpp in the src/tests directory.
- Add clear_current_caption function in localvocal-offline-test.cpp.
This commit is contained in:
Roy Shilkrot 2024-10-01 13:41:47 -04:00 committed by GitHub
parent 024502333a
commit 65408db097
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 61 additions and 32 deletions

View File

@ -130,32 +130,5 @@ target_sources(
set_target_properties_plugin(${CMAKE_PROJECT_NAME} PROPERTIES OUTPUT_NAME ${_name})
if(ENABLE_TESTS)
add_executable(${CMAKE_PROJECT_NAME}-tests)
include(cmake/FindLibAvObs.cmake)
target_sources(
${CMAKE_PROJECT_NAME}-tests
PRIVATE src/tests/localvocal-offline-test.cpp
src/tests/audio-file-utils.cpp
src/transcription-utils.cpp
src/model-utils/model-infos.cpp
src/model-utils/model-find-utils.cpp
src/whisper-utils/whisper-processing.cpp
src/whisper-utils/whisper-utils.cpp
src/whisper-utils/silero-vad-onnx.cpp
src/whisper-utils/token-buffer-thread.cpp
src/whisper-utils/vad-processing.cpp
src/translation/language_codes.cpp
src/translation/translation.cpp
src/ui/filter-replace-utils.cpp
src/translation/translation-language-utils.cpp)
find_libav(${CMAKE_PROJECT_NAME}-tests)
target_link_libraries(${CMAKE_PROJECT_NAME}-tests PRIVATE ct2 sentencepiece Whispercpp Ort OBS::libobs ICU)
target_include_directories(${CMAKE_PROJECT_NAME}-tests PRIVATE src)
# install the tests to the release/test directory
install(TARGETS ${CMAKE_PROJECT_NAME}-tests DESTINATION test)
add_subdirectory(src/tests)
endif()

View File

@ -20,7 +20,7 @@ function(find_libav TARGET)
endif()
if(NOT buildspec)
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/buildspec.json" buildspec)
file(READ "${CMAKE_SOURCE_DIR}/buildspec.json" buildspec)
endif()
string(
JSON
@ -36,7 +36,7 @@ function(find_libav TARGET)
elseif(APPLE)
set(arch universal)
endif()
set(deps_root "${CMAKE_CURRENT_SOURCE_DIR}/.deps/obs-deps-${version}-${arch}")
set(deps_root "${CMAKE_SOURCE_DIR}/.deps/obs-deps-${version}-${arch}")
target_include_directories(${TARGET} PRIVATE "${deps_root}/include")
target_link_libraries(

View File

@ -221,14 +221,26 @@ std::map<std::string, ModelInfo> models_info = {{
"7d99f41a10525d0206bddadd86760181fa920438b6b33237e3118ff6c83bb53d"}}}},
{"Whisper Medium English (1.5Gb)",
{"Whisper Medium English",
"ggml-meduim-en",
"ggml-medium-en",
MODEL_TYPE_TRANSCRIPTION,
{{"https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-medium.en.bin",
"cc37e93478338ec7700281a7ac30a10128929eb8f427dda2e865faa8f6da4356"}}}},
{"Whisper Medium (1.5Gb)",
{"Whisper Medium",
"ggml-meduim",
"ggml-medium",
MODEL_TYPE_TRANSCRIPTION,
{{"https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-medium.bin",
"6c14d5adee5f86394037b4e4e8b59f1673b6cee10e3cf0b11bbdbee79c156208"}}}},
{"Whisper Large v3 Turbo (1.62Gb)",
{"Whisper Large v3 Turbo",
"ggml-large-v3-turbo",
MODEL_TYPE_TRANSCRIPTION,
{{"https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-large-v3-turbo.bin",
"1FC70F774D38EB169993AC391EEA357EF47C88757EF72EE5943879B7E8E2BC69"}}}},
{"Whisper Large v3 Turbo q5 (574Mb)",
{"Whisper Large v3 Turbo q5",
"ggml-large-v3-turbo-q5_0",
MODEL_TYPE_TRANSCRIPTION,
{{"https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-large-v3-turbo-q5_0.bin",
"394221709CD5AD1F40C46E6031CA61BCE88931E6E088C188294C6D5A55FFA7E2"}}}},
}};

29
src/tests/CMakeLists.txt Normal file
View File

@ -0,0 +1,29 @@
set(TEST_EXEC_NAME ${CMAKE_PROJECT_NAME}-tests)
add_executable(${TEST_EXEC_NAME})
target_sources(
${TEST_EXEC_NAME}
PRIVATE ${CMAKE_SOURCE_DIR}/src/tests/localvocal-offline-test.cpp
${CMAKE_SOURCE_DIR}/src/tests/audio-file-utils.cpp
${CMAKE_SOURCE_DIR}/src/transcription-utils.cpp
${CMAKE_SOURCE_DIR}/src/model-utils/model-infos.cpp
${CMAKE_SOURCE_DIR}/src/model-utils/model-find-utils.cpp
${CMAKE_SOURCE_DIR}/src/whisper-utils/whisper-processing.cpp
${CMAKE_SOURCE_DIR}/src/whisper-utils/whisper-utils.cpp
${CMAKE_SOURCE_DIR}/src/whisper-utils/silero-vad-onnx.cpp
${CMAKE_SOURCE_DIR}/src/whisper-utils/token-buffer-thread.cpp
${CMAKE_SOURCE_DIR}/src/whisper-utils/vad-processing.cpp
${CMAKE_SOURCE_DIR}/src/translation/language_codes.cpp
${CMAKE_SOURCE_DIR}/src/translation/translation.cpp
${CMAKE_SOURCE_DIR}/src/ui/filter-replace-utils.cpp
${CMAKE_SOURCE_DIR}/src/translation/translation-language-utils.cpp)
include(${CMAKE_SOURCE_DIR}/cmake/FindLibAvObs.cmake)
find_libav(${TEST_EXEC_NAME})
target_link_libraries(${TEST_EXEC_NAME} PRIVATE ct2 sentencepiece Whispercpp Ort OBS::libobs ICU)
target_include_directories(${TEST_EXEC_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/src)
# install the tests to the release/test directory
install(TARGETS ${TEST_EXEC_NAME} DESTINATION test)

View File

@ -276,6 +276,21 @@ void json_segments_saver_thread_function()
}
}
void clear_current_caption(transcription_filter_data *gf_)
{
if (gf_->captions_monitor.isEnabled()) {
gf_->captions_monitor.clear();
gf_->translation_monitor.clear();
}
// reset translation context
gf_->last_text_for_translation = "";
gf_->last_text_translation = "";
gf_->translation_ctx.last_input_tokens.clear();
gf_->translation_ctx.last_translation_tokens.clear();
gf_->last_transcription_sentence.clear();
gf_->cleared_last_sub = true;
}
void set_text_callback(struct transcription_filter_data *gf,
const DetectionResultWithText &resultIn)
{