Skip to content

Commit

Permalink
Don't count time silent towards time speaking
Browse files Browse the repository at this point in the history
  • Loading branch information
mutexlox-signal authored Nov 15, 2024
1 parent 5b3840b commit 15bc44f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/rust/src/core/group_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1425,14 +1425,15 @@ impl Client {
if let Some(next_speaking_audio_levels_time) = state.next_speaking_audio_levels_time {
if now >= next_speaking_audio_levels_time {
let (captured_level, _) = state.peer_connection.get_audio_levels();
let mut time_silent = Duration::from_secs(0);
state.started_speaking = if captured_level > MIN_NON_SILENT_LEVEL
&& !state.outgoing_heartbeat_state.audio_muted.unwrap_or(true)
{
state.silence_started = None;
state.started_speaking.or(Some(now))
} else {
state.silence_started = state.silence_started.or(Some(now));
let time_silent = state
time_silent = state
.silence_started
.map_or(Duration::from_secs(0), |start| now.duration_since(start));
if time_silent >= STOPPED_SPEAKING_DURATION {
Expand All @@ -1442,7 +1443,9 @@ impl Client {
}
};

let time_speaking = now.duration_since(state.silence_started.unwrap_or(now));
let time_speaking = now
.duration_since(state.started_speaking.unwrap_or(now))
.saturating_sub(time_silent);

let event = if time_speaking > MIN_SPEAKING_HAND_LOWER {
Some(SpeechEvent::LowerHandSuggestion)
Expand Down

0 comments on commit 15bc44f

Please sign in to comment.