From 8feebfb953611710340075bf3f112e40f4f3a17e Mon Sep 17 00:00:00 2001 From: yuniruyuni Date: Wed, 26 Apr 2023 14:47:15 +0900 Subject: [PATCH] fix: audio_transcription sample build error --- examples/audio_transcription.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/audio_transcription.rs b/examples/audio_transcription.rs index e389723..aa6b54c 100644 --- a/examples/audio_transcription.rs +++ b/examples/audio_transcription.rs @@ -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.