Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for small segments #57

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion whisper_s2t/backends/ctranslate2/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def align_words(self, features, texts, text_tokens, sot_seqs, seq_lens, seg_meta

return word_timings

def generate_segment_batched(self, features, prompts, seq_lens, seg_metadata):
def generate_segment_batched(self, features, prompts, seq_lens=None, seg_metadata=None):

if self.device == 'cpu':
features = np.ascontiguousarray(features.detach().numpy())
Expand Down
3 changes: 2 additions & 1 deletion whisper_s2t/data.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import torch

import math
import numpy as np
from tqdm import tqdm

Expand Down Expand Up @@ -63,7 +64,7 @@ def __call__(self, input_file=None, audio_signal=None):
audio_duration = len(audio_signal)/self.sampling_rate

start_ends = []
for i in range(0, int(audio_duration), int(self.max_seg_len)):
for i in range(0, math.ceil(audio_duration), int(self.max_seg_len)):
start_ends.append([i, i + self.max_seg_len])

start_ends[-1][1] = min(audio_duration, start_ends[-1][1]) # fix edge
Expand Down