Add missing parallel transcription
This commit is contained in:
parent
7bac5e4d7a
commit
6c1071fc8b
|
|
@ -110,6 +110,14 @@ typedef struct {
|
|||
int n_samples;
|
||||
} ruby_whisper_full_args;
|
||||
|
||||
typedef struct ruby_whisper_full_parallel_args {
|
||||
VALUE *context;
|
||||
VALUE *params;
|
||||
float *samples;
|
||||
int n_samples;
|
||||
int n_processors;
|
||||
} ruby_whisper_full_parallel_args;
|
||||
|
||||
typedef struct {
|
||||
struct parakeet_full_params params;
|
||||
ruby_whisper_callback_container *new_segment_callback_container;
|
||||
|
|
|
|||
|
|
@ -38,14 +38,6 @@ typedef struct fill_samples_args {
|
|||
int n_samples;
|
||||
} fill_samples_args;
|
||||
|
||||
typedef struct full_parallel_args {
|
||||
VALUE *context;
|
||||
VALUE *params;
|
||||
float *samples;
|
||||
int n_samples;
|
||||
int n_processors;
|
||||
} full_parallel_args;
|
||||
|
||||
typedef struct full_without_gvl_args {
|
||||
struct whisper_context *context;
|
||||
struct whisper_full_params *params;
|
||||
|
|
@ -549,10 +541,10 @@ full_parallel_without_gvl(void *rb_args)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
VALUE
|
||||
full_parallel_body(VALUE rb_args)
|
||||
{
|
||||
full_parallel_args *args = (full_parallel_args *)rb_args;
|
||||
ruby_whisper_full_parallel_args *args = (ruby_whisper_full_parallel_args *)rb_args;
|
||||
|
||||
ruby_whisper *rw;
|
||||
ruby_whisper_params *rwp;
|
||||
|
|
@ -614,7 +606,7 @@ ruby_whisper_full_parallel(int argc, VALUE *argv,VALUE self)
|
|||
break;
|
||||
}
|
||||
struct parsed_samples_t parsed = parse_samples(&argv[1], &n_samples);
|
||||
const full_parallel_args args = {
|
||||
const ruby_whisper_full_parallel_args args = {
|
||||
&self,
|
||||
&argv[0],
|
||||
parsed.samples,
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ extern ID transcribe_option_names[1];
|
|||
|
||||
extern void prepare_transcription(ruby_whisper_params * rwp, VALUE * self, int n_processors);
|
||||
extern VALUE full_body(VALUE rb_args);
|
||||
extern VALUE full_parallel_body(VALUE rb_args);
|
||||
|
||||
typedef struct{
|
||||
struct whisper_context *context;
|
||||
|
|
@ -80,14 +81,36 @@ ruby_whisper_transcribe(int argc, VALUE *argv, VALUE self) {
|
|||
fprintf(stderr, "error: failed to open '%s' as WAV file\n", fname_inp.c_str());
|
||||
return self;
|
||||
}
|
||||
/*
|
||||
*
|
||||
typedef struct full_parallel_args {
|
||||
VALUE *context;
|
||||
VALUE *params;
|
||||
float *samples;
|
||||
int n_samples;
|
||||
int n_processors;
|
||||
} full_parallel_args;
|
||||
|
||||
ruby_whisper_full_args args = {
|
||||
&self,
|
||||
¶ms,
|
||||
pcmf32.data(),
|
||||
(int)pcmf32.size(),
|
||||
};
|
||||
VALUE rb_result = full_body((VALUE)&args);
|
||||
*/
|
||||
VALUE rb_result;
|
||||
if (n_processors == 1) {
|
||||
ruby_whisper_full_args args = {
|
||||
&self,
|
||||
¶ms,
|
||||
pcmf32.data(),
|
||||
(int)pcmf32.size(),
|
||||
};
|
||||
rb_result = full_body((VALUE)&args);
|
||||
} else {
|
||||
ruby_whisper_full_parallel_args parallel_args = {
|
||||
&self,
|
||||
¶ms,
|
||||
pcmf32.data(),
|
||||
(int)pcmf32.size(),
|
||||
n_processors,
|
||||
};
|
||||
rb_result = full_parallel_body((VALUE)¶llel_args);
|
||||
}
|
||||
const int result = NUM2INT(rb_result);
|
||||
if (result != 0) {
|
||||
fprintf(stderr, "failed to process audio\n");
|
||||
|
|
|
|||
Loading…
Reference in New Issue