Skip to content
This repository has been archived by the owner on Mar 5, 2022. It is now read-only.

Commit

Permalink
Add APIs added by the new upstream release
Browse files Browse the repository at this point in the history
Adds DS_DisableExternalScorer, DS_GetModelBeamWidth,
DS_SetModelBeamWidth, DS_SetScorerAlphaBeta bindings
added by the v0.7.0-alpha.2 upstream release.
  • Loading branch information
est31 committed Feb 24, 2020
1 parent df055b6 commit d40087d
Showing 1 changed file with 42 additions and 1 deletion.
43 changes: 42 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,51 @@ impl Model {
}
}

/// Disable decoding using an external scorer
pub fn disable_external_scorer(&mut self) -> Result<(), ()> {
let ret = unsafe {
ds::DS_DisableExternalScorer(self.model)
};
if ret != 0 {
Err(())
} else {
Ok(())
}
}

/// Get sample rate expected by a model
pub fn get_sample_rate(&mut self) -> i32 {
unsafe {
ds::DS_GetModelSampleRate(self.model)
ds::DS_GetModelSampleRate(self.model) as _
}
}

pub fn get_model_beam_width(&mut self) -> u16 {
unsafe {
ds::DS_GetModelBeamWidth(self.model) as _
}
}

pub fn set_model_beam_width(&mut self, bw :u16) -> Result<(), ()> {
let ret = unsafe {
ds::DS_SetModelBeamWidth(self.model, bw as _)
};
if ret != 0 {
Err(())
} else {
Ok(())
}
}

/// Set hyperparameters alpha and beta of the external scorer
pub fn set_scorer_alpha_beta(&mut self, alpha :f32, beta :f32) -> Result<(), ()> {
let ret = unsafe {
ds::DS_SetScorerAlphaBeta(self.model, alpha, beta)
};
if ret != 0 {
Err(())
} else {
Ok(())
}
}

Expand Down

0 comments on commit d40087d

Please sign in to comment.