File: ruby_whisper.h

package info (click to toggle)
whisper.cpp 1.8.3%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 32,228 kB
  • sloc: cpp: 188,765; ansic: 121,729; lisp: 10,221; sh: 4,272; objc: 2,159; ruby: 1,682; python: 1,177; javascript: 594; makefile: 144
file content (79 lines) | stat: -rw-r--r-- 1,940 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#ifndef RUBY_WHISPER_H
#define RUBY_WHISPER_H

#include "whisper.h"

typedef struct {
  VALUE *context;
  VALUE user_data;
  VALUE callback;
  VALUE callbacks;
} ruby_whisper_callback_container;

typedef struct {
  struct whisper_context *context;
} ruby_whisper;

typedef struct {
  struct whisper_full_params params;
  bool diarize;
  ruby_whisper_callback_container *new_segment_callback_container;
  ruby_whisper_callback_container *progress_callback_container;
  ruby_whisper_callback_container *encoder_begin_callback_container;
  ruby_whisper_callback_container *abort_callback_container;
  VALUE vad_params;
} ruby_whisper_params;

typedef struct {
  struct whisper_vad_params params;
} ruby_whisper_vad_params;

typedef struct {
  VALUE context;
  int index;
} ruby_whisper_segment;

typedef struct {
  whisper_token_data *token_data;
  const char *text;
} ruby_whisper_token;

typedef struct {
  VALUE context;
} ruby_whisper_model;

typedef struct {
  struct whisper_vad_segments *segments;
} ruby_whisper_vad_segments;

typedef struct {
  VALUE segments;
  int index;
} ruby_whisper_vad_segment;

typedef struct {
  struct whisper_vad_context *context;
} ruby_whisper_vad_context;

#define GetContext(obj, rw) do { \
  TypedData_Get_Struct((obj), ruby_whisper, &ruby_whisper_type, (rw)); \
  if ((rw)->context == NULL) { \
    rb_raise(rb_eRuntimeError, "Not initialized"); \
  } \
} while (0)

#define GetToken(obj, rwt) do {                                             \
  TypedData_Get_Struct((obj), ruby_whisper_token, &ruby_whisper_token_type, (rwt)); \
  if ((rwt)->token_data == NULL) { \
    rb_raise(rb_eRuntimeError, "Not initialized"); \
  } \
} while (0)

#define GetVADSegments(obj, rwvss) do { \
  TypedData_Get_Struct((obj), ruby_whisper_vad_segments, &ruby_whisper_vad_segments_type, (rwvss)); \
  if ((rwvss)->segments == NULL) { \
    rb_raise(rb_eRuntimeError, "Not initialized"); \
  } \
} while (0)

#endif