Skip to content

Commit 503904d

Browse files
authored
fix(faster-whisper): cast segment timestamps to int after multiplication (#9674)
`int(x) * 1e9` returns a float because `1e9` is a float literal, but TranscriptSegment.start/end are integer protobuf fields. This caused every transcription request to fail with: TypeError: 'float' object cannot be interpreted as an integer Multiply first, then cast — `int(x * 1e9)` — to get an int as required.
1 parent d5ce823 commit 503904d

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

backend/python/faster-whisper/backend.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def AudioTranscription(self, request, context):
5959
id = 0
6060
for segment in segments:
6161
print("[%.2fs -> %.2fs] %s" % (segment.start, segment.end, segment.text))
62-
resultSegments.append(backend_pb2.TranscriptSegment(id=id, start=int(segment.start)*1e9, end=int(segment.end)*1e9, text=segment.text))
62+
resultSegments.append(backend_pb2.TranscriptSegment(id=id, start=int(segment.start*1e9), end=int(segment.end*1e9), text=segment.text))
6363
text += segment.text
6464
id += 1
6565
except Exception as err:

0 commit comments

Comments
 (0)