Skip to content

Commit faea950

Browse files
committed
feat: stream whisper-asr
1 parent d6a9608 commit faea950

5 files changed

Lines changed: 316 additions & 155 deletions

File tree

src/config.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,16 @@ pub enum TTSConfig {
244244

245245
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
246246
pub struct SileroVadconfig {
247+
#[serde(default = "SileroVadconfig::default_threshold")]
247248
pub threshold: f32,
249+
#[serde(default = "SileroVadconfig::default_neg_threshold")]
248250
pub neg_threshold: Option<f32>,
249-
251+
#[serde(default = "SileroVadconfig::default_min_speech_duration_ms")]
250252
pub min_speech_duration_ms: usize,
253+
#[serde(default = "SileroVadconfig::default_max_silence_duration_ms")]
251254
pub max_silence_duration_ms: usize,
252-
pub audio_cache_ms: usize,
255+
#[serde(default = "SileroVadconfig::hangover_ms")]
256+
pub hangover_ms: usize,
253257
}
254258

255259
impl SileroVadconfig {
@@ -262,15 +266,15 @@ impl SileroVadconfig {
262266
}
263267

264268
pub fn default_min_speech_duration_ms() -> usize {
265-
150
269+
400
266270
}
267271

268272
pub fn default_max_silence_duration_ms() -> usize {
269-
400
273+
200
270274
}
271275

272-
pub fn default_audio_cache_ms() -> usize {
273-
1000
276+
pub fn hangover_ms() -> usize {
277+
500
274278
}
275279
}
276280

@@ -281,7 +285,7 @@ impl Default for SileroVadconfig {
281285
neg_threshold: Self::default_neg_threshold(),
282286
min_speech_duration_ms: Self::default_min_speech_duration_ms(),
283287
max_silence_duration_ms: Self::default_max_silence_duration_ms(),
284-
audio_cache_ms: Self::default_audio_cache_ms(),
288+
hangover_ms: Self::hangover_ms(),
285289
}
286290
}
287291
}

src/services/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use axum::{
77
};
88

99
pub mod file;
10+
#[deprecated]
1011
pub mod realtime_ws;
1112
pub mod ws;
1213
pub mod ws_record;
@@ -22,7 +23,7 @@ pub struct ConnectQueryParams {
2223
#[serde(default)]
2324
vowel: bool,
2425
#[serde(default)]
25-
server_vad: bool,
26+
stream_asr: bool,
2627
}
2728

2829
pub async fn v2_mixed_handler(
@@ -45,7 +46,7 @@ pub async fn v2_mixed_handler(
4546
reconnect: params.reconnect,
4647
opus: params.opus,
4748
vowel: params.vowel,
48-
server_vad: params.server_vad,
49+
stream_asr: params.stream_asr,
4950
}),
5051
)
5152
.await

src/services/ws.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ pub struct ConnectQueryParams {
6767
#[serde(default)]
6868
pub vowel: bool,
6969
#[serde(default)]
70-
pub server_vad: bool,
70+
pub stream_asr: bool,
7171
}
7272

7373
enum WsEvent {

0 commit comments

Comments
 (0)