diff --git a/src/whisper_ctx.rs b/src/whisper_ctx.rs index 954f157..9553702 100644 --- a/src/whisper_ctx.rs +++ b/src/whisper_ctx.rs @@ -306,14 +306,14 @@ impl WhisperContext { /// * token_id: ID of the token. /// /// # Returns - /// Ok(String) on success, Err(WhisperError) on failure. + /// Ok(&str) on success, Err(WhisperError) on failure. /// /// # C++ equivalent /// `const char * whisper_token_to_str(struct whisper_context * ctx, whisper_token token)` - pub fn token_to_str(&self, token_id: WhisperToken) -> Result { + pub fn token_to_str(&self, token_id: WhisperToken) -> Result<&str, WhisperError> { let c_str = self.token_to_cstr(token_id)?; let r_str = c_str.to_str()?; - Ok(r_str.to_string()) + Ok(r_str) } /// Convert a token ID to a &CStr.