Skip to content

Commit

Permalink
style: fix lints
Browse files Browse the repository at this point in the history
  • Loading branch information
Bear-03 committed Oct 26, 2024
1 parent 0706303 commit 719b4a4
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion crates/vosk/src/gpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ pub fn gpu_init() {
/// Must be called for each thread.
pub fn gpu_thread_init() {
unsafe { vosk_sys::vosk_gpu_thread_init() }
}
}
6 changes: 4 additions & 2 deletions crates/vosk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
//! * Create a [`Recognizer`] with that model
//! * Feel audio to the recognizer with [`Recognizer::accept_waveform`]
//! * Get the processed result with [`Recognizer::result`],
//! [`Recognizer::partial_result`] or [`Recognizer::final_result`]
//! [`Recognizer::partial_result`] or [`Recognizer::final_result`]

#[cfg(feature = "batch")]
mod gpu;
mod log;
mod models;
mod recognition;

pub use crate::{log::*, models::*, recognition::{*, results::*}};
pub use crate::{log::*, models::*, recognition::*};
#[cfg(feature = "batch")]
pub use gpu::*;
2 changes: 1 addition & 1 deletion crates/vosk/src/models/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ impl Drop for BatchModel {
}

unsafe impl Send for BatchModel {}
unsafe impl Sync for BatchModel {}
unsafe impl Sync for BatchModel {}
2 changes: 1 addition & 1 deletion crates/vosk/src/models/sequential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@ impl Drop for SpeakerModel {
}

unsafe impl Send for SpeakerModel {}
unsafe impl Sync for SpeakerModel {}
unsafe impl Sync for SpeakerModel {}
16 changes: 5 additions & 11 deletions crates/vosk/src/recognition/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@ impl BatchRecognizer {
/// The recognizers process the speech and return text using shared model data.
///
/// * `model` - [`BatchModel`] containing static data for recognizer. Model can be shared
/// across recognizers, even running in different threads.
/// across recognizers, even running in different threads.
///
/// * `sample_rate` - The sample rate of the audio you going to feed into the recognizer.
/// Make sure this rate matches the audio content, it is a common issue causing accuracy problems.
/// Make sure this rate matches the audio content, it is a common issue causing accuracy problems.
///
/// [`BatchModel`]: crate::BatchModel
#[must_use]
pub fn new(model: &BatchModel, sample_rate: f32) -> Option<Self> {
let recognizer_ptr =
unsafe { vosk_batch_recognizer_new(model.0.as_ptr(), sample_rate) };
let recognizer_ptr = unsafe { vosk_batch_recognizer_new(model.0.as_ptr(), sample_rate) };
Some(Self(NonNull::new(recognizer_ptr)?))
}

Expand All @@ -37,11 +36,7 @@ impl BatchRecognizer {
/// * `data` - Audio data in PCM 16-bit mono format as an array of i8.
pub fn accept_waveform(&mut self, data: &[i8]) {
unsafe {
vosk_batch_recognizer_accept_waveform(
self.0.as_ptr(),
data.as_ptr(),
data.len() as i32,
)
vosk_batch_recognizer_accept_waveform(self.0.as_ptr(), data.as_ptr(), data.len() as i32)
};
}

Expand Down Expand Up @@ -76,9 +71,8 @@ unsafe impl Send for BatchRecognizer {}
// which ensures exclusive access, so it is Sync
unsafe impl Sync for BatchRecognizer {}


impl Drop for BatchRecognizer {
fn drop(&mut self) {
unsafe { vosk_batch_recognizer_free(self.0.as_ptr()) }
}
}
}
5 changes: 3 additions & 2 deletions crates/vosk/src/recognition/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ use std::os::raw::c_int;

#[cfg(feature = "batch")]
mod batch;
mod results;
mod sequential;
pub mod results;

#[cfg(feature = "batch")]
pub use batch::BatchRecognizer;
pub use results::*;
pub use sequential::Recognizer;

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
Expand All @@ -29,4 +30,4 @@ impl DecodingState {
_ => Self::Failed,
}
}
}
}
19 changes: 11 additions & 8 deletions crates/vosk/src/recognition/sequential.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use super::{
results::{CompleteResult, PartialResult},
DecodingState,
};
use crate::models::{Model, SpeakerModel};
use super::{DecodingState, results::{CompleteResult, PartialResult}};

use serde::Deserialize;
use std::{
Expand All @@ -21,10 +24,10 @@ impl Recognizer {
/// The recognizers process the speech and return text using shared model data.
///
/// * `model` - [`Model`] containing static data for recognizer. Model can be shared
/// across recognizers, even running in different threads.
/// across recognizers, even running in different threads.
///
/// * `sample_rate` - The sample rate of the audio you going to feed into the recognizer.
/// Make sure this rate matches the audio content, it is a common issue causing accuracy problems.
/// Make sure this rate matches the audio content, it is a common issue causing accuracy problems.
///
/// [`Model`]: crate::Model
#[must_use]
Expand All @@ -39,11 +42,11 @@ impl Recognizer {
/// text but also return speaker vectors one can use for speaker identification
///
/// * `model` - [`Model`] containing the data for recognizer. Model can be
/// shared across recognizers, even running in different threads.
/// shared across recognizers, even running in different threads.
///
/// * `sample_rate` - The sample rate of the audio you going to feed into the recognizer.
/// Make sure this rate matches the audio content, it is a common
/// issue causing accuracy problems.
/// Make sure this rate matches the audio content, it is a common
/// issue causing accuracy problems.
///
/// * `spk_model` - Speaker model for speaker identification.
///
Expand Down Expand Up @@ -73,10 +76,10 @@ impl Recognizer {
/// Precompiled HCLG graph models are not supported.
///
/// * `model` - [`Model`] containing the data for recognizer. Model can be shared
/// across recognizers, even running in different threads.
/// across recognizers, even running in different threads.
///
/// * `sample_rate` - The sample rate of the audio you going to feed into the recognizer.
/// Make sure this rate matches the audio content, it is a common issue causing accuracy problems.
/// Make sure this rate matches the audio content, it is a common issue causing accuracy problems.
///
/// * `grammar` - The list of phrases to recognize.
///
Expand Down

0 comments on commit 719b4a4

Please sign in to comment.