Spaces:
Sleeping
Sleeping
Commit
·
aa23397
1
Parent(s):
67868c4
added stop audit button, to be used by admin only, hence protected by admin passowrd
Browse files- ASR_Server.py +12 -4
ASR_Server.py
CHANGED
|
@@ -14,6 +14,7 @@ from utils.generate_box_plot import box_plot_data
|
|
| 14 |
from utils.model_validity import is_valid_asr_model
|
| 15 |
from utils.send_email import send_email
|
| 16 |
|
|
|
|
| 17 |
# Set the cache directory for Hugging Face datasets
|
| 18 |
os.environ["HF_HOME"] = "/tmp/huggingface"
|
| 19 |
# ASR_model = "openai/whisper-tiny" # Replace with your ASR model
|
|
@@ -267,10 +268,17 @@ def get_status():
|
|
| 267 |
|
| 268 |
@app.route('/api/stop', methods=['GET'])
|
| 269 |
def stop_transcription():
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 274 |
|
| 275 |
@app.route('/api', methods=['GET'])
|
| 276 |
def api():
|
|
|
|
| 14 |
from utils.model_validity import is_valid_asr_model
|
| 15 |
from utils.send_email import send_email
|
| 16 |
|
| 17 |
+
load_dotenv()
|
| 18 |
# Set the cache directory for Hugging Face datasets
|
| 19 |
os.environ["HF_HOME"] = "/tmp/huggingface"
|
| 20 |
# ASR_model = "openai/whisper-tiny" # Replace with your ASR model
|
|
|
|
| 268 |
|
| 269 |
@app.route('/api/stop', methods=['GET'])
|
| 270 |
def stop_transcription():
|
| 271 |
+
if job_status["running"] == False :
|
| 272 |
+
return jsonify({"message": "No transcription is running currently"})
|
| 273 |
+
|
| 274 |
+
admin_pass = os.environ.get('ADMIN_PASSWORD') ;
|
| 275 |
+
passkey = request.args.get('passkey', default="", type=str)
|
| 276 |
+
if passkey == admin_pass :
|
| 277 |
+
global stop_transcription_flag
|
| 278 |
+
stop_transcription_flag["active"] = True
|
| 279 |
+
return jsonify({"message": "Stop requested. The running transcription will terminate soon or as soon as possible."})
|
| 280 |
+
else :
|
| 281 |
+
return jsonify({"message": f"{passkey} : Wrong Admin Password(This feature is only for platform admin, users should not try to use it)"})
|
| 282 |
|
| 283 |
@app.route('/api', methods=['GET'])
|
| 284 |
def api():
|