Skip to content

Commit b516273

Browse files
committed
move non-whisper.cpp to rcpp_whisper_utils
1 parent 8b8313c commit b516273

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/Makevars

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ PKG_CPPFLAGS += -DSTRICT_R_HEADERS -I./dr_libs -I./whisper_cpp/ggml/include -I./
66
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
77
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
88

9-
SOURCES += whisper_cpp/src/whisper.cpp rcpp_whisper.cpp RcppExports.cpp
10-
OBJECTS += whisper_cpp/src/whisper.o rcpp_whisper.o RcppExports.o
9+
SOURCES += whisper_cpp/src/whisper.cpp rcpp_whisper_utils.cpp RcppExports.cpp
10+
OBJECTS += whisper_cpp/src/whisper.o rcpp_whisper_utils.o RcppExports.o
1111

1212
all: $(SHLIB)
1313

src/rcpp_whisper_utils.cpp

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include <Rcpp.h>
2+
3+
4+
#include "whisper.h"
5+
6+
// [[Rcpp::export]]
7+
Rcpp::DataFrame whisper_language_info() {
8+
auto max_id = whisper_lang_max_id();
9+
std::vector<int> id;
10+
std::vector<std::string> language;
11+
std::vector<std::string> label;
12+
for (int i = 0; i <= max_id; ++i) {
13+
id.push_back(i);
14+
language.push_back(whisper_lang_str(i));
15+
label.push_back(whisper_lang_str_full(i));
16+
}
17+
return Rcpp::DataFrame::create(
18+
Rcpp::Named("id") = id,
19+
Rcpp::Named("language") = language,
20+
Rcpp::Named("language_label") = label,
21+
Rcpp::Named("stringsAsFactors") = false);
22+
}

0 commit comments

Comments
 (0)