calculate mel.n_len as mel spectrogram stride len
This commit is contained in:
parent
ba0cde2ea3
commit
fcb477cc5e
1 changed files with 3 additions and 1 deletions
|
|
@ -123,12 +123,14 @@ impl<'a> WhisperState<'a> {
|
||||||
/// # C++ equivalent
|
/// # C++ equivalent
|
||||||
/// `int whisper_set_mel(struct whisper_context * ctx, const float * data, int n_len, int n_mel)`
|
/// `int whisper_set_mel(struct whisper_context * ctx, const float * data, int n_len, int n_mel)`
|
||||||
pub fn set_mel(&mut self, data: &[f32]) -> Result<(), WhisperError> {
|
pub fn set_mel(&mut self, data: &[f32]) -> Result<(), WhisperError> {
|
||||||
|
let hop_size = 160;
|
||||||
|
let n_len = (data.len() / hop_size) * 2;
|
||||||
let ret = unsafe {
|
let ret = unsafe {
|
||||||
whisper_rs_sys::whisper_set_mel_with_state(
|
whisper_rs_sys::whisper_set_mel_with_state(
|
||||||
self.ctx,
|
self.ctx,
|
||||||
self.ptr,
|
self.ptr,
|
||||||
data.as_ptr(),
|
data.as_ptr(),
|
||||||
data.len() as c_int,
|
n_len as c_int,
|
||||||
80 as c_int,
|
80 as c_int,
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue