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

Add new models #74

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
3 changes: 1 addition & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,5 @@ Suggests:
audio.vadwebrtc (>= 0.2.0)
LinkingTo: Rcpp
SystemRequirements: GNU make
RoxygenNote: 7.1.2
RoxygenNote: 7.3.2
Remotes: bnosac/audio.vadwebrtc

40 changes: 26 additions & 14 deletions R/whisper.R
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,18 @@ align_skipped <- function(sentences, skipped, from = "from", to = "to"){
#' language = "en", duration = 1000)
#' }
whisper <- function(x, use_gpu = FALSE, overwrite = FALSE, model_dir = Sys.getenv("WHISPER_MODEL_DIR", unset = getwd()), ...){
if(x %in% c("tiny", "tiny.en", "base", "base.en", "small", "small.en", "medium", "medium.en", "large-v1", "large-v2", "large-v3", "large",
"tiny-q5_1", "tiny.en-q5_1",
"base-q5_1", "base.en-q5_1",
"small-q5_1", "small.en-q5_1",
"medium-q5_0", "medium.en-q5_0",
"large-v2-q5_0", "large-v3-q5_0")){
if(x %in% c("tiny", "tiny-q5_1", "tiny-q8_0",
"tiny.en", "tiny.en-q5_1", "tiny.en-q8_0",
"base", "base-q5_1", "base-q8_0",
"base.en", "base.en-q5_1", "base.en-q8_0",
"small", "small-q5_1", "small-q8_0",
"small.en", "small.en-q5_1", "small.en-q8_0",
"medium", "medium-q5_0", "medium-q8_0",
"medium.en", "medium.en-q5_0", "medium.en-q8_0",
"large-v1",
"large-v2", "large-v2-q5_0", "large-v2-q8_0",
"large-v3", "large-v3-q5_0",
"large-v3-turbo", "large-v3-turbo-q5_0", "large-v3-turbo-q8_0")){
x <- whisper_download_model(x, overwrite = overwrite, model_dir = model_dir)
}
if(inherits(x, "whisper_download")){
Expand All @@ -263,8 +269,8 @@ whisper <- function(x, use_gpu = FALSE, overwrite = FALSE, model_dir = Sys.geten
#' \item{base & base.en: 142 MB, RAM required: ~500 MB. Multilingual and English only version.}
#' \item{small & small.en: 466 MB, RAM required: ~1.0 GB. Multilingual and English only version.}
#' \item{medium & medium.en: 1.5 GB, RAM required: ~2.6 GB. Multilingual and English only version.}
#' \item{large-v1, large-v2, large-v3: 2.9 GB, RAM required: ~4.7 GB. Multilingual}
#' \item{quantised models: tiny-q5_1, tiny.en-q5_1, base-q5_1, base.en-q5_1, small-q5_1, small.en-q5_1, medium-q5_0, medium.en-q5_0, large-v2-q5_0 and large-v3-q5_0 (only - from version 1.5.4 onwards)}
#' \item{large-v1, large-v2, large-v3, large-v3-turbo: 2.9 GB, RAM required: ~4.7 GB. Multilingual}
#' \item{quantised models: tiny-q5_1, tiny-q8_0, tiny.en-q5_1, tiny.en-q8_0, base-q5_1, base-q8_0, base.en-q5_1, base_q8_0, small-q5_1, small-q8_0, small.en-q5_1, small.en-q8_0, medium-q5_0, medium-q8_0, medium.en-q5_0, medium.en-q8_0, large-v2-q5_0, large-v2-q8_0, large-v3-q5_0, large-v3-turbo-q5_0, and large-v3-turbo-q8_0 (only - from version 1.5.4 onwards)}
#' }
#' Note that the larger models may take longer than 60 seconds to download, so consider
#' increasing the timeout option in R via \code{options(timeout = 120)}
Expand Down Expand Up @@ -314,12 +320,18 @@ whisper <- function(x, use_gpu = FALSE, overwrite = FALSE, model_dir = Sys.geten
#' \dontshow{
#' if(file.exists(path$file_model)) file.remove(path$file_model)
#' }
whisper_download_model <- function(x = c("tiny", "tiny.en", "base", "base.en", "small", "small.en", "medium", "medium.en", "large-v1", "large-v2", "large-v3", "large",
"tiny-q5_1", "tiny.en-q5_1",
"base-q5_1", "base.en-q5_1",
"small-q5_1", "small.en-q5_1",
"medium-q5_0", "medium.en-q5_0",
"large-v2-q5_0", "large-v3-q5_0"),
whisper_download_model <- function(x = c("tiny", "tiny-q5_1", "tiny-q8_0",
"tiny.en", "tiny.en-q5_1", "tiny.en-q8_0",
"base", "base-q5_1", "base-q8_0",
"base.en", "base.en-q5_1", "base.en-q8_0",
"small", "small-q5_1", "small-q8_0",
"small.en", "small.en-q5_1", "small.en-q8_0",
"medium", "medium-q5_0", "medium-q8_0",
"medium.en", "medium.en-q5_0", "medium.en-q8_0",
"large-v1",
"large-v2", "large-v2-q5_0", "large-v2-q8_0",
"large-v3", "large-v3-q5_0",
"large-v3-turbo", "large-v3-turbo-q5_0", "large-v3-turbo-q8_0"),
model_dir = Sys.getenv("WHISPER_MODEL_DIR", unset = getwd()),
repos = c("huggingface", "ggerganov"),
version = c("1.5.4", "1.2.1"),
Expand Down
14 changes: 8 additions & 6 deletions man/whisper_download_model.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/RcppExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

using namespace Rcpp;

#ifdef RCPP_USE_GLOBAL_ROSTREAM
Rcpp::Rostream<true>& Rcpp::Rcout = Rcpp::Rcpp_cout_get();
Rcpp::Rostream<false>& Rcpp::Rcerr = Rcpp::Rcpp_cerr_get();
#endif

// whisper_load_model
SEXP whisper_load_model(std::string model, bool use_gpu);
RcppExport SEXP _audio_whisper_whisper_load_model(SEXP modelSEXP, SEXP use_gpuSEXP) {
Expand Down
Loading