remove useless error handling
This commit is contained in:
parent
462f6c7b13
commit
b4459e5e53
1 changed files with 16 additions and 32 deletions
|
|
@ -222,49 +222,37 @@ impl WhisperContext {
|
||||||
/// Get the mel spectrogram length.
|
/// Get the mel spectrogram length.
|
||||||
///
|
///
|
||||||
/// # Returns
|
/// # Returns
|
||||||
/// Ok(c_int) on success, Err(WhisperError) on failure.
|
/// c_int
|
||||||
///
|
///
|
||||||
/// # C++ equivalent
|
/// # C++ equivalent
|
||||||
/// `int whisper_n_len (struct whisper_context * ctx)`
|
/// `int whisper_n_len (struct whisper_context * ctx)`
|
||||||
pub fn n_len(&self) -> Result<c_int, WhisperError> {
|
#[inline]
|
||||||
let ret = unsafe { whisper_rs_sys::whisper_n_len(self.ctx) };
|
pub fn n_len(&self) -> c_int {
|
||||||
if ret < 0 {
|
unsafe { whisper_rs_sys::whisper_n_len(self.ctx) }
|
||||||
Err(WhisperError::GenericError(ret))
|
|
||||||
} else {
|
|
||||||
Ok(ret as c_int)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get n_vocab.
|
/// Get n_vocab.
|
||||||
///
|
///
|
||||||
/// # Returns
|
/// # Returns
|
||||||
/// Ok(c_int) on success, Err(WhisperError) on failure.
|
/// c_int
|
||||||
///
|
///
|
||||||
/// # C++ equivalent
|
/// # C++ equivalent
|
||||||
/// `int whisper_n_vocab (struct whisper_context * ctx)`
|
/// `int whisper_n_vocab (struct whisper_context * ctx)`
|
||||||
pub fn n_vocab(&self) -> Result<c_int, WhisperError> {
|
#[inline]
|
||||||
let ret = unsafe { whisper_rs_sys::whisper_n_vocab(self.ctx) };
|
pub fn n_vocab(&self) -> c_int {
|
||||||
if ret < 0 {
|
unsafe { whisper_rs_sys::whisper_n_vocab(self.ctx) }
|
||||||
Err(WhisperError::GenericError(ret))
|
|
||||||
} else {
|
|
||||||
Ok(ret as c_int)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get n_text_ctx.
|
/// Get n_text_ctx.
|
||||||
///
|
///
|
||||||
/// # Returns
|
/// # Returns
|
||||||
/// Ok(c_int) on success, Err(WhisperError) on failure.
|
/// c_int
|
||||||
///
|
///
|
||||||
/// # C++ equivalent
|
/// # C++ equivalent
|
||||||
/// `int whisper_n_text_ctx (struct whisper_context * ctx)`
|
/// `int whisper_n_text_ctx (struct whisper_context * ctx)`
|
||||||
pub fn n_text_ctx(&self) -> Result<c_int, WhisperError> {
|
#[inline]
|
||||||
let ret = unsafe { whisper_rs_sys::whisper_n_text_ctx(self.ctx) };
|
pub fn n_text_ctx(&self) -> c_int {
|
||||||
if ret < 0 {
|
unsafe { whisper_rs_sys::whisper_n_text_ctx(self.ctx) }
|
||||||
Err(WhisperError::GenericError(ret))
|
|
||||||
} else {
|
|
||||||
Ok(ret as c_int)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Does this model support multiple languages?
|
/// Does this model support multiple languages?
|
||||||
|
|
@ -453,17 +441,13 @@ impl WhisperContext {
|
||||||
/// * segment: Segment index.
|
/// * segment: Segment index.
|
||||||
///
|
///
|
||||||
/// # Returns
|
/// # Returns
|
||||||
/// Ok(c_int) on success, Err(WhisperError) on failure.
|
/// c_int
|
||||||
///
|
///
|
||||||
/// # C++ equivalent
|
/// # C++ equivalent
|
||||||
/// `int whisper_full_n_tokens(struct whisper_context * ctx, int i_segment)`
|
/// `int whisper_full_n_tokens(struct whisper_context * ctx, int i_segment)`
|
||||||
pub fn full_n_tokens(&self, segment: c_int) -> Result<c_int, WhisperError> {
|
#[inline]
|
||||||
let ret = unsafe { whisper_rs_sys::whisper_full_n_tokens(self.ctx, segment) };
|
pub fn full_n_tokens(&self, segment: c_int) -> c_int {
|
||||||
if ret < 0 {
|
unsafe { whisper_rs_sys::whisper_full_n_tokens(self.ctx, segment) }
|
||||||
Err(WhisperError::GenericError(ret))
|
|
||||||
} else {
|
|
||||||
Ok(ret as c_int)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the token text of the specified token in the specified segment.
|
/// Get the token text of the specified token in the specified segment.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue