From a2ca7a67df1f33d585b5d46a9bf5df307c2e3861 Mon Sep 17 00:00:00 2001 From: Shruti1229 Date: Thu, 28 Dec 2023 00:28:05 +0530 Subject: [PATCH] Add Pre and post processor condition in Indic ASR --- backend/transcript/metadata.py | 6 ++++-- backend/transcript/utils/asr.py | 30 +++++++++++++++++++++--------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/backend/transcript/metadata.py b/backend/transcript/metadata.py index 91af3b61..9cb65937 100644 --- a/backend/transcript/metadata.py +++ b/backend/transcript/metadata.py @@ -2,7 +2,6 @@ TRANSCRIPTION_LANGUAGE_CHOICES = [ ("en", "English"), ("hi", "Hindi"), - ("as", "Assamese"), ("bn", "Bengali"), ("gu", "Gujarati"), ("kn", "Kannada"), @@ -12,10 +11,11 @@ ("pa", "Punjabi"), ("ta", "Tamil"), ("te", "Telugu"), + ("sa", "Sanskrit"), + ("ur": "Urdu"), ] TRANSCRIPTION_SUPPORTED_LANGUAGES = { - "Assamese": "as", "Bengali": "bn", "English": "en", "Gujarati": "gu", @@ -25,6 +25,8 @@ "Marathi": "mr", "Oriya": "or", "Punjabi": "pa", + "Sanskrit": "sa", "Tamil": "ta", "Telugu": "te", + "Urdu": "ur", } diff --git a/backend/transcript/utils/asr.py b/backend/transcript/utils/asr.py index 9e8c2289..51e118e4 100644 --- a/backend/transcript/utils/asr.py +++ b/backend/transcript/utils/asr.py @@ -55,15 +55,27 @@ def make_asr_api_call(url, lang, vad_level=3, chunk_size=10): else: return None - json_data = { - "config": { - "serviceId": service_id, - "language": {"sourceLanguage": lang}, - "transcriptionFormat": {"value": "srt"}, - "postProcessors": ["itn", "punctuation"], - }, - "audio": [{"audioUri": url}], - } + if lang not in ["kn", "gu", "ur", "ml"]: + json_data = { + "config": { + "serviceId": service_id, + "language": {"sourceLanguage": lang}, + "transcriptionFormat": {"value": "srt"}, + "postProcessors": ["itn", "punctuation"], + "preProcessors": ["vad"], + }, + "audio": [{"audioUri": url}], + } + else: + json_data = { + "config": { + "serviceId": service_id, + "language": {"sourceLanguage": lang}, + "transcriptionFormat": {"value": "srt"}, + "preProcessors": ["vad"], + }, + "audio": [{"audioUri": url}], + } logging.info("Sending request to indic model.") try: response = requests.post(