diff --git a/backend/projects/annotation_registry.py b/backend/projects/annotation_registry.py index 34ef2a68a..1214b2f45 100644 --- a/backend/projects/annotation_registry.py +++ b/backend/projects/annotation_registry.py @@ -221,7 +221,7 @@ def convert_prediction_json_to_annotation_result( "original_length": audio_duration, "type": "textarea", "value": { - "text": "", + "text": [], }, } ) diff --git a/backend/tasks/views.py b/backend/tasks/views.py index 368008cd9..9def3a039 100644 --- a/backend/tasks/views.py +++ b/backend/tasks/views.py @@ -138,14 +138,9 @@ def annotations(self, request, pk): # modifications for integrations of chitralekha UI if "enable_chitralekha_UI" in dict(request.query_params): for ann in annotations: - ( - subtitles, - standardised_transcription, - ) = convert_result_to_chitralekha_format( + ann.result = convert_result_to_chitralekha_format( ann.result, ann.id, project.project_type ) - # ann.result = {"subtitles": subtitles, "standardised_transcription": standardised_transcription} - ann.result = subtitles serializer = AnnotationSerializer(annotations, many=True) return Response(serializer.data) diff --git a/backend/utils/convert_result_to_chitralekha_format.py b/backend/utils/convert_result_to_chitralekha_format.py index 7f2b6f0d0..0e540fdb7 100644 --- a/backend/utils/convert_result_to_chitralekha_format.py +++ b/backend/utils/convert_result_to_chitralekha_format.py @@ -29,7 +29,7 @@ def create_memory(result): def convert_result_to_chitralekha_format(result, ann_id, project_type): if (len(result) == 1 and result[0] == {}) or len(result) == 0: - return [], None + return [] memory = create_memory(result) modified_result = [] count = 1 @@ -101,15 +101,18 @@ def convert_result_to_chitralekha_format(result, ann_id, project_type): modified_result = ( sort_result_by_start_time(modified_result) if len(modified_result) > 0 else [] ) - standardised_transcription = None - """ if project_type == "AcousticNormalisedTranscription": + if project_type == "AcousticNormalisedTranscription": standardised_transcription = ( result[memory["standardised_transcription"]]["value"]["text"][0] - if result[memory["standardised_transcription"]]["value"]["text"] + if "standardised_transcription" in memory.keys() + and result[memory["standardised_transcription"]]["value"]["text"] else "" ) - """ - return (modified_result, standardised_transcription) + modified_result.append( + {"standardised_transcription": standardised_transcription} + ) + + return modified_result def convert_fractional_time_to_formatted(decimal_time, ann_id, data_id):