diff --git a/app/asr_models/asr_model.py b/app/asr_models/asr_model.py index 76b7b8551d7dbf7fae72092297b314c4e25df096..2c6fbf097a7e64b4ee73cddeb7c338993f7b8603 100644 --- a/app/asr_models/asr_model.py +++ b/app/asr_models/asr_model.py @@ -75,3 +75,20 @@ class ASRModel(ABC): gc.collect() self.model = None print("Model unloaded due to timeout") + + @property + def is_transcribing(self) -> bool: + """ + Returns True if a transcription is currently running. + """ + return self.model_lock.locked() + + @property + def is_model_loaded(self) -> bool: + """ + Returns True if the model is loaded in memory. + """ + model_attr = self.model + if isinstance(model_attr, dict): + return model_attr.get('whisperx') is not None + return model_attr is not None diff --git a/app/webservice.py b/app/webservice.py index 24fe05daf30a25bcc323b4754f59fbff582cb918..38431fa751af85329ed089b3021a20ef5f9f756f 100644 --- a/app/webservice.py +++ b/app/webservice.py @@ -125,7 +125,8 @@ async def transcription_status(): """ Return whether a transcription is currently running. """ - return {"active": asr_model.transcription_active} + # Use the model lock to check if a transcription is currently running + return {"active": asr_model.is_transcribing} @click.command()