update python bindings for stream transcribe#351
Conversation
Signed-off-by: jakmro <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR updates the Python bindings for the stream transcription API to align with changes in the underlying C FFI. The API is simplified by consolidating functions and changing their behavior.
Changes:
- Renamed
cactus_stream_transcribe_inittocactus_stream_transcribe_startwith added options parameter - Removed
cactus_stream_transcribe_insertfunction and merged its functionality intocactus_stream_transcribe_process - Updated
cactus_stream_transcribe_processto accept PCM data directly and return transcription immediately - Renamed
cactus_stream_transcribe_finalizetocactus_stream_transcribe_stop - Removed
cactus_stream_transcribe_destroyfunction (cleanup now handled by stop)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| stream, buf, len(buf), | ||
| options.encode() if options else None | ||
| ) | ||
| _lib.cactus_stream_transcribe_process(stream, arr, len(arr), buf, len(buf)) |
There was a problem hiding this comment.
The return value from _lib.cactus_stream_transcribe_process is not being checked. According to the C FFI header and usage in tests, this function returns an integer where negative values indicate errors. The function should check the return value and handle errors appropriately, similar to how other functions in this file handle errors from FFI calls.
| _lib.cactus_stream_transcribe_process(stream, arr, len(arr), buf, len(buf)) | |
| result = _lib.cactus_stream_transcribe_process(stream, arr, len(arr), buf, len(buf)) | |
| if result < 0: | |
| raise RuntimeError(f"cactus_stream_transcribe_process failed with error code {result}") |
| """ | ||
| buf = ctypes.create_string_buffer(65536) | ||
| _lib.cactus_stream_transcribe_finalize(stream, buf, len(buf)) | ||
| _lib.cactus_stream_transcribe_stop(stream, buf, len(buf)) |
There was a problem hiding this comment.
The return value from _lib.cactus_stream_transcribe_stop is not being checked. According to the C FFI header and usage in tests, this function returns an integer where negative values indicate errors. The function should check the return value and handle errors appropriately before returning the buffer content.
| _lib.cactus_stream_transcribe_stop(stream, buf, len(buf)) | |
| result = _lib.cactus_stream_transcribe_stop(stream, buf, len(buf)) | |
| if result < 0: | |
| raise RuntimeError(f"cactus_stream_transcribe_stop failed with error code {result}") |
Signed-off-by: jakmro <[email protected]>
Signed-off-by: jakmro <[email protected]>
No description provided.