Skip to content

Commit

Permalink
move non-whisper.cpp to rcpp_whisper_utils
Browse files Browse the repository at this point in the history
  • Loading branch information
jwijffels committed Oct 6, 2024
1 parent 8b8313c commit b516273
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Makevars
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ PKG_CPPFLAGS += -DSTRICT_R_HEADERS -I./dr_libs -I./whisper_cpp/ggml/include -I./
SOURCES = whisper_cpp/ggml/src/ggml-quants.c whisper_cpp/ggml/src/ggml-backend.c whisper_cpp/ggml/src/ggml-alloc.c whisper_cpp/ggml/src/ggml-aarch64.c whisper_cpp/ggml/src/ggml.c
OBJECTS = whisper_cpp/ggml/src/ggml-quants.o whisper_cpp/ggml/src/ggml-backend.o whisper_cpp/ggml/src/ggml-alloc.o whisper_cpp/ggml/src/ggml-aarch64.o whisper_cpp/ggml/src/ggml.o

SOURCES += whisper_cpp/src/whisper.cpp rcpp_whisper.cpp RcppExports.cpp
OBJECTS += whisper_cpp/src/whisper.o rcpp_whisper.o RcppExports.o
SOURCES += whisper_cpp/src/whisper.cpp rcpp_whisper_utils.cpp RcppExports.cpp
OBJECTS += whisper_cpp/src/whisper.o rcpp_whisper_utils.o RcppExports.o

all: $(SHLIB)

Expand Down
22 changes: 22 additions & 0 deletions src/rcpp_whisper_utils.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <Rcpp.h>


#include "whisper.h"

// [[Rcpp::export]]
Rcpp::DataFrame whisper_language_info() {
auto max_id = whisper_lang_max_id();
std::vector<int> id;
std::vector<std::string> language;
std::vector<std::string> label;
for (int i = 0; i <= max_id; ++i) {
id.push_back(i);
language.push_back(whisper_lang_str(i));
label.push_back(whisper_lang_str_full(i));
}
return Rcpp::DataFrame::create(
Rcpp::Named("id") = id,
Rcpp::Named("language") = language,
Rcpp::Named("language_label") = label,
Rcpp::Named("stringsAsFactors") = false);
}

0 comments on commit b516273

Please sign in to comment.