From 673d701ea471daebecb1fb0c1edf79a2017a78ac Mon Sep 17 00:00:00 2001 From: yum Date: Sat, 16 Nov 2024 15:04:13 -0800 Subject: Add support for whisper large v3 turbo Also: * Double # of audio device slots * Fetch CuDNN from NVIDIA at runtime instead of vendoring --- GUI/GUI/GUI/Frame.cpp | 166 ++++++++++++++++++++++++++++++++-------- GUI/package.ps1 | 34 -------- Scripts/requirements.txt | 5 +- Scripts/requirements_frozen.txt | 65 ++++++++-------- 4 files changed, 169 insertions(+), 101 deletions(-) diff --git a/GUI/GUI/GUI/Frame.cpp b/GUI/GUI/GUI/Frame.cpp index 77447bc..0782376 100644 --- a/GUI/GUI/GUI/Frame.cpp +++ b/GUI/GUI/GUI/Frame.cpp @@ -136,6 +136,16 @@ namespace { "7", "8", "9", + "10", + "11", + "12", + "13", + "14", + "15", + "16", + "17", + "18", + "19", }; const size_t kNumMicChoices = sizeof(kMicChoices) / sizeof(kMicChoices[0]); constexpr int kMicDefault = 0; // index @@ -472,6 +482,7 @@ namespace { "large-v2", "distil-large-v3", "large-v3", + "large-v3-turbo", }; const size_t kNumModelChoices = sizeof(kModelChoices) / sizeof(kModelChoices[0]); constexpr int kModelDefault = 2; // base.en @@ -1855,6 +1866,27 @@ void Frame::OnNavbarDebug(wxCommandEvent& event) Resize(); } +bool FindDirectoryByPrefix(wxTextCtrl* out, const std::string& prefix, std::filesystem::path& path) { + std::error_code ec; + // Find directory starting with "cudnn" + for (const auto& entry : + std::filesystem::directory_iterator(".", ec)) { + if (ec) { + Log(out, "Failed to iterate cwd: {}\n", + ec.message()); + return false; + } + + if (entry.is_directory(ec) && + !ec && + entry.path().filename().string().starts_with(prefix)) { + path = entry.path(); + return true; + } + } + return false; +} + void Frame::EnsureVirtualEnv(bool block, bool force) { auto status = env_proc_.wait_for(std::chrono::seconds(0)); @@ -1886,48 +1918,116 @@ void Frame::EnsureVirtualEnv(bool block, bool force) return; } - env_proc_ = std::move(std::async(std::launch::async, [&]() { - Log(transcribe_out_, "Setting up Python virtual environment\n"); - Log(transcribe_out_, "This could take several minutes, please be " - "patient!\n"); - Log(transcribe_out_, "This will download ~1GB of dependencies.\n"); - - { - Log(transcribe_out_, " Installing pip\n"); - auto out_cb = [&](const std::string& out, const std::string& err) { - Log(transcribe_out_, "{}", out); - Log(transcribe_out_, "{}", err); - }; - if (!PythonWrapper::InstallPip(std::move(out_cb))) { - Log(transcribe_out_, "Failed to install pip!\n"); - return false; - } - } + env_proc_ = std::move(std::async(std::launch::async, [&]() { + Log(transcribe_out_, "Setting up Python virtual environment\n"); + Log(transcribe_out_, "This could take several minutes, please be " + "patient!\n"); + Log(transcribe_out_, "This will download ~1GB of dependencies.\n"); - Log(transcribe_out_, " Installing dependencies\n"); + { + Log(transcribe_out_, " Installing pip\n"); auto out_cb = [&](const std::string& out, const std::string& err) { Log(transcribe_out_, "{}", out); Log(transcribe_out_, "{}", err); }; - if (!PythonWrapper::InvokeWithArgs(*app_c_, - { - "-u", // Unbuffered output - "-m pip", - "install", - "-r Resources/Scripts/requirements_frozen.txt", - }, std::move(out_cb))) { - Log(transcribe_out_, "Failed to launch environment setup thread!\n"); + if (!PythonWrapper::InstallPip(std::move(out_cb))) { + Log(transcribe_out_, "Failed to install pip!\n"); return false; } - Log(transcribe_out_, "Successfully set up virtual environment!\n"); + } - std::ofstream venv_flag_ofs(venv_flag); - auto now = std::chrono::system_clock::now(); - const int64_t seconds_since_epoch = std::chrono::duration_cast(now.time_since_epoch()).count(); - venv_flag_ofs << std::to_string(seconds_since_epoch); + Log(transcribe_out_, " Installing python dependencies\n"); + auto out_cb = [&](const std::string& out, const std::string& err) { + Log(transcribe_out_, "{}", out); + Log(transcribe_out_, "{}", err); + }; + if (!PythonWrapper::InvokeWithArgs(*app_c_, + { + "-u", // Unbuffered output + "-m pip", + "install", + "-r Resources/Scripts/requirements_frozen.txt", + }, out_cb)) { + Log(transcribe_out_, "Failed to launch environment setup thread!\n"); + return false; + } - return true; - })); + Log(transcribe_out_, " Fetching CuDNN\n"); + if (!PythonWrapper::InvokeWithArgs(*app_c_, + { + "-m wget", + "https://developer.download.nvidia.com/compute/cudnn/redist/cudnn/windows-x86_64/cudnn-windows-x86_64-9.5.1.17_cuda12-archive.zip" + }, out_cb)) { + } + Log(transcribe_out_, " Unzipping CuDNN\n"); + if (!PythonWrapper::InvokeWithArgs(*app_c_, + { + "-m zipfile -e", + "cudnn-windows-x86_64-9.5.1.17_cuda12-archive.zip", + "." + }, out_cb)) { + } + Log(transcribe_out_, " Installing CuDNN\n"); + { + std::filesystem::path cudnn_dir; + if (!FindDirectoryByPrefix(transcribe_out_, "cudnn", cudnn_dir)) { + Log(transcribe_out_, "Failed to find unzipped cudnn " + "directory\n"); + return false; + } + std::error_code ec; + const std::filesystem::path dest_dir = "Resources/Scripts"; + for (const auto& entry : + std::filesystem::recursive_directory_iterator(cudnn_dir, ec)) { + if (ec) { + Log(transcribe_out_, "Failed to iterate cudnn dir: {}\n", + ec.message()); + return false; + } + if (!entry.is_regular_file(ec)) { + continue; + } + if (ec) { + Log(transcribe_out_, "Skipping unrecognized file type " + "{}: {}\n", entry.path().string(), ec.message()); + continue; + } + if (entry.path().extension() != ".dll") { + continue; + } + std::filesystem::path dest = + dest_dir / entry.path().filename(); + // Remove destination + std::filesystem::remove(dest, ec); + if (ec) { + Log(transcribe_out_, "Failed to delete old CuDNN .dll: {}\n", + ec.message()); + return false; + } + // Rename file + std::filesystem::rename(entry.path(), dest, ec); + if (ec) { + Log(transcribe_out_, "Failed to move CuDNN .dll: {}\n", + ec.message()); + } + } + // Delete cudnn dir + std::filesystem::remove_all(cudnn_dir, ec); + if (ec) { + Log(transcribe_out_, "Failed to remove old CuDNN dir: {}\n", + ec.message()); + } + } + + Log(transcribe_out_, "Successfully set up virtual environment!\n"); + + std::ofstream venv_flag_ofs(venv_flag); + auto now = std::chrono::system_clock::now(); + const int64_t seconds_since_epoch = std::chrono::duration_cast(now.time_since_epoch()).count(); + venv_flag_ofs << std::to_string(seconds_since_epoch); + + return true; + })); if (block) { // Spinning prevents the GUI from hanging. diff --git a/GUI/package.ps1 b/GUI/package.ps1 index 9b1c05b..697f1a2 100644 --- a/GUI/package.ps1 +++ b/GUI/package.ps1 @@ -85,39 +85,6 @@ if (-Not (Test-Path $git_dir)) { Read-Host -Prompt "Press enter once PortableGit is installed at $pwd\PortableGit" } -$nvidia_dir = "nvidia_dll" - -if (-Not (Test-Path $nvidia_dir)) { - echo "Fetching CUDNN dependencies" - - mkdir $nvidia_dir - pushd $nvidia_dir > $null - - $ZLIB_URL = "https://drive.google.com/uc?export=download&id=1NpWU83JVOWG0tJtFK7ObygTbOasGWZpI" - Invoke-WebRequest $ZLIB_URL -OutFile "zlibwapi.dll" - - # NVIDIA locks these files behind a fucking login making it a massive - # pain in the dick for end users to download, so I rehosted them. - # TODO check hashes. - echo "Fetching NVIDIA dll 1/4 (90 MB)" - $CUDNN_1_URL = "https://www.dropbox.com/scl/fi/d21dsoa982ce7wigng510/cudnn_ops_infer64_8.dll?rlkey=xflxyux0ekhr0fs11m4gs58md&st=0wff5fyn&dl=1" - Invoke-WebRequest $CUDNN_1_URL -OutFile "cudnn_ops_infer64_8.dll" - - echo "Fetching NVIDIA dll 2/4 (570 MB)" - $CUDNN_2_URL = "https://www.dropbox.com/scl/fi/uqccevwk9h2q84dt9vr6u/cudnn_cnn_infer64_8.dll?rlkey=sik7xd0ozg06nr4eayzdym4la&st=031bb8pa&dl=1" - Invoke-WebRequest $CUDNN_2_URL -OutFile "cudnn_cnn_infer64_8.dll" - - echo "Fetching NVIDIA dll 3/4 (470 MB)" - $CUBLAS_1_URL = "https://www.dropbox.com/scl/fi/3vrd4fzwno8q5ejigqz6l/cublasLt64_12.dll?rlkey=uvbdn5e7dmm8ajdhm7yztjmhc&st=dguf57q4&dl=1" - Invoke-WebRequest $CUBLAS_1_URL -OutFile "cublasLt64_12.dll" - - echo "Fetching NVIDIA dll 4/4 (100 MB)" - $CUBLAS_2_URL = "https://www.dropbox.com/scl/fi/hoxjdru7qmwbzelw1gr2t/cublas64_12.dll?rlkey=mcmq5t0b62wjc2uc7ylrixwi6&st=z1la337w&dl=1" - Invoke-WebRequest $CUBLAS_2_URL -OutFile "cublas64_12.dll" - - popd > $null -} - if (-Not (Test-Path UwwwuPP)) { git clone https://github.com/yum-food/UwwwuPP pushd UwwwuPP > $null @@ -162,7 +129,6 @@ cp -Recurse ../Fonts/Emotes TaSTT/Resources/Fonts/Emotes cp -Recurse Python TaSTT/Resources/Python cp -Recurse PortableGit TaSTT/Resources/PortableGit cp -Recurse ../Scripts TaSTT/Resources/Scripts -cp $nvidia_dir/*.dll TaSTT/Resources/Scripts/ mkdir TaSTT/Resources/Images cp ../Images/logo*.png TaSTT/Resources/Images/ cp -Recurse ../Shaders TaSTT/Resources/Shaders diff --git a/Scripts/requirements.txt b/Scripts/requirements.txt index 949b82c..41c581c 100644 --- a/Scripts/requirements.txt +++ b/Scripts/requirements.txt @@ -1,6 +1,6 @@ -ctranslate2==4.2.1 +ctranslate2==4.5.0 editdistance -faster-whisper@https://github.com/guillaumekln/faster-whisper/archive/2f6913efc85306fc4f900da6c67f9a06a7d54a3d.tar.gz +faster-whisper@https://github.com/guillaumekln/faster-whisper/archive/53bbe5401683c9a7549db62642e3d4535956b95c.tar.gz future==0.18.2 huggingface_hub==0.16.4 keyboard @@ -14,4 +14,5 @@ python-osc pyyaml sentence_splitter transformers>=4.21.0 +wget diff --git a/Scripts/requirements_frozen.txt b/Scripts/requirements_frozen.txt index 1913457..9e6a6ab 100644 --- a/Scripts/requirements_frozen.txt +++ b/Scripts/requirements_frozen.txt @@ -1,41 +1,42 @@ -av==12.0.0 -certifi==2023.7.22 -charset-normalizer==3.2.0 +av==13.1.0 +certifi==2024.8.30 +charset-normalizer==3.4.0 colorama==0.4.6 coloredlogs==15.0.1 -ctranslate2==4.2.1 -editdistance==0.6.2 -faster-whisper @ https://github.com/guillaumekln/faster-whisper/archive/2f6913efc85306fc4f900da6c67f9a06a7d54a3d.tar.gz#sha256=c389ad787c8cdafcb13d31f8bae788083eb4e490819aad6b49d76c82e490a388 -filelock==3.12.3 -flatbuffers==23.5.26 -fsspec==2023.9.0 +ctranslate2==4.5.0 +editdistance==0.8.1 +faster-whisper @ https://github.com/guillaumekln/faster-whisper/archive/53bbe5401683c9a7549db62642e3d4535956b95c.tar.gz#sha256=17b49d15a58e18d78b4639af59bd35da12bc0bf3bb73c9af4ad48891dd6793f7 +filelock==3.16.1 +flatbuffers==24.3.25 +fsspec==2024.10.0 future==0.18.2 huggingface-hub==0.16.4 humanfriendly==10.0 -idna==3.4 +idna==3.10 keyboard==0.13.5 -langcodes==3.3.0 -language-data==1.1 -marisa-trie==0.7.8 +langcodes==3.4.1 +language_data==1.2.0 +marisa-trie==1.2.1 mpmath==1.3.0 -numpy==1.25.2 -onnxruntime==1.14.1 -openvr==1.26.701 -packaging==23.1 -Pillow==10.0.0 -protobuf==4.24.3 -PyAudio==0.2.13 +numpy==2.1.3 +onnxruntime==1.20.0 +openvr==2.5.101 +packaging==24.2 +pillow==11.0.0 +protobuf==5.28.3 +PyAudio==0.2.14 pydub==0.25.1 -pyreadline3==3.4.1 -python-osc==1.8.3 -PyYAML==6.0.1 -regex==2023.8.8 -requests==2.31.0 -safetensors==0.3.3 +pyreadline3==3.5.4 +python-osc==1.9.0 +PyYAML==6.0.2 +regex==2024.11.6 +requests==2.32.3 +safetensors==0.4.5 sentence-splitter==1.4 -sympy==1.12 -tokenizers==0.13.3 -tqdm==4.66.1 -transformers==4.33.1 -typing_extensions==4.7.1 -urllib3==2.0.4 +sympy==1.13.3 +tokenizers==0.15.2 +tqdm==4.67.0 +transformers==4.35.2 +typing_extensions==4.12.2 +urllib3==2.2.3 +wget==3.2 -- cgit v1.2.3