Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Update cleanstream-filter.cpp to fix audio file loading issue … #25

Merged
merged 3 commits into from
Jul 20, 2024
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
48 changes: 1 addition & 47 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,53 +34,7 @@ if(ENABLE_QT)
AUTORCC ON)
endif()

function(find_libav)
if(UNIX AND NOT APPLE)
find_package(PkgConfig REQUIRED)
pkg_check_modules(
FFMPEG
REQUIRED
IMPORTED_TARGET
libavformat
libavcodec
libavutil
libswresample)
if(FFMPEG_FOUND)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE PkgConfig::FFMPEG)
else()
message(FATAL_ERROR "FFMPEG not found!")
endif()
return()
endif()

if(NOT buildspec)
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/buildspec.json" buildspec)
endif()
string(
JSON
version
GET
${buildspec}
dependencies
prebuilt
version)

if(MSVC)
set(arch ${CMAKE_GENERATOR_PLATFORM})
elseif(APPLE)
set(arch universal)
endif()
set(deps_root "${CMAKE_CURRENT_SOURCE_DIR}/.deps/obs-deps-${version}-${arch}")

target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE "${deps_root}/include")
target_link_libraries(
${CMAKE_PROJECT_NAME}
PRIVATE "${deps_root}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}avcodec${CMAKE_STATIC_LIBRARY_SUFFIX}"
"${deps_root}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}avformat${CMAKE_STATIC_LIBRARY_SUFFIX}"
"${deps_root}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}avutil${CMAKE_STATIC_LIBRARY_SUFFIX}"
"${deps_root}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}swresample${CMAKE_STATIC_LIBRARY_SUFFIX}")
endfunction(find_libav)

include(cmake/FindLibAv.cmake)
find_libav()

set(USE_SYSTEM_CURL
Expand Down
61 changes: 61 additions & 0 deletions cmake/FindLibAv.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
function(find_libav)
if(UNIX AND NOT APPLE)
find_package(PkgConfig REQUIRED)
pkg_check_modules(
FFMPEG
REQUIRED
IMPORTED_TARGET
libavformat
libavcodec
libavutil
libswresample)
if(FFMPEG_FOUND)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE PkgConfig::FFMPEG)
else()
message(FATAL_ERROR "FFMPEG not found!")
endif()
return()
endif()

if(NOT buildspec)
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/buildspec.json" buildspec)
endif()
string(
JSON
version
GET
${buildspec}
dependencies
prebuilt
version)

if(MSVC)
set(arch ${CMAKE_GENERATOR_PLATFORM})
elseif(APPLE)
set(arch universal)
endif()
set(deps_root "${CMAKE_CURRENT_SOURCE_DIR}/.deps/obs-deps-${version}-${arch}")

target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE "${deps_root}/include")
target_link_libraries(
${CMAKE_PROJECT_NAME}
PRIVATE "${deps_root}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}avcodec${CMAKE_STATIC_LIBRARY_SUFFIX}"
"${deps_root}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}avformat${CMAKE_STATIC_LIBRARY_SUFFIX}"
"${deps_root}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}avutil${CMAKE_STATIC_LIBRARY_SUFFIX}"
"${deps_root}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}swresample${CMAKE_STATIC_LIBRARY_SUFFIX}")

if(MSVC)
# find libav .dlls
file(
GLOB_RECURSE av_dlls
LIST_DIRECTORIES false
"${deps_root}/bin/av*.dll")
# add sw* .dlls
file(
GLOB_RECURSE sw_dlls
LIST_DIRECTORIES false
"${deps_root}/bin/sw*.dll")
# install .dlls to the same directory as the executable
install(FILES ${av_dlls};${sw_dlls} DESTINATION "obs-plugins/64bit")
endif()
endfunction(find_libav)
17 changes: 11 additions & 6 deletions src/cleanstream-filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,10 @@ void *cleanstream_create(obs_data_t *settings, obs_source_t *filter)
if (audioFile.empty()) {
obs_log(LOG_ERROR, "Failed to load audio file: %s",
audio_file_path_fs.string().c_str());
return nullptr;
gf->audioFileCache[file_name] = {};
} else {
gf->audioFileCache[file_name] = audioFile;
}
gf->audioFileCache[file_name] = audioFile;
}
#endif

Expand Down Expand Up @@ -428,8 +429,14 @@ obs_properties_t *cleanstream_properties(void *data)
obs_property_list_add_int(replace_sounds_list, "Silence", REPLACE_SOUNDS_SILENCE);
// on windows and mac, add external file path for replace sound
#if defined(_WIN32) || defined(__APPLE__)
obs_property_list_add_int(replace_sounds_list, "Beep", REPLACE_SOUNDS_BEEP);
obs_property_list_add_int(replace_sounds_list, "Horn", REPLACE_SOUNDS_HORN);
struct cleanstream_data *gf = static_cast<struct cleanstream_data *>(data);

if (!gf->audioFileCache["beep.wav"].empty()) {
obs_property_list_add_int(replace_sounds_list, "Beep", REPLACE_SOUNDS_BEEP);
}
if (!gf->audioFileCache["horn.wav"].empty()) {
obs_property_list_add_int(replace_sounds_list, "Horn", REPLACE_SOUNDS_HORN);
}
obs_property_list_add_int(replace_sounds_list, "External", REPLACE_SOUNDS_EXTERNAL);

// add external file path for replace sound
Expand All @@ -448,8 +455,6 @@ obs_properties_t *cleanstream_properties(void *data)
return true;
});

struct cleanstream_data *gf = static_cast<struct cleanstream_data *>(data);

obs_property_set_modified_callback2(
replace_sound_path,
[](void *data_, obs_properties_t *props, obs_property_t *property,
Expand Down
62 changes: 38 additions & 24 deletions src/model-utils/model-infos.cpp
Original file line number Diff line number Diff line change
@@ -1,28 +1,6 @@
#include "model-downloader-types.h"

std::map<std::string, ModelInfo> models_info = {{
{"M2M-100 418M (495Mb)",
{"M2M-100 418M",
"m2m-100-418M",
MODEL_TYPE_TRANSLATION,
{{"https://huggingface.co/jncraton/m2m100_418M-ct2-int8/resolve/main/model.bin?download=true",
"D6703DD9F920FF896E45C3D97B490761BED5944937B90BBE6A7245F5652542D4"},
{
"https://huggingface.co/jncraton/m2m100_418M-ct2-int8/resolve/main/config.json?download=true",
"4244772990E30069563E3DDFB4AD6DC95BDFD2AC3DE667EA8858C9B0A8433FA8",
},
{"https://huggingface.co/jncraton/m2m100_418M-ct2-int8/resolve/main/generation_config.json?download=true",
"AED76366507333DDBB8BD49960F23C82FE6446B3319A46A54BEFDB45324CCF61"},
{"https://huggingface.co/jncraton/m2m100_418M-ct2-int8/resolve/main/shared_vocabulary.json?download=true",
"7EB5D0FF184C6095C7C10F9911C0AEA492250ABD12854F9C3D787C64B1C6397E"},
{"https://huggingface.co/jncraton/m2m100_418M-ct2-int8/resolve/main/special_tokens_map.json?download=true",
"C1A4F86C3874D279AE1B2A05162858DB5DD6C61665D84223ED886CBCFF08FDA6"},
{"https://huggingface.co/jncraton/m2m100_418M-ct2-int8/resolve/main/tokenizer_config.json?download=true",
"AE54F15F0649BB05041CDADAD8485BA1FAF40BC33E6B4C2A74AE2D1AE5710FA2"},
{"https://huggingface.co/jncraton/m2m100_418M-ct2-int8/resolve/main/vocab.json?download=true",
"B6E77E474AEEA8F441363ACA7614317C06381F3EACFE10FB9856D5081D1074CC"},
{"https://huggingface.co/jncraton/m2m100_418M-ct2-int8/resolve/main/sentencepiece.bpe.model?download=true",
"D8F7C76ED2A5E0822BE39F0A4F95A55EB19C78F4593CE609E2EDBC2AEA4D380A"}}}},
{"Whisper Base q5 (57Mb)",
{"Whisper Base q5",
"whisper-base-q5",
Expand All @@ -47,8 +25,8 @@ std::map<std::string, ModelInfo> models_info = {{
MODEL_TYPE_TRANSCRIPTION,
{{"https://ggml.ggerganov.com/ggml-model-whisper-base.en.bin",
"A03779C86DF3323075F5E796CB2CE5029F00EC8869EEE3FDFB897AFE36C6D002"}}}},
{"Whisper Large q5 (1Gb)",
{"Whisper Large q5",
{"Whisper Large v1 q5 (1Gb)",
{"Whisper Large v1 q5",
"ggml-model-whisper-large-q5_0",
MODEL_TYPE_TRANSCRIPTION,
{{"https://ggml.ggerganov.com/ggml-model-whisper-large-q5_0.bin",
Expand Down Expand Up @@ -119,4 +97,40 @@ std::map<std::string, ModelInfo> models_info = {{
MODEL_TYPE_TRANSCRIPTION,
{{"https://ggml.ggerganov.com/ggml-model-whisper-tiny.en.bin",
"921E4CF8686FDD993DCD081A5DA5B6C365BFDE1162E72B08D75AC75289920B1F"}}}},
{"Whisper Large v3 (3Gb)",
{"Whisper Large v3",
"ggml-large-v3",
MODEL_TYPE_TRANSCRIPTION,
{{"https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-large-v3.bin",
"64d182b440b98d5203c4f9bd541544d84c605196c4f7b845dfa11fb23594d1e2"}}}},
{"Whisper Large v3 q5 (1Gb)",
{"Whisper Large v3 q5",
"ggml-large-v3-q5_0",
MODEL_TYPE_TRANSCRIPTION,
{{"https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-large-v3-q5_0.bin",
"d75795ecff3f83b5faa89d1900604ad8c780abd5739fae406de19f23ecd98ad1"}}}},
{"Whisper Large v2 (3Gb)",
{"Whisper Large v2",
"ggml-large-v2",
MODEL_TYPE_TRANSCRIPTION,
{{"https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-large-v2.bin",
"9a423fe4d40c82774b6af34115b8b935f34152246eb19e80e376071d3f999487"}}}},
{"Whisper Large v1 (3Gb)",
{"Whisper Large v1",
"ggml-large-v1",
MODEL_TYPE_TRANSCRIPTION,
{{"https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-large-v1.bin",
"7d99f41a10525d0206bddadd86760181fa920438b6b33237e3118ff6c83bb53d"}}}},
{"Whisper Medium English (1.5Gb)",
{"Whisper Medium English",
"ggml-meduim-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",
MODEL_TYPE_TRANSCRIPTION,
{{"https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-medium.bin",
"6c14d5adee5f86394037b4e4e8b59f1673b6cee10e3cf0b11bbdbee79c156208"}}}},
}};
Loading