Module: Whisper

Defined in:
lib/whisper/context.rb,
lib/whisper/segment.rb,
lib/whisper/model/uri.rb,
ext/ruby_whisper.c

Defined Under Namespace

Modules: VAD Classes: Context, Model, Segment

Constant Summary collapse

VERSION =
rb_str_new2(whisper_version())
LOG_LEVEL_NONE =
INT2NUM(GGML_LOG_LEVEL_NONE)
LOG_LEVEL_INFO =
INT2NUM(GGML_LOG_LEVEL_INFO)
LOG_LEVEL_WARN =
INT2NUM(GGML_LOG_LEVEL_WARN)
LOG_LEVEL_ERROR =
INT2NUM(GGML_LOG_LEVEL_ERROR)
LOG_LEVEL_DEBUG =
INT2NUM(GGML_LOG_LEVEL_DEBUG)
LOG_LEVEL_CONT =
INT2NUM(GGML_LOG_LEVEL_CONT)
AHEADS_NONE =
INT2NUM(WHISPER_AHEADS_NONE)
AHEADS_N_TOP_MOST =
INT2NUM(WHISPER_AHEADS_N_TOP_MOST)
AHEADS_CUSTOM =
INT2NUM(WHISPER_AHEADS_CUSTOM)
AHEADS_TINY_EN =
INT2NUM(WHISPER_AHEADS_TINY_EN)
AHEADS_TINY =
INT2NUM(WHISPER_AHEADS_TINY)
AHEADS_BASE_EN =
INT2NUM(WHISPER_AHEADS_BASE_EN)
AHEADS_BASE =
INT2NUM(WHISPER_AHEADS_BASE)
AHEADS_SMALL_EN =
INT2NUM(WHISPER_AHEADS_SMALL_EN)
AHEADS_SMALL =
INT2NUM(WHISPER_AHEADS_SMALL)
AHEADS_MEDIUM_EN =
INT2NUM(WHISPER_AHEADS_MEDIUM_EN)
AHEADS_MEDIUM =
INT2NUM(WHISPER_AHEADS_MEDIUM)
AHEADS_LARGE_V1 =
INT2NUM(WHISPER_AHEADS_LARGE_V1)
AHEADS_LARGE_V2 =
INT2NUM(WHISPER_AHEADS_LARGE_V2)
AHEADS_LARGE_V3 =
INT2NUM(WHISPER_AHEADS_LARGE_V3)
AHEADS_LARGE_V3_TURBO =
INT2NUM(WHISPER_AHEADS_LARGE_V3_TURBO)

Class Method Summary collapse

Class Method Details

.lang_id(lang_name) ⇒ Integer

Returns:

  • (Integer)


61
62
63
64
65
66
67
68
# File 'ext/ruby_whisper.c', line 61

static VALUE ruby_whisper_s_lang_id(VALUE self, VALUE lang) {
  const char * lang_str = StringValueCStr(lang);
  const int id = whisper_lang_id(lang_str);
  if (-1 == id) {
    rb_raise(rb_eArgError, "language not found: %s", lang_str);
  }
  return INT2NUM(id);
}

.lang_max_idInteger

Returns:

  • (Integer)


53
54
55
# File 'ext/ruby_whisper.c', line 53

static VALUE ruby_whisper_s_lang_max_id(VALUE self) {
  return INT2NUM(whisper_lang_max_id());
}

.lang_str(lang_id) ⇒ String

Returns:

  • (String)


74
75
76
77
78
79
80
81
# File 'ext/ruby_whisper.c', line 74

static VALUE ruby_whisper_s_lang_str(VALUE self, VALUE id) {
  const int lang_id = NUM2INT(id);
  const char * str = whisper_lang_str(lang_id);
  if (NULL == str) {
    rb_raise(rb_eIndexError, "id %d outside of language id", lang_id);
  }
  return rb_str_new2(str);
}

.lang_str(lang_id) ⇒ String

Returns:

  • (String)


87
88
89
90
91
92
93
94
# File 'ext/ruby_whisper.c', line 87

static VALUE ruby_whisper_s_lang_str_full(VALUE self, VALUE id) {
  const int lang_id = NUM2INT(id);
  const char * str_full = whisper_lang_str_full(lang_id);
  if (NULL == str_full) {
    rb_raise(rb_eIndexError, "id %d outside of language id", lang_id);
  }
  return rb_str_new2(str_full);
}

.-nil

Returns:

  • (nil)


123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'ext/ruby_whisper.c', line 123

static VALUE ruby_whisper_s_log_set(VALUE self, VALUE log_callback, VALUE user_data) {
  VALUE old_callback = rb_iv_get(self, "log_callback");
  if (!NIL_P(old_callback)) {
    rb_undefine_finalizer(old_callback);
  }

  rb_iv_set(self, "log_callback", log_callback);
  rb_iv_set(self, "user_data", user_data);

  VALUE finalize_log_callback = rb_funcall(mWhisper, rb_intern("method"), 1, rb_str_new2("finalize_log_callback"));
  rb_define_finalizer(log_callback, finalize_log_callback);

  whisper_log_set(ruby_whisper_log_callback, NULL);

  return Qnil;
}

.system_info_strString

Returns:

  • (String)


100
101
102
# File 'ext/ruby_whisper.c', line 100

static VALUE ruby_whisper_s_system_info_str(VALUE self) {
  return rb_str_new2(whisper_print_system_info());
}