diff --git a/sziszapangma/.DS_Store b/sziszapangma/.DS_Store index 2fff18096fcf72463ee45cf922f8040ac30b2e8a..b4c1ad28389434242f75e13e11d1692bf083ec69 100644 Binary files a/sziszapangma/.DS_Store and b/sziszapangma/.DS_Store differ diff --git a/sziszapangma/integration/service_core/asr/asr_base_processor.py b/sziszapangma/integration/service_core/asr/asr_base_processor.py index ee15a082a3c6ecae1b6e4ae6d566bf164099df02..a447dc27829dbee60e2fdf16e21e40728158e5f7 100644 --- a/sziszapangma/integration/service_core/asr/asr_base_processor.py +++ b/sziszapangma/integration/service_core/asr/asr_base_processor.py @@ -36,13 +36,19 @@ class AsrBaseProcessor(ABC): try: transcription = self.process_asr(file_path) os.remove(file_path) - result_object = jsonify( - {"transcription": transcription.words, "full_text": transcription.full_text} - ) + response_dict = { + "transcription": transcription.words, + "full_text": transcription.full_text, + "words_time_alignment": transcription.words_time_alignment + } + result_object = jsonify(response_dict) except Exception as exception: print(exception) traceback.print_exc() result_object = jsonify({"error": "Error on asr processing"}) + finally: + if os.path.isfile(file_path): + os.remove(file_path) else: result_object = jsonify({"error": "Error on asr processing"}) return result_object diff --git a/sziszapangma/integration/service_core/asr/asr_result.py b/sziszapangma/integration/service_core/asr/asr_result.py index cdf7c208f29f4585116191b67769a4d26150c3da..dd65f5539ef4a798684a1fea5bf1351fde6d2fe9 100644 --- a/sziszapangma/integration/service_core/asr/asr_result.py +++ b/sziszapangma/integration/service_core/asr/asr_result.py @@ -1,8 +1,15 @@ from dataclasses import dataclass -from typing import List +from typing import List, Optional + + +@dataclass(frozen=True) +class WordTimeAlignment: + start_ms: float + end_ms: float @dataclass(frozen=True) class AsrResult: words: List[str] full_text: str + words_time_alignment: Optional[List[WordTimeAlignment]]