Skip to content

Commit 8e5653a

Browse files
committed
fix: all lint
1 parent 2bd95be commit 8e5653a

File tree

19 files changed

+376
-367
lines changed

19 files changed

+376
-367
lines changed

Cargo.lock

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ members = [
2222
"apps/whisper-api",
2323
"apps/whisper-realtime",
2424
]
25+
lints = { clippy = { nursery = {level = "warn", priority = -1}, pedantic = { level = "warn", priority = -1 }, missing_errors_doc = "allow", module_name_repetitions = "allow", unused_async = "allow", cast_precision_loss = "allow", cast_sign_loss = "allow", cast_possible_truncation = "allow", unused_self = "allow"}}
2526

2627
[profile.dev]
2728
opt-level = 1

apps/orpheus-tts/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,6 @@ cuda = [
2929
"candle-nn/cuda",
3030
"candle-transformers/cuda"
3131
]
32+
33+
[lints]
34+
workspace = true

apps/silero-vad-lite-whisper-realtime-ort/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ crossbeam-channel = "0.5.15"
2121
tokenizers = "0.21.2"
2222
ndarray = "0.16.1"
2323
serde = { version = "1.0.219", features = ["derive"] }
24-
lazy_static = "1.5.0"
2524
rustfft = "6.4.0"
2625
ndarray-stats = "0.6.0"
2726
log = "0.4.27"
@@ -34,3 +33,6 @@ ort = { version = "2.0.0-rc.10", features = ["ndarray", "directml", "cuda"] }
3433

3534
[target.'cfg(target_os = "linux")'.dependencies]
3635
ort = { version = "2.0.0-rc.10", features = ["ndarray", "cuda"] }
36+
37+
[lints]
38+
workspace = true

apps/silero-vad-lite-whisper-realtime-ort/src/main.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ async fn process_audio_chunk(
7979
chunk: Vec<f32>,
8080
sample_rate: u32,
8181
) -> Result<()> {
82-
frame_buffer.extend_from_slice(&chunk);
83-
8482
// Silero VAD works with specific frame sizes. 512 is a good choice for 16kHz audio.
8583
const VAD_FRAME_SIZE: usize = 512;
8684

85+
frame_buffer.extend_from_slice(&chunk);
86+
8787
while frame_buffer.len() >= VAD_FRAME_SIZE {
8888
let frame: Vec<f32> = frame_buffer.drain(..VAD_FRAME_SIZE).collect();
8989

@@ -92,14 +92,14 @@ async fn process_audio_chunk(
9292
let is_speech = vad.is_speech(speech_prob);
9393

9494
// Add the frame to the audio buffer and check if a full utterance is ready
95-
if let Some(complete_audio) = audio_buffer.add_chunk(&frame, is_speech) {
96-
if !complete_audio.is_empty() {
97-
// For debugging, you can save the audio chunk
98-
// ... (your save_audio_chunk_to_file logic can go here)
99-
100-
// Transcribe the complete audio utterance
101-
transcribe_audio(whisper, complete_audio, sample_rate).await?;
102-
}
95+
if let Some(complete_audio) = audio_buffer.add_chunk(&frame, is_speech)
96+
&& !complete_audio.is_empty()
97+
{
98+
// For debugging, you can save the audio chunk
99+
// ... (your save_audio_chunk_to_file logic can go here)
100+
101+
// Transcribe the complete audio utterance
102+
transcribe_audio(whisper, complete_audio, sample_rate).await?;
103103
}
104104
}
105105

apps/silero-vad-lite-whisper-realtime-ort/src/vad.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl SileroVADModel {
4545
None => repo.download(model_path_sub_name)?,
4646
};
4747

48-
let session = Self::create_optimized_session(model_path.clone())?;
48+
let session = Self::create_optimized_session(model_path)?;
4949

5050
Ok(Self { session: Arc::new(Mutex::new(session)) })
5151
}
@@ -75,17 +75,18 @@ impl SileroVADModel {
7575

7676
/// Stateless inference that matches JavaScript interface
7777
/// Returns both output and updated state like the JS version
78+
#[allow(clippy::significant_drop_tightening)]
7879
pub fn inference(
7980
&self,
8081
input_data: SileroVADInput,
8182
) -> Result<SileroVADResult> {
8283
// Validate input dimensions
83-
if input_data.state.len() != 2 * 1 * 128 {
84+
if input_data.state.len() != 2 * 128 {
8485
return Err(anyhow::anyhow!("State must have 256 elements (2*1*128), got {}", input_data.state.len()));
8586
}
8687

8788
// Create input tensors for the ONNX model
88-
let inputs = vec![("input", Tensor::from_array((vec![1, input_data.input.len()], input_data.input.clone()))?.into_dyn()), ("sr", Tensor::from_array(([1], vec![input_data.sr]))?.into_dyn()), ("state", Tensor::from_array((vec![2, 1, 128], input_data.state.clone()))?.into_dyn())];
89+
let inputs = vec![("input", Tensor::from_array((vec![1, input_data.input.len()], input_data.input.clone()))?.into_dyn()), ("sr", Tensor::from_array(([1], vec![input_data.sr]))?.into_dyn()), ("state", Tensor::from_array((vec![2, 1, 128], input_data.state))?.into_dyn())];
8990

9091
// Run inference and extract data while session is still locked
9192
let (state_data, speech_data) = {
@@ -127,7 +128,7 @@ impl SileroVADPipeline {
127128
) -> Result<Self> {
128129
let model = SileroVADModel::new()?;
129130
// The initial state for the Silero VAD model is a tensor of shape (2, 1, 128) filled with zeros.
130-
let state = vec![0.0; 2 * 1 * 128];
131+
let state = vec![0.0; 2 * 128];
131132
Ok(Self { model, state, sample_rate: i64::from(sample_rate), threshold })
132133
}
133134

0 commit comments

Comments
 (0)