Skip to content
Snippets Groups Projects
Unverified Commit f9d36ebb authored by Marcin Wątroba's avatar Marcin Wątroba
Browse files

Add words_time_alignment to asr

parent 694c20b0
1 merge request!10Feature/add auth asr service
No preview for this file type
...@@ -36,13 +36,19 @@ class AsrBaseProcessor(ABC): ...@@ -36,13 +36,19 @@ class AsrBaseProcessor(ABC):
try: try:
transcription = self.process_asr(file_path) transcription = self.process_asr(file_path)
os.remove(file_path) os.remove(file_path)
result_object = jsonify( response_dict = {
{"transcription": transcription.words, "full_text": transcription.full_text} "transcription": transcription.words,
) "full_text": transcription.full_text,
"words_time_alignment": transcription.words_time_alignment
}
result_object = jsonify(response_dict)
except Exception as exception: except Exception as exception:
print(exception) print(exception)
traceback.print_exc() traceback.print_exc()
result_object = jsonify({"error": "Error on asr processing"}) result_object = jsonify({"error": "Error on asr processing"})
finally:
if os.path.isfile(file_path):
os.remove(file_path)
else: else:
result_object = jsonify({"error": "Error on asr processing"}) result_object = jsonify({"error": "Error on asr processing"})
return result_object return result_object
......
from dataclasses import dataclass 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) @dataclass(frozen=True)
class AsrResult: class AsrResult:
words: List[str] words: List[str]
full_text: str full_text: str
words_time_alignment: Optional[List[WordTimeAlignment]]
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment