mirror of
https://github.com/shirayu/whispering.git
synced 2024-11-13 04:02:00 +00:00
Fix timestamp calculation
This commit is contained in:
parent
b2650dbcd8
commit
1165ad9f3a
1 changed files with 2 additions and 1 deletions
|
@ -160,6 +160,7 @@ class WhisperStreamingTranscriber:
|
|||
tokens[last_slice - 1].item() - self.tokenizer.timestamp_begin
|
||||
)
|
||||
self.buffer_tokens.extend(tokens[: last_slice + 1].tolist())
|
||||
self.timestamp += last_timestamp_position * self.input_stride
|
||||
else:
|
||||
duration = segment_duration
|
||||
timestamps = tokens[timestamp_tokens.nonzero().flatten()]
|
||||
|
@ -178,6 +179,7 @@ class WhisperStreamingTranscriber:
|
|||
)
|
||||
if chunk is not None:
|
||||
yield chunk
|
||||
self.timestamp += float(segment_duration * HOP_LENGTH / SAMPLE_RATE)
|
||||
|
||||
if result.temperature > 0.5:
|
||||
# do not feed the prompt tokens if a high temperature was used
|
||||
|
@ -208,4 +210,3 @@ class WhisperStreamingTranscriber:
|
|||
yield from self._deal_timestamp(
|
||||
result=result, segment_duration=segment_duration
|
||||
)
|
||||
self.timestamp += float(segment.shape[-1] * HOP_LENGTH / SAMPLE_RATE)
|
||||
|
|
Loading…
Reference in a new issue