Skip to content

Commit

Permalink
add collapse_segments later on
Browse files Browse the repository at this point in the history
  • Loading branch information
jwijffels committed Jan 27, 2024
1 parent ac805e2 commit 622ad2e
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions R/vad.R
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ print.VAD <- function(x, ...){



collapse_segments <- function(x, collapse_silence_secs = 1){
x$has_voice <- ifelse(x$has_voice, x$has_voice, ifelse((x$end - x$start) < collapse_silence_secs, TRUE, x$has_voice))
grp <- rle(x$has_voice)
x$vad_segment <- rep(seq_along(grp$lengths), grp$lengths)
x <- data.table::as.data.table(x)
x <- x[, list(start = min(start), end = max(end)), by = list(vad_segment, has_voice)]
x
}
# collapse_segments <- function(x, collapse_silence_secs = 1){
# x$has_voice <- ifelse(x$has_voice, x$has_voice, ifelse((x$end - x$start) < collapse_silence_secs, TRUE, x$has_voice))
# grp <- rle(x$has_voice)
# x$vad_segment <- rep(seq_along(grp$lengths), grp$lengths)
# x <- data.table::as.data.table(x)
# x <- x[, list(start = min(start), end = max(end)), by = list(vad_segment, has_voice)]
# x
# }
#voiced <- collapse_segments(vad$vad_segments)

0 comments on commit 622ad2e

Please sign in to comment.