Skip to content
Snippets Groups Projects

Feature/add auth asr service

1 file
+ 5
2
Compare changes
  • Side-by-side
  • Inline
@@ -11,13 +11,15 @@ from flask_httpauth import HTTPTokenAuth
@@ -11,13 +11,15 @@ from flask_httpauth import HTTPTokenAuth
from sziszapangma.integration.base_asr_service.asr_result import AsrResult
from sziszapangma.integration.base_asr_service.asr_result import AsrResult
_TEMP_DIRECTORY = "asr_processing"
_TEMP_DIRECTORY = "asr_processing"
 
_AUTH_TOKEN = 'AUTH_TOKEN'
 
_SERVICE_PORT = 'SERVICE_PORT'
class AsrProcessor(ABC):
class AsrProcessor(ABC):
user_token: str
user_token: str
def __init__(self):
def __init__(self):
self.user_token = os.environ["AUTH_TOKEN"]
self.user_token = os.environ[_AUTH_TOKEN]
@abstractmethod
@abstractmethod
def process_asr(self, audio_file_path: str) -> AsrResult:
def process_asr(self, audio_file_path: str) -> AsrResult:
@@ -61,4 +63,5 @@ class AsrProcessor(ABC):
@@ -61,4 +63,5 @@ class AsrProcessor(ABC):
Path(_TEMP_DIRECTORY).mkdir(parents=True, exist_ok=True)
Path(_TEMP_DIRECTORY).mkdir(parents=True, exist_ok=True)
app.route("/process_asr", methods=["POST"])(auth.login_required(self.process_request))
app.route("/process_asr", methods=["POST"])(auth.login_required(self.process_request))
app.route("/health_check", methods=["GET"])(self.health_check)
app.route("/health_check", methods=["GET"])(self.health_check)
app.run(debug=True, host="0.0.0.0")
port = int(os.environ[_SERVICE_PORT]) if _SERVICE_PORT in os.environ else 5000
 
app.run(debug=True, host="0.0.0.0", port=port)
Loading