mirror of
https://github.com/shirayu/whispering.git
synced 2025-01-23 07:08:10 +00:00
Fix seek
This commit is contained in:
parent
2a159f12d7
commit
ca7e77f437
1 changed files with 3 additions and 2 deletions
|
@ -199,9 +199,9 @@ class WhisperStreamingTranscriber:
|
||||||
self.timestamp += last_timestamp_position0 * self.time_precision
|
self.timestamp += last_timestamp_position0 * self.time_precision
|
||||||
yield last_timestamp_position0
|
yield last_timestamp_position0
|
||||||
else:
|
else:
|
||||||
logger.debug("Length of consecutive: 0")
|
|
||||||
duration = segment_duration
|
duration = segment_duration
|
||||||
timestamps = tokens[timestamp_tokens.nonzero().flatten()]
|
timestamps = tokens[timestamp_tokens.nonzero().flatten()]
|
||||||
|
logger.debug(f"Length of consecutive: 0, timestamps: {timestamps}")
|
||||||
if len(timestamps) > 0:
|
if len(timestamps) > 0:
|
||||||
# no consecutive timestamps but it has a timestamp; use the last one.
|
# no consecutive timestamps but it has a timestamp; use the last one.
|
||||||
# single timestamp at the end means no speech after the last timestamp.
|
# single timestamp at the end means no speech after the last timestamp.
|
||||||
|
@ -209,6 +209,7 @@ class WhisperStreamingTranscriber:
|
||||||
timestamps[-1].item() - self.tokenizer.timestamp_begin
|
timestamps[-1].item() - self.tokenizer.timestamp_begin
|
||||||
)
|
)
|
||||||
duration = last_timestamp_position * self.time_precision
|
duration = last_timestamp_position * self.time_precision
|
||||||
|
logger.debug(f"segment_duration: {segment_duration}, Duration: {duration}")
|
||||||
chunk = self._get_chunk(
|
chunk = self._get_chunk(
|
||||||
start=self.timestamp,
|
start=self.timestamp,
|
||||||
end=self.timestamp + duration,
|
end=self.timestamp + duration,
|
||||||
|
@ -281,7 +282,7 @@ class WhisperStreamingTranscriber:
|
||||||
seek += segment.shape[-1]
|
seek += segment.shape[-1]
|
||||||
rest_start = None
|
rest_start = None
|
||||||
else:
|
else:
|
||||||
seek += last_timestamp_position
|
seek += last_timestamp_position * self.input_stride
|
||||||
rest_start = seek
|
rest_start = seek
|
||||||
|
|
||||||
logger.debug(f"Last rest_start={rest_start}")
|
logger.debug(f"Last rest_start={rest_start}")
|
||||||
|
|
Loading…
Reference in a new issue