### set_start_rule
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.FullParams.html
Sets the starting grammar rule for the model. This has no effect if no grammar is set.
```APIDOC
## pub fn set_start_rule(&mut self, start_rule: usize)
### Description
Set the start grammar rule. Does nothing if no grammar is set.
### Parameters
* `start_rule` (usize) - The index of the grammar rule to use as the starting point.
```
--------------------------------
### set_initial_prompt
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.FullParams.html
Sets the initial prompt for the model, providing a starting point for text generation. Subsequent calls will overwrite the previous prompt.
```APIDOC
## pub fn set_initial_prompt(&mut self, initial_prompt: &str)
### Description
Set the initial prompt for the model. This is the text that will be used as the starting point for the model’s decoding. Calling this more than once will overwrite the previous initial prompt.
### Arguments
* `initial_prompt` (&str) - A string slice representing the initial prompt text.
### Panics
This method will panic if `initial_prompt` contains a null byte, as it cannot be converted into a `CString`.
```
--------------------------------
### Set Start Offset
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.FullParams.html
Specifies the starting offset in milliseconds for the decoding process. Defaults to 0.
```rust
pub fn set_offset_ms(&mut self, offset_ms: c_int)
```
--------------------------------
### FullParams::set_offset_ms
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.FullParams.html
Sets the start offset in milliseconds to use for decoding. Defaults to 0.
```APIDOC
## FullParams::set_offset_ms
### Description
Set the start offset in milliseconds to use for decoding.
Defaults to 0.
### Method
`pub fn set_offset_ms(&mut self, offset_ms: c_int)`
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
- **offset_ms** (c_int) - The start offset in milliseconds.
### Request Example
None
### Response
#### Success Response
None
#### Response Example
None
```
--------------------------------
### Set Initial Prompt for Whisper Model
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.FullParams.html
Configures the starting text for the model's decoding process. Subsequent calls will overwrite the previous prompt. Panics if the prompt contains a null byte.
```rust
let mut params = FullParams::new(SamplingStrategy::Greedy { best_of: 5 });
params.set_initial_prompt("Hello, world!");
// ... further usage of params ...
```
--------------------------------
### Get Segment Start Timestamp
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperSegment.html
Retrieves the start time of the segment in centiseconds (10s of milliseconds).
```rust
pub fn start_timestamp(&self) -> i64
```
--------------------------------
### Install Logging Hooks
Source: https://docs.rs/whisper-rs/latest/whisper_rs/fn.install_logging_hooks.html
Redirects whisper.cpp and GGML logs to the Rust logging system. Enable `log_backend` or `tracing_backend` features to direct logs to `log` or `tracing` respectively. Without these, logs are effectively disabled. Safe to call multiple times.
```rust
pub fn install_logging_hooks()
```
--------------------------------
### install_logging_hooks
Source: https://docs.rs/whisper-rs/latest/whisper_rs/fn.install_logging_hooks.html
Redirects all whisper.cpp and GGML logs to logging hooks installed by whisper-rs. This function is safe to call multiple times, but only has an effect the first time it is invoked.
```APIDOC
## install_logging_hooks
### Description
Redirects all whisper.cpp and GGML logs to logging hooks installed by whisper-rs. This integration allows logs to be processed by `log` or `tracing` frameworks if the corresponding features are enabled. If neither feature is enabled, logs will effectively be disabled.
Note that whisper.cpp and GGML do not consistently adhere to Rust logging conventions. Control log output using your logging crate's configuration. It is recommended to configure by module path and use `whisper_rs::ggml_logging_hook` and/or `whisper_rs::whisper_logging_hook` to ensure future `whisper-rs` logs are not inadvertently ignored.
This function is safe to call multiple times; it only affects the system on its first invocation. Subsequent calls have no additional effect.
### Function Signature
```rust
pub fn install_logging_hooks()
```
### Usage
This function does not take any parameters and does not return any value. Its effect is to modify the global logging behavior for the whisper.cpp and GGML libraries.
```
--------------------------------
### set_start_encoder_callback_user_data
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.FullParams.html
Sets the user data to be passed to the start encoder callback. This is an unsafe function and requires careful handling of the user data pointer.
```APIDOC
## pub unsafe fn set_start_encoder_callback_user_data(&mut self, user_data: *mut c_void)
### Description
Set the user data to be passed to the start encoder callback.
### Safety
See the safety notes for `set_start_encoder_callback`.
### Parameters
* `user_data` (*mut c_void) - The user data pointer to be passed to the callback.
```
--------------------------------
### Get Audio Context Size
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperContext.html
Retrieves the maximum number of audio samples (or frames) the model can process at once. This defines the window size for audio input.
```rust
pub fn n_audio_ctx(&self) -> c_int
```
--------------------------------
### Get Whisper Version
Source: https://docs.rs/whisper-rs/latest/whisper_rs/fn.get_whisper_version.html
Retrieves the static string slice representing the current whisper.cpp version. No setup or imports are required beyond the library itself.
```rust
pub fn get_whisper_version() -> &'static str
```
--------------------------------
### Get Model Audio Context Size
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperContext.html
Returns the audio context size as defined by the model architecture. This is the number of audio frames the model's encoder can handle.
```rust
pub fn model_n_audio_ctx(&self) -> c_int
```
--------------------------------
### Get Vocabulary Size
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperContext.html
Retrieves the number of tokens in the model's vocabulary. This value is constant for a given model.
```rust
pub fn n_vocab(&self) -> c_int
```
--------------------------------
### Get Model File Type
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperContext.html
Retrieves an integer code representing the file type or precision of the loaded model (e.g., f32, f16).
```rust
pub fn model_ftype(&self) -> c_int
```
--------------------------------
### Get Model Text Context Size
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperContext.html
Returns the text context size as defined by the model architecture. This is the maximum number of tokens the text decoder can consider.
```rust
pub fn model_n_text_ctx(&self) -> c_int
```
--------------------------------
### set_abort_callback
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.FullParams.html
Sets a callback that is invoked before GGML computation starts. This is an unsafe C-style callback and requires careful consideration to avoid undefined behavior.
```APIDOC
## pub unsafe fn set_abort_callback(&mut self, abort_callback: WhisperAbortCallback)
### Description
Set the callback that is called each time before ggml computation starts.
Note that this callback has not been Rustified yet. It is still a C callback.
### Safety
Do not use this function unless you know what you are doing. Be careful not to mutate the state of the whisper_context pointer returned in the callback. This could cause undefined behavior, as this violates the thread-safety guarantees of the underlying C library.
### Parameters
* `abort_callback` (WhisperAbortCallback) - The callback function to be set.
```
--------------------------------
### Convert Stereo to Mono Audio
Source: https://docs.rs/whisper-rs/latest/whisper_rs/fn.convert_stereo_to_mono_audio.html
Converts 32-bit floating point stereo PCM audio to mono PCM audio. Ensure the input array length is even and the output array has half the capacity of the input. This example demonstrates a successful conversion with pre-allocated buffers.
```rust
let samples = [0.0f32; 1024];
let mut mono_samples = [0.0f32; 512];
convert_stereo_to_mono_audio(&samples, &mut mono_samples).expect("should be no half samples missing");
```
--------------------------------
### Get Model Vocabulary Size
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperContext.html
Retrieves the vocabulary size specific to the model architecture. This might differ from the context's vocabulary size in some configurations.
```rust
pub fn model_n_vocab(&self) -> c_int
```
--------------------------------
### Get Text Context Size
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperContext.html
Returns the maximum number of tokens the model can process in its text context. This indicates the model's memory for textual input.
```rust
pub fn n_text_ctx(&self) -> c_int
```
--------------------------------
### get_lang_str_full
Source: https://docs.rs/whisper-rs/latest/whisper_rs/fn.get_lang_str_full.html
Gets the full string representation of a language ID. For example, an ID of 2 returns 'german'.
```APIDOC
## Function get_lang_str_full
### Description
Get the full string of the specified language name (e.g. 2 -> “german”).
### Signature
```rust
pub fn get_lang_str_full(id: i32) -> Option<&'static str>
```
### Parameters
* **id** (i32) - The ID of the language.
### Returns
- `Option<&'static str>`: The full string of the language, or `None` if the ID is not found.
### C++ Equivalent
`const char * whisper_lang_str_full(int id)`
```
--------------------------------
### get_lang_str
Source: https://docs.rs/whisper-rs/latest/whisper_rs/fn.get_lang_str.html
Gets the short string representation of a language ID. For example, an ID of 2 returns 'de'.
```APIDOC
## get_lang_str
### Description
Get the short string of the specified language id (e.g. 2 -> “de”).
### Signature
```rust
pub fn get_lang_str(id: i32) -> Option<&'static str>
```
### Parameters
#### Path Parameters
- **id** (i32) - Required - The language ID.
### Returns
- **Option<&'static str>** - The short string of the language, None if not found.
### C++ Equivalent
`const char * whisper_lang_str(int id)`
```
--------------------------------
### CloneToUninit Implementation (Nightly)
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.SegmentCallbackData.html
An experimental nightly-only API to perform copy-assignment from a value to an uninitialized memory location.
```rust
unsafe fn clone_to_uninit(&self, dest: *mut u8)
```
--------------------------------
### Get Model Audio State Size
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperContext.html
Retrieves the size of the internal audio state maintained by the model. This relates to the model's memory for audio processing.
```rust
pub fn model_n_audio_state(&self) -> c_int
```
--------------------------------
### Create New FullParams
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.FullParams.html
Initializes a new set of parameters for the decoder. Requires a SamplingStrategy.
```rust
pub fn new(sampling_strategy: SamplingStrategy) -> FullParams<'a, 'b>
```
--------------------------------
### Create WhisperContext from File
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperContext.html
Creates a new WhisperContext by loading a model from a specified file path with custom parameters. Ensure the model file exists and parameters are correctly configured.
```rust
pub fn new_with_params
( path: P, parameters: WhisperContextParameters<'_>, ) -> Result where P: AsRef,
```
--------------------------------
### WhisperVadContext::new
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperVadContext.html
Initializes a new WhisperVadContext. This is the entry point for using the VAD functionality.
```APIDOC
## WhisperVadContext::new
### Description
Initializes a new WhisperVadContext with the specified model path and VAD parameters.
### Method
`new(model_path: &str, params: WhisperVadContextParams) -> Result`
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Parameters
* **model_path** (`&str`) - The path to the Whisper model.
* **params** (`WhisperVadContextParams`) - The VAD context parameters.
### Response
#### Success Response
- **WhisperVadContext** - A new instance of WhisperVadContext on success.
#### Error Response
- **WhisperError** - An error if initialization fails.
```
--------------------------------
### full_lang_id_from_state
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperState.html
Gets the language ID associated with the provided Whisper state.
```APIDOC
## full_lang_id_from_state
### Description
Retrieves the language ID that was identified for the given Whisper state.
### Method
GET (Implicit)
### Endpoint
N/A (Method on WhisperState object)
### Returns
- `c_int`: The identified language ID.
```
--------------------------------
### Get No Speech Probability
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperSegment.html
Retrieves the probability that the segment contains no speech.
```rust
pub fn no_speech_probability(&self) -> f32
```
--------------------------------
### print_system_info
Source: https://docs.rs/whisper-rs/latest/whisper_rs/index.html
Prints system information related to the whisper.cpp environment.
```APIDOC
## print_system_info
### Description
Prints system information related to the whisper.cpp environment.
### Method
(Not specified, likely a free function)
### Endpoint
(Not applicable, this is an SDK function)
### Parameters
(None)
### Request Example
(Not applicable)
### Response
(No return value specified)
#### Response Example
(Not applicable)
```
--------------------------------
### Get Number of Tokens in Segment
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperSegment.html
Retrieves the number of tokens present in this segment.
```rust
pub fn n_tokens(&self) -> c_int
```
--------------------------------
### C++ Equivalent for print_system_info
Source: https://docs.rs/whisper-rs/latest/whisper_rs/fn.print_system_info.html
This shows the equivalent function signature in C++ for `print_system_info`. It returns a C-style string.
```cpp
const char * whisper_print_system_info()
```
--------------------------------
### Get Specific Segment
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperVadSegments.html
Retrieves a specific WhisperVadSegment by its index. Returns None if the index is out of bounds.
```rust
pub fn get_segment(&self, idx: c_int) -> Option
```
--------------------------------
### Set Initial Tokens
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.FullParams.html
Provides the model with initial input tokens. These are prepended to any existing text content. Calling this multiple times overwrites previous tokens. Defaults to an empty vector.
```rust
pub fn set_tokens(&mut self, tokens: &'b [c_int])
```
--------------------------------
### Get Segment End Timestamp
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperSegment.html
Retrieves the end time of the segment in centiseconds (10s of milliseconds).
```rust
pub fn end_timestamp(&self) -> i64
```
--------------------------------
### print_system_info
Source: https://docs.rs/whisper-rs/latest/whisper_rs/fn.print_system_info.html
Prints system information. This function is available in Rust and has a C++ equivalent.
```APIDOC
## print_system_info
### Description
Prints system information.
### Signature
```rust
pub fn print_system_info() -> &'static str
```
### C++ Equivalent
```cpp
const char * whisper_print_system_info()
```
```
--------------------------------
### Get Model Type
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperContext.html
Retrieves an integer code representing the overall type or architecture of the Whisper model.
```rust
pub fn model_type(&self) -> c_int
```
--------------------------------
### FullParams::new
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.FullParams.html
Creates a new set of parameters for the decoder, requiring a SamplingStrategy.
```APIDOC
## FullParams::new
### Description
Create a new set of parameters for the decoder.
### Method
`pub fn new(sampling_strategy: SamplingStrategy) -> FullParams<'a, 'b>`
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Request Example
None
### Response
#### Success Response
- **FullParams<'a, 'b>** - A new instance of FullParams.
#### Response Example
None
```
--------------------------------
### Get Mel Spectrogram Length
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperState.html
Returns the length of the mel spectrogram currently stored in the Whisper state.
```rust
pub fn n_len(&self) -> c_int
```
--------------------------------
### Get Segment Index
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperSegment.html
Retrieves the index of the current segment. This is useful for referencing the segment in other API calls.
```rust
pub fn segment_index(&self) -> c_int
```
--------------------------------
### Enable TinyDiarize Support (Experimental)
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.FullParams.html
Enables experimental support for tinydiarize, which includes speaker turn detection. Defaults to false.
```rust
pub fn set_tdrz_enable(&mut self, tdrz_enable: bool)
```
--------------------------------
### clone_to_uninit
Source: https://docs.rs/whisper-rs/latest/whisper_rs/enum.WhisperError.html
Performs copy-assignment from `self` to `dest`. This is a nightly-only experimental API.
```APIDOC
## unsafe fn clone_to_uninit(&self, dest: *mut u8)
### Description
Performs copy-assignment from `self` to `dest`.
### Method
unsafe fn
### Parameters
#### Path Parameters
- **dest** (*mut u8) - Required - The destination pointer to copy to.
### Note
This is a nightly-only experimental API.
```
--------------------------------
### WhisperVadSegment Struct Definition
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperVadSegment.html
Defines the WhisperVadSegment struct, which represents a segment of audio with start and end timestamps in centiseconds.
```rust
pub struct WhisperVadSegment {
pub start: f32,
pub end: f32,
}
```
--------------------------------
### Enable Token-Level Timestamps (Experimental)
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.FullParams.html
Enables experimental token-level timestamps. Defaults to false.
```rust
pub fn set_token_timestamps(&mut self, token_timestamps: bool)
```
--------------------------------
### Get VAD Probabilities
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperVadContext.html
Retrieves the array of speech probabilities detected by the VAD. The use of this method is currently undocumented.
```rust
pub fn probabilities(&self) -> &[f32]
```
--------------------------------
### FullParams::set_audio_ctx
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.FullParams.html
EXPERIMENTAL: Overwrites the audio context size. 0 means default. Defaults to 0.
```APIDOC
## FullParams::set_audio_ctx
### Description
##### §EXPERIMENTAL
Overwrite the audio context size. 0 = default.
Defaults to 0.
### Method
`pub fn set_audio_ctx(&mut self, audio_ctx: c_int)`
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
- **audio_ctx** (c_int) - The audio context size to set.
### Request Example
None
### Response
#### Success Response
None
#### Response Example
None
```
--------------------------------
### C++ Equivalent for full_with_state
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperState.html
This snippet shows the C++ equivalent function signature for processing audio with a whisper context and state, returning the number of generated text segments.
```cpp
int whisper_full_with_state(struct whisper_context * ctx, struct whisper_state * state, struct whisper_full_params params, const float * samples, int n_samples)
```
--------------------------------
### Get Token Data
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperToken.html
Retrieves the associated data for a Whisper token. This can provide additional context or information about the token.
```rust
pub fn token_data(&self) -> WhisperTokenData
```
--------------------------------
### Get Specific Token from Segment
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperSegment.html
Retrieves a `WhisperToken` at a specified index within the segment. Returns `None` if the index is out of bounds.
```rust
pub fn get_token(&self, token: c_int) -> Option>
```
--------------------------------
### Get Token Probability
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperToken.html
Retrieves the probability associated with a Whisper token. This indicates how likely the token is to appear in the given context.
```rust
pub fn token_probability(&self) -> f32
```
--------------------------------
### WhisperContext::new_with_params
Source: https://docs.rs/whisper-rs/latest/whisper_rs/index.html
Creates a new WhisperContext with specified parameters. This is the initial step for setting up the transcription pipeline.
```APIDOC
## WhisperContext::new_with_params
### Description
Creates a new `WhisperContext` with specified parameters. This is the initial step for setting up the transcription pipeline.
### Method
(Not specified, likely a constructor or associated function)
### Endpoint
(Not applicable, this is an SDK function)
### Parameters
(Specific parameters not detailed in the source, but `WhisperContextParameters` is mentioned as relevant)
### Request Example
(Not applicable)
### Response
#### Success Response
- **WhisperContext**: A new instance of `WhisperContext`.
#### Response Example
(Not applicable)
```
--------------------------------
### Get Token ID
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperToken.html
Retrieves the unique identifier for a Whisper token within its segment. This is useful for tracking specific tokens.
```rust
pub fn token_id(&self) -> WhisperTokenId
```
--------------------------------
### set_start_encoder_callback
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.FullParams.html
Sets a callback that is invoked before the encoder begins processing. This is an unsafe C-style callback and requires careful consideration to avoid undefined behavior.
```APIDOC
## pub unsafe fn set_start_encoder_callback(&mut self, start_encoder_callback: WhisperStartEncoderCallback)
### Description
Set the callback that is called each time before the encoder begins.
Note that this callback has not been Rustified yet. It is still a C callback.
### Safety
Do not use this function unless you know what you are doing. Be careful not to mutate the state of the whisper_context pointer returned in the callback. This could cause undefined behavior, as this violates the thread-safety guarantees of the underlying C library.
### Parameters
* `start_encoder_callback` (WhisperStartEncoderCallback) - The callback function to be set.
```
--------------------------------
### Configure GPU Usage
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperContextParameters.html
Sets whether to use the GPU if available for processing.
```rust
pub fn use_gpu(&mut self, use_gpu: bool) -> &mut Self
```
--------------------------------
### C++ Equivalent for full_lang_id_from_state
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperState.html
This snippet shows the C++ equivalent function signature for getting the language ID associated with a whisper state.
```cpp
int whisper_full_lang_id_from_state(struct whisper_state * state);
```
--------------------------------
### Get Maximum Language ID
Source: https://docs.rs/whisper-rs/latest/whisper_rs/fn.get_lang_max_id.html
Returns the ID of the maximum language. This is equivalent to the total number of supported languages minus one.
```rust
pub fn get_lang_max_id() -> i32
```
--------------------------------
### WhisperState::full
Source: https://docs.rs/whisper-rs/latest/whisper_rs/index.html
Runs the full transcription pipeline using a `WhisperState`. This is the primary method for obtaining transcription results.
```APIDOC
## WhisperState::full
### Description
Runs the full transcription pipeline using a `WhisperState`. This is the primary method for obtaining transcription results.
### Method
(Not specified, likely a method on `WhisperState`)
### Endpoint
(Not applicable, this is an SDK function)
### Parameters
(Specific parameters for the transcription process, such as audio data and potentially `FullParams`, are implied but not explicitly detailed in the source)
### Request Example
(Not applicable)
### Response
#### Success Response
- **WhisperSegment**: A collection of transcribed segments.
#### Response Example
(Not applicable)
```
--------------------------------
### Rust Function Signature: print_system_info
Source: https://docs.rs/whisper-rs/latest/whisper_rs/fn.print_system_info.html
This is the Rust signature for the `print_system_info` function. It returns a static string slice containing system information.
```rust
pub fn print_system_info() -> &'static str
```
--------------------------------
### Get Model Type Readable
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperContext.html
Attempts to retrieve a human-readable string describing the model type. This function is exposed but undocumented in the C++ API.
```rust
pub fn model_type_readable_bytes(&self) -> Result<&[u8], WhisperError>
```
--------------------------------
### Run Full VAD Pipeline on Samples
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperVadContext.html
Executes the complete VAD pipeline, including speech detection and probability processing, directly on audio samples. This method internally calls `Self::detect_speech` and `Self::segments_from_probabilities`. The sole possible error is `WhisperError::NullPointer`.
```rust
pub fn segments_from_samples( &mut self, params: WhisperVadParams, samples: &[f32], ) -> Result
```
--------------------------------
### Get Raw Segment Bytes
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperSegment.html
Retrieves the raw byte representation of the segment's text content. Returns `WhisperError::NullPointer` on failure.
```rust
pub fn to_bytes(&self) -> Result<&'a [u8], WhisperError>
```
--------------------------------
### WhisperContext::new_with_params
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperContext.html
Creates a new WhisperContext from a file path with specified parameters. This is the primary way to load a model from disk.
```APIDOC
## WhisperContext::new_with_params
### Description
Creates a new WhisperContext from a file, with parameters.
### Method
`new_with_params`
### Parameters
#### Path Parameters
- **path** (P: AsRef) - Required - The path to the model file.
- **parameters** (WhisperContextParameters<'_>) - Required - A parameter struct containing the parameters to use.
#### Returns
- `Result` - Ok(Self) on success, Err(WhisperError) on failure.
### C++ Equivalent
`struct whisper_context * whisper_init_from_file_with_params_no_state(const char * path_model, struct whisper_context_params params);`
```
--------------------------------
### Get Model Mel Count
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperContext.html
Returns the number of mel spectrogram bins the model uses. This is a parameter related to the audio feature extraction process.
```rust
pub fn model_n_mels(&self) -> c_int
```
--------------------------------
### full
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperState.html
Executes the complete Whisper processing pipeline, from raw PCM audio to text output. This method encompasses PCM to mel spectrogram conversion, encoding, decoding, and text generation using specified parameters. It is intended as the primary function for end-users.
```APIDOC
## full
### Description
Run the entire model: PCM -> log mel spectrogram -> encoder -> decoder -> text Uses the specified decoding strategy to obtain the text. This is usually the only function you need to call as an end user.
### Method
`pub fn full(&mut self, params: FullParams<'_, '_>, data: &[f32]) -> Result<(), WhisperError>`
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Arguments
* `params`: FullParams struct containing decoding strategy and other parameters.
* `data`: The raw PCM audio data.
### Returns
`Ok(())` on success, `Err(WhisperError)` on failure.
### Note
This is usually the only function you need to call as an end user.
```
--------------------------------
### WhisperStartEncoderCallback
Source: https://docs.rs/whisper-rs/latest/whisper_rs/type.WhisperStartEncoderCallback.html
Represents a callback function that is invoked when the encoder begins. It can either be None or a Some variant containing a C-style function pointer.
```APIDOC
## Type Alias WhisperStartEncoderCallback
```
pub type WhisperStartEncoderCallback = whisper_encoder_begin_callback;
```
## Aliased Type
```
pub enum WhisperStartEncoderCallback {
None,
Some(unsafe extern "C" fn(*mut whisper_context, *mut whisper_state, *mut c_void) -> bool),
}
```
### Variants
#### None
No value.
#### Some(unsafe extern "C" fn(*mut whisper_context, *mut whisper_state, *mut c_void) -> bool)
Some value of type `T`.
```
--------------------------------
### FullParams::set_tdrz_enable
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.FullParams.html
EXPERIMENTAL: Enables tinydiarize support for experimental speaker turn detection. Defaults to false.
```APIDOC
## FullParams::set_tdrz_enable
### Description
##### §EXPERIMENTAL
Enable tinydiarize support. Experimental speaker turn detection.
Defaults to false.
### Method
`pub fn set_tdrz_enable(&mut self, tdrz_enable: bool)`
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
- **tdrz_enable** (bool) - Whether to enable tinydiarize support.
### Request Example
None
### Response
#### Success Response
None
#### Response Example
None
```
--------------------------------
### Get Logits
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperState.html
Retrieves the logits generated from the last call to `WhisperState::decode`. As of whisper.cpp 1.4.1, this provides the logits for the last token in the input sequence.
```rust
pub fn get_logits(&self) -> Result<&[f32], WhisperError>
```
--------------------------------
### Enable Debug Mode (Experimental)
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.FullParams.html
Activates debug mode, which may include dumping the log mel spectrogram. Defaults to false.
```rust
pub fn set_debug_mode(&mut self, debug: bool)
```
--------------------------------
### Clone Implementation for DtwParameters
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.DtwParameters.html
Allows creating a duplicate of a DtwParameters instance. This is useful for passing configurations around without modifying the original.
```rust
fn clone(&self) -> DtwParameters<'a>
```
--------------------------------
### Get Specific Token Unchecked
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperSegment.html
Retrieves a `WhisperToken` at a specified index without bounds checking. This is unsafe and requires the caller to ensure the index is valid.
```rust
pub unsafe fn get_token_unchecked(&self, token: c_int) -> WhisperToken<'_, '_>
```
--------------------------------
### Get Full Language String by ID
Source: https://docs.rs/whisper-rs/latest/whisper_rs/fn.get_lang_str_full.html
Retrieves the full string name of a language using its integer ID. Returns None if the ID is not found.
```rust
pub fn get_lang_str_full(id: i32) -> Option<&'static str>
```
--------------------------------
### Get Model Text Layer Count
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperContext.html
Retrieves the number of layers in the text processing part of the model. This indicates the depth of the text generation or understanding capabilities.
```rust
pub fn model_n_text_layer(&self) -> c_int
```
--------------------------------
### product
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperStateSegmentIterator.html
Calculates the product of all elements in the iterator. The element type must implement `Product`.
```APIDOC
## fn product(self) -> P
where Self: Sized, P: Product,
### Description
Iterates over the entire iterator, multiplying all the elements.
### Type Parameters
- **P**: The type of the product, must implement `Product` for the iterator's item type.
```
--------------------------------
### print_timings
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperContext.html
Prints performance statistics to stderr.
```APIDOC
## pub fn print_timings(&self)
### Description
Prints detailed performance statistics and timing information related to the Whisper context operations to the standard error stream (stderr).
### C++ Equivalent
`void whisper_print_timings(struct whisper_context * ctx);`
```
--------------------------------
### Overwrite Audio Context Size (Experimental)
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.FullParams.html
Allows overwriting the audio context size. A value of 0 uses the default. Defaults to 0.
```rust
pub fn set_audio_ctx(&mut self, audio_ctx: c_int)
```
--------------------------------
### convert_stereo_to_mono_audio
Source: https://docs.rs/whisper-rs/latest/whisper_rs/index.html
Converts 32-bit floating-point stereo PCM audio to 32-bit floating-point mono PCM audio.
```APIDOC
## convert_stereo_to_mono_audio
### Description
Converts 32-bit floating-point stereo PCM audio to 32-bit floating-point mono PCM audio.
### Method
(Not specified, likely a free function)
### Endpoint
(Not applicable, this is an SDK function)
### Parameters
- **stereo_audio**: (Input slice of f32) - The input stereo audio data.
### Request Example
(Not applicable)
### Response
#### Success Response
- **Vec**: A vector of 32-bit float mono audio samples.
#### Response Example
(Not applicable)
```
--------------------------------
### FullParams::set_debug_mode
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.FullParams.html
EXPERIMENTAL: Enables debug mode, such as dumping the log mel spectrogram. Defaults to false.
```APIDOC
## FullParams::set_debug_mode
### Description
##### §EXPERIMENTAL
Enables debug mode, such as dumping the log mel spectrogram.
Defaults to false.
### Method
`pub fn set_debug_mode(&mut self, debug: bool)`
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
- **debug** (bool) - Whether to enable debug mode.
### Request Example
None
### Response
#### Success Response
None
#### Response Example
None
```
--------------------------------
### Get Raw Token Bytes
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperToken.html
Retrieves the raw byte representation of a Whisper token. This is useful for languages where tokens may not align with UTF-8 character boundaries.
```rust
pub fn to_bytes(&self) -> Result<&'b [u8], WhisperError>
```
--------------------------------
### TryInto Implementation
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.SegmentCallbackData.html
Attempts to convert a value into another type using a TryFrom implementation, returning a Result.
```rust
type Error = >::Error
```
```rust
fn try_into(self) -> Result>::Error>
```
--------------------------------
### Get Model Text State Size
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperContext.html
Retrieves the size of the internal text state maintained by the model. This relates to the model's memory for text generation or processing.
```rust
pub fn model_n_text_state(&self) -> c_int
```
--------------------------------
### C++ Equivalent for full_n_segments
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperState.html
This snippet shows the C++ equivalent function signature for retrieving the number of generated text segments from a whisper context.
```cpp
int whisper_full_n_segments(struct whisper_context * ctx)
```
--------------------------------
### Get Model Audio Layer Count
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperContext.html
Retrieves the number of layers in the audio processing part of the model. More layers generally mean a more complex and potentially more capable model.
```rust
pub fn model_n_audio_layer(&self) -> c_int
```
--------------------------------
### from
Source: https://docs.rs/whisper-rs/latest/whisper_rs/enum.WhisperError.html
Creates a new instance of the type from the given argument. This is a generic conversion trait.
```APIDOC
## fn from(t: T) -> T
### Description
Returns the argument unchanged. This is part of the `From` trait implementation.
### Method
fn
### Parameters
#### Path Parameters
- **t** (T) - Required - The value to convert from.
### Returns
- T - The converted value.
```
--------------------------------
### convert_stereo_to_mono_audio
Source: https://docs.rs/whisper-rs/latest/whisper_rs/fn.convert_stereo_to_mono_audio.html
Converts 32-bit floating point stereo PCM audio to 32-bit floating point mono PCM audio. It takes an input slice of stereo samples and an output mutable slice for mono samples. Errors can occur if the input sample length is odd or if there's a mismatch between input and output lengths.
```APIDOC
## Function convert_stereo_to_mono_audio
### Description
Converts 32-bit floating point stereo PCM audio to 32-bit floating point mono PCM audio.
### Arguments
* `input` - The array of 32-bit floating point stereo PCM audio samples.
* `output` - An output place to write all the mono samples.
### Errors
* if `samples.len()` is odd (`WhisperError::HalfSampleMissing`)
* if `input.len() / 2 < samples.len()` (`WhisperError::InputOutputLengthMismatch`)
### Returns
A vector of 32-bit floating point mono PCM audio samples.
### Examples
```rust
let samples = [0.0f32; 1024];
let mut mono_samples = [0.0f32; 512];
convert_stereo_to_mono_audio(&samples, &mut mono_samples).expect("should be no half samples missing");
```
```
--------------------------------
### Get Segment Text as UTF-8 String
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperSegment.html
Retrieves the segment's text content as a UTF-8 validated string. Returns `WhisperError::NullPointer` or `WhisperError::InvalidUtf8` on failure.
```rust
pub fn to_str(&self) -> Result<&'a str, WhisperError>
```
--------------------------------
### TryFrom Implementation
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.SegmentCallbackData.html
Attempts to convert a value into another type, returning a Result indicating success or failure.
```rust
type Error = Infallible
```
```rust
fn try_from(value: U) -> Result>::Error>
```
--------------------------------
### Get Token Text (UTF-8 Validated)
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperToken.html
Retrieves the text of a Whisper token, ensuring it is valid UTF-8. Returns an error if the token data is invalid or a null pointer.
```rust
pub fn to_str(&self) -> Result<&'b str, WhisperError>
```
--------------------------------
### From Implementation
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.SegmentCallbackData.html
Converts a value into itself, returning the argument unchanged.
```rust
fn from(t: T) -> T
```
--------------------------------
### Get Language ID
Source: https://docs.rs/whisper-rs/latest/whisper_rs/fn.get_lang_id.html
Returns the integer ID for a given language string. Returns None if the language is not found. Panics if the language string contains a null byte.
```rust
pub fn get_lang_id(lang: &str) -> Option
```
--------------------------------
### WhisperVadParams Configuration Methods
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperVadParams.html
This snippet outlines the methods available for configuring WhisperVadParams, allowing users to customize VAD behavior for speech detection.
```APIDOC
## WhisperVadParams
Configuration for Voice Activity Detection in `whisper.cpp`.
### Methods
#### `new()`
Creates a new `WhisperVadParams` instance with default settings.
#### `set_threshold(threshold: f32)`
Sets the probability threshold for considering audio as speech. Probabilities above this value are classified as speech.
* **Default**: 0.5
#### `set_min_speech_duration(min_speech_duration: c_int)`
Sets the minimum duration (in milliseconds) for a valid speech segment. Segments shorter than this are discarded.
* **Default**: 250 milliseconds
#### `set_min_silence_duration(min_silence_duration: c_int)`
Sets the minimum duration (in milliseconds) of silence required to end a speech segment. Shorter silences are ignored.
* **Default**: 100 milliseconds
#### `set_max_speech_duration(max_speech_duration: f32)`
Sets the maximum duration (in seconds) for a speech segment before it's split. Segments longer than this will be split at silence points.
* **Default**: `f32::MAX`
#### `set_speech_pad(speech_pad: c_int)`
Sets the padding (in milliseconds) to add before and after speech segments to avoid cutting off edges.
* **Default**: 30 milliseconds
#### `set_samples_overlap(samples_overlap: f32)`
Sets the overlap (in seconds) between consecutive speech segments. This ensures smooth transitions.
* **Default**: 0.1 seconds
```
--------------------------------
### Initialize WhisperVadContext
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperVadContext.html
Creates a new instance of WhisperVadContext. This function requires the path to the model and VAD-specific parameters.
```rust
pub fn new( model_path: &str, params: WhisperVadContextParams, ) -> Result
```
--------------------------------
### Get Model Text Head Count
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperContext.html
Returns the number of attention heads in the text processing layers of the model. This affects how the model weighs different tokens during text generation.
```rust
pub fn model_n_text_head(&self) -> c_int
```
--------------------------------
### Get Segment Text as Lossy String
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperSegment.html
Retrieves the segment's text content, replacing invalid UTF-8 sequences with the replacement character. Returns `WhisperError::NullPointer` on failure.
```rust
pub fn to_str_lossy(&self) -> Result, WhisperError>
```
--------------------------------
### decode
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperState.html
Runs the Whisper decoder to generate logits and probabilities for the next token, based on the previously encoded spectrogram. It requires the sequence of tokens to decode, the number of tokens, and the number of past tokens to consider.
```APIDOC
## decode
### Description
Run the Whisper decoder to obtain the logits and probabilities for the next token. Make sure to call WhisperState::encode first. tokens + n_tokens is the provided context for the decoder.
### Method
`pub fn decode(&mut self, tokens: &[WhisperTokenId], n_past: usize, threads: usize) -> Result<(), WhisperError>`
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Arguments
* `tokens`: The tokens to decode.
* `n_tokens`: The number of tokens to decode.
* `n_past`: The number of past tokens to use for the decoding.
* `n_threads`: How many threads to use. Defaults to 1. Must be at least 1, returns an error otherwise.
### Returns
`Ok(())` on success, `Err(WhisperError)` on failure.
### C++ equivalent
`int whisper_decode(struct whisper_context * ctx, const whisper_token * tokens, int n_tokens, int n_past, int n_threads)`
```
--------------------------------
### Get Model Audio Head Count
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperContext.html
Returns the number of attention heads in the audio processing layers of the model. This impacts the model's ability to focus on different parts of the audio.
```rust
pub fn model_n_audio_head(&self) -> c_int
```
--------------------------------
### Set Print Realtime
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.FullParams.html
Enables printing results directly from whisper.cpp. It is recommended to use callback methods instead. Defaults to false.
```rust
pub fn set_print_realtime(&mut self, print_realtime: bool)
```
--------------------------------
### Get Token Text (Lossy UTF-8)
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperToken.html
Retrieves the text of a Whisper token, replacing invalid UTF-8 sequences with the replacement character. This method is useful for handling potentially malformed text.
```rust
pub fn to_str_lossy(&self) -> Result, WhisperError>
```
--------------------------------
### FullParams::set_translate
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.FullParams.html
Sets whether to translate the output. This only translates to English. Defaults to false.
```APIDOC
## FullParams::set_translate
### Description
Set whether to translate the output. This only translates to English.
Defaults to false.
### Method
`pub fn set_translate(&mut self, translate: bool)`
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
- **translate** (bool) - Whether to translate the output.
### Request Example
None
### Response
#### Success Response
None
#### Response Example
None
```
--------------------------------
### Set Duration to Process
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.FullParams.html
Sets the total duration of audio in milliseconds to be processed. Defaults to 0, which typically means processing the entire audio file.
```rust
pub fn set_duration_ms(&mut self, duration_ms: c_int)
```
--------------------------------
### Enable Flash Attention
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperContextParameters.html
Enables flash attention for potentially faster processing. Note: Cannot be used with DTW; DTW will be disabled if flash_attn is true.
```rust
pub fn flash_attn(&mut self, flash_attn: bool) -> &mut Self
```
--------------------------------
### Set Print Timestamps for Realtime
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.FullParams.html
Configures whether to print timestamps for each text segment when realtime printing is enabled. Only effective if `set_print_realtime` is true. Defaults to true.
```rust
pub fn set_print_timestamps(&mut self, print_timestamps: bool)
```
--------------------------------
### WhisperSegment Methods
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperSegment.html
This section details the methods available on the WhisperSegment struct for retrieving information about a transcribed audio segment.
```APIDOC
## WhisperSegment
A segment returned by Whisper after running the transcription pipeline.
### Methods
#### `segment_index(&self) -> c_int`
Get the index of this segment.
#### `start_timestamp(&self) -> i64`
Get the start time of the specified segment.
**Returns**: Start time in centiseconds (10s of milliseconds).
#### `end_timestamp(&self) -> i64`
Get the end time of the specified segment.
**Returns**: End time in centiseconds (10s of milliseconds).
#### `n_tokens(&self) -> c_int`
Get number of tokens in this segment.
**Returns**: `c_int`.
#### `next_segment_speaker_turn(&self) -> bool`
Get whether the next segment is predicted as a speaker turn.
**Returns**: `bool`.
#### `no_speech_probability(&self) -> f32`
Get the no_speech probability for the specified segment.
**Returns**: `f32`.
#### `to_bytes(&self) -> Result<&'a [u8], WhisperError>`
Get the raw bytes of this segment.
**Returns**:
* On success: The raw bytes, with no null terminator
* On failure: `WhisperError::NullPointer`
#### `to_str(&self) -> Result<&'a str, WhisperError>`
Get the text of this segment.
**Returns**:
* On success: the UTF-8 validated string.
* On failure: `WhisperError::NullPointer` or `WhisperError::InvalidUtf8`
#### `to_str_lossy(&self) -> Result, WhisperError>`
Get the text of this segment. This function differs from `Self::to_str` in that it ignores invalid UTF-8 in strings, and instead replaces it with the replacement character.
**Returns**:
* On success: The valid string, with any invalid UTF-8 replaced with the replacement character
* On failure: `WhisperError::NullPointer`
#### `get_token(&self, token: c_int) -> Option>`
Get the token at the specified index. Returns `None` if out of bounds for this state.
#### `get_token_unchecked(&self, token: c_int) -> WhisperToken<'_, '_>`
The same as `Self::get_token` but without any bounds check.
**Safety**: You must ensure `token` is in bounds for this `WhisperSegment`. If it is not, this is immediate Undefined Behaviour.
```
--------------------------------
### Set Print Progress
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.FullParams.html
Determines whether to print decoding progress updates. Defaults to true.
```rust
pub fn set_print_progress(&mut self, print_progress: bool)
```
--------------------------------
### FullParams::set_single_segment
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.FullParams.html
Forces single segment output, which may be useful for streaming. Defaults to false.
```APIDOC
## FullParams::set_single_segment
### Description
Force single segment output. This may be useful for streaming.
Defaults to false.
### Method
`pub fn set_single_segment(&mut self, single_segment: bool)`
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
- **single_segment** (bool) - Whether to force single segment output.
### Request Example
None
### Response
#### Success Response
None
#### Response Example
None
```
--------------------------------
### SystemInfo Struct Definition
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.SystemInfo.html
Defines the SystemInfo struct, which exposes boolean flags for CPU features such as AVX, AVX2, FMA, and F16C. This struct is used to programmatically access system hardware capabilities.
```rust
pub struct SystemInfo {
pub avx: bool,
pub avx2: bool,
pub fma: bool,
pub f16c: bool,
}
```
--------------------------------
### token_beg
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperContext.html
Retrieves the token ID for the beginning (beg) token.
```APIDOC
## pub fn token_beg(&self) -> WhisperTokenId
### Description
Returns the unique token ID designated as the beginning (beg) token.
### Returns
* `WhisperTokenId`: The ID of the beg token.
```
--------------------------------
### Generate Segments from Probabilities
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperVadContext.html
Completes the VAD pipeline using pre-computed probabilities and returns detailed segment information. The only expected error is `WhisperError::NullPointer`.
```rust
pub fn segments_from_probabilities( &mut self, params: WhisperVadParams, ) -> Result
```
--------------------------------
### Iterator - Intersperse (Nightly)
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperVadSegments.html
Creates an iterator that places a copy of a separator between items. This is a nightly-only experimental API.
```rust
fn intersperse(self, separator: Self::Item) -> Intersperse
where Self: Sized, Self::Item: Clone,
```
--------------------------------
### Iterator - Next Chunk (Nightly)
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperVadSegments.html
Advances the iterator and returns an array of the next N values. This is a nightly-only experimental API.
```rust
fn next_chunk( &mut self, ) -> Result<[Self::Item; N], IntoIter>
where Self: Sized,
```
--------------------------------
### set_mel
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperState.html
Allows setting a custom log mel spectrogram directly into the WhisperState. This is an alternative to `pcm_to_mel` for users who wish to provide their own pre-computed spectrogram data. It is considered a low-level function.
```APIDOC
## set_mel
### Description
This can be used to set a custom log mel spectrogram inside the provided whisper state. Use this instead of whisper_pcm_to_mel() if you want to provide your own log mel spectrogram.
### Method
`pub fn set_mel(&mut self, data: &[f32]) -> Result<(), WhisperError>`
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Arguments
* `data`: The log mel spectrogram.
### Returns
`Ok(())` on success, `Err(WhisperError)` on failure.
### Note
This is a low-level function. If you’re a typical user, you probably don’t want to use this function. See instead WhisperState::pcm_to_mel.
### C++ equivalent
`int whisper_set_mel(struct whisper_context * ctx, const float * data, int n_len, int n_mel)`
```
--------------------------------
### Set Speech Padding
Source: https://docs.rs/whisper-rs/latest/whisper_rs/struct.WhisperVadParams.html
Adds padding in milliseconds before and after speech segments to prevent cutting off edges. Defaults to 30ms.
```rust
pub fn set_speech_pad(&mut self, speech_pad: c_int)
```
--------------------------------
### Convert 16-bit Integer Audio Samples to 32-bit Float
Source: https://docs.rs/whisper-rs/latest/whisper_rs/fn.convert_integer_to_float_audio.html
Use this function to convert an array of 16-bit mono audio samples to a vector of 32-bit floats. Ensure that the input samples array and the output vector have the same length to avoid panics.
```rust
let samples = [0i16; 1024];
let mut output = vec![0.0f32; samples.len()];
convert_integer_to_float_audio(&samples, &mut output).expect("input and output lengths should be equal");
```