Skip to content
Open
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
8 changes: 6 additions & 2 deletions funasr/auto/auto_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,8 +555,12 @@ def inference_with_vad(self, input, input_len=None, **cfg):
if k not in result:
result[k] = []
for t in restored_data[j][k]:
t[0] += vadsegments[j][0]
t[1] += vadsegments[j][0]
if isinstance(t, dict):
t["start_time"] = (t["start_time"] * 1000 + vadsegments[j][0]) / 1000
t["end_time"] = (t["end_time"] * 1000 + vadsegments[j][0]) / 1000
Comment on lines +559 to +560
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The calculation for adjusting timestamps can be simplified for better readability. Directly adding the offset in seconds is more concise and achieves the same result.

Suggested change
t["start_time"] = (t["start_time"] * 1000 + vadsegments[j][0]) / 1000
t["end_time"] = (t["end_time"] * 1000 + vadsegments[j][0]) / 1000
t["start_time"] += vadsegments[j][0] / 1000.0
t["end_time"] += vadsegments[j][0] / 1000.0

else:
t[0] += vadsegments[j][0]
t[1] += vadsegments[j][0]
result[k].extend(restored_data[j][k])
elif k == "spk_embedding":
if k not in result:
Expand Down