fix: audio_transcription sample build error

This commit is contained in:
yuniruyuni 2023-04-26 14:47:15 +09:00
parent af4bacf80b
commit 8feebfb953

View file

@ -11,8 +11,8 @@ fn main() -> Result<(), &'static str> {
// Load a context and model.
let ctx = WhisperContext::new("example/path/to/model/whisper.cpp/models/ggml-base.en.bin")
.expect("failed to load model");
// Create a single global key.
ctx.create_key(()).expect("failed to create key");
// Create a state
let state = ctx.create_state().expect("failed to create key");
// Create a params object for running the model.
// The number of past samples to consider defaults to 0.
@ -63,7 +63,7 @@ fn main() -> Result<(), &'static str> {
}
// Run the model.
ctx.full(&(), params, &audio[..])
ctx.full(&state, params, &audio[..])
.expect("failed to run model");
// Create a file to write the transcript to.
@ -71,18 +71,18 @@ fn main() -> Result<(), &'static str> {
// Iterate through the segments of the transcript.
let num_segments = ctx
.full_n_segments(&())
.full_n_segments(&state)
.expect("failed to get number of segments");
for i in 0..num_segments {
// Get the transcribed text and timestamps for the current segment.
let segment = ctx
.full_get_segment_text(&(), i)
.full_get_segment_text(&state, i)
.expect("failed to get segment");
let start_timestamp = ctx
.full_get_segment_t0(&(), i)
.full_get_segment_t0(&state, i)
.expect("failed to get start timestamp");
let end_timestamp = ctx
.full_get_segment_t1(&(), i)
.full_get_segment_t1(&state, i)
.expect("failed to get end timestamp");
// Print the segment to stdout.