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