diff --git a/buzz/transcriber/recording_transcriber.py b/buzz/transcriber/recording_transcriber.py index ac4f366e..3d0105ba 100644 --- a/buzz/transcriber/recording_transcriber.py +++ b/buzz/transcriber/recording_transcriber.py @@ -325,14 +325,15 @@ class RecordingTranscriber(QObject): self.error.emit(str(exc)) return - self.finished.emit() - - # Cleanup + # Cleanup before emitting finished to avoid destroying QThread + # while this function is still on the call stack if model: del model if torch.cuda.is_available(): torch.cuda.empty_cache() + self.finished.emit() + @staticmethod def get_device_sample_rate(device_id: Optional[int]) -> int: """Returns the sample rate to be used for recording. It uses the default sample rate