Skip to content

Commit

Permalink
close off last segment
Browse files Browse the repository at this point in the history
  • Loading branch information
cpoile committed Mar 22, 2024
1 parent bd6e7dd commit e57bae6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions cmd/transcriber/call/live_captions.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,11 @@ type segmentSamples struct {

// convertToSegmentSamples turns the speech.Segments (in time) into segmentSamples (measured in samples)
func convertToSegmentSamples(segments []speech.Segment, audioLen int) []segmentSamples {
// close off the last segment (we know segments > 0)
if segments[len(segments)-1].SpeechEndAt == 0 {
segments[len(segments)-1].SpeechEndAt = float64(audioLen) / trackOutAudioRate
}

var ret []segmentSamples
lastEndAtIdx := 0
for _, seg := range segments {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/pion/randutil v0.1.0
github.com/pion/rtp v1.8.3
github.com/pion/webrtc/v3 v3.2.21
github.com/streamer45/silero-vad-go v0.1.3-0.20240319124904-3e7e59fa58bf
github.com/streamer45/silero-vad-go v0.1.3-0.20240322202454-14710a0ddbf0
github.com/stretchr/testify v1.8.4
)

Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ github.com/streamer45/silero-vad-go v0.1.3-0.20240315212856-bb94974c19ca h1:/Dwj
github.com/streamer45/silero-vad-go v0.1.3-0.20240315212856-bb94974c19ca/go.mod h1:B+2FXs/5fZ6pzl6unUZYhZqkYdOB+3saBVzjOzdZnUs=
github.com/streamer45/silero-vad-go v0.1.3-0.20240319124904-3e7e59fa58bf h1:noStsY9vK/SmF09B+1vgOc9s7pjXsd9iCgWvS44rq9Y=
github.com/streamer45/silero-vad-go v0.1.3-0.20240319124904-3e7e59fa58bf/go.mod h1:B+2FXs/5fZ6pzl6unUZYhZqkYdOB+3saBVzjOzdZnUs=
github.com/streamer45/silero-vad-go v0.1.3-0.20240322202454-14710a0ddbf0 h1:hkjS44sC6b5Ho88N9cB0RN8zFYWdI55r4nPE2b3iCw0=
github.com/streamer45/silero-vad-go v0.1.3-0.20240322202454-14710a0ddbf0/go.mod h1:B+2FXs/5fZ6pzl6unUZYhZqkYdOB+3saBVzjOzdZnUs=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
Expand Down

0 comments on commit e57bae6

Please sign in to comment.