add whisper_full_get_token_data

This commit is contained in:
0/0 2022-12-14 17:10:53 -07:00
parent eda8559cc8
commit cc05ecfd42
No known key found for this signature in database
GPG Key ID: 3861E636EA1E0E2B

View File

@ -502,21 +502,28 @@ impl WhisperContext {
/// * token: Token index. /// * token: Token index.
/// ///
/// # Returns /// # Returns
/// Ok(WhisperToken) on success, Err(WhisperError) on failure. /// [crate::WhisperToken]
/// ///
/// # C++ equivalent /// # C++ equivalent
/// `whisper_token whisper_full_get_token_id (struct whisper_context * ctx, int i_segment, int i_token)` /// `whisper_token whisper_full_get_token_id (struct whisper_context * ctx, int i_segment, int i_token)`
pub fn full_get_token_id( pub fn full_get_token_id(&self, segment: c_int, token: c_int) -> WhisperToken {
&self, unsafe { whisper_rs_sys::whisper_full_get_token_id(self.ctx, segment, token) }
segment: c_int, }
token: c_int,
) -> Result<WhisperToken, WhisperError> { /// Get token data for the specified token in the specified segment.
let ret = unsafe { whisper_rs_sys::whisper_full_get_token_id(self.ctx, segment, token) }; ///
if ret < 0 { /// # Arguments
Err(WhisperError::GenericError(ret)) /// * segment: Segment index.
} else { /// * token: Token index.
Ok(ret as WhisperToken) ///
} /// # Returns
/// [crate::WhisperTokenData]
///
/// # C++ equivalent
/// `whisper_token_data whisper_full_get_token_data(struct whisper_context * ctx, int i_segment, int i_token)`
#[inline]
pub fn full_get_token_data(&self, segment: c_int, token: c_int) -> WhisperTokenData {
unsafe { whisper_rs_sys::whisper_full_get_token_data(self.ctx, segment, token) }
} }
/// Get the probability of the specified token in the specified segment. /// Get the probability of the specified token in the specified segment.