Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions R/alignment.R
Original file line number Diff line number Diff line change
Expand Up @@ -231,19 +231,25 @@ dtw_align <- function(cost) {
D[1, 1] <- cost[1, 1]

# First row: can only come from the left
for (j in 2:m) {
D[1, j] <- D[1, j - 1] + cost[1, j]
if (m >= 2L) {
for (j in 2:m) {
D[1, j] <- D[1, j - 1] + cost[1, j]
}
}

# First column: can only come from above
for (i in 2:n) {
D[i, 1] <- D[i - 1, 1] + cost[i, 1]
if (n >= 2L) {
for (i in 2:n) {
D[i, 1] <- D[i - 1, 1] + cost[i, 1]
}
}

# Fill rest
for (i in 2:n) {
for (j in 2:m) {
D[i, j] <- cost[i, j] + min(D[i - 1, j], D[i, j - 1], D[i - 1, j - 1])
if (n >= 2L && m >= 2L) {
for (i in 2:n) {
for (j in 2:m) {
D[i, j] <- cost[i, j] + min(D[i - 1, j], D[i, j - 1], D[i - 1, j - 1])
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions R/transcribe.R
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@ transcribe_chunk <- function(

if (seek == 0L) {
mel <- full_mel
} else if (seek + 1L > n_frames) {
break
} else {
# Slice mel[1, :, seek:] and pad to n_frames width
mel_slice <- full_mel[, , (seek + 1L):n_frames]
Expand Down Expand Up @@ -335,6 +337,7 @@ transcribe_chunk <- function(
device = device)

generated <- decode_result$tokens
all_generated <- c(all_generated, generated)

# Find the last timestamp token to determine where to seek next
last_ts_frame <- 0L
Expand Down