language_service package

asr

This is “asr.py” file.

async language_service.asr.transcribe_and_translate(file_name, language_code, sample_rate_hertz=16000)[source]

Generate transcriptions (text) and confidence score for a given audio or voice file in a specified language using an ASR model.

Note: The original method call is as below. Due to some ‘Documentation Syntax requiremets’ issues we have removed a parameter in the function call. async def transcribe_and_translate( file_name, language_code, encoding_format=speech.RecognitionConfig.AudioEncoding.MP3, sample_rate_hertz=16000

):

translation

This is “translation.py”

async language_service.translation.a_translate_to(text: str, lang_code: str) str[source]

Translate a given text to specified language.

async language_service.translation.a_translate_to_english(text: str) str[source]

Translate a given text to english.

async language_service.translation.detect_language_and_translate_to_english(input_msg)[source]

Detect the language of specified text and translate it to english.

tts

This is “tts.py”

async language_service.tts.synthesize_speech(input_text: str, input_language: str, id_string: str | None = None, aiohttp_session=None, sample_rate_hertz=48000) str[source]
async language_service.tts.synthesize_speech_azure(text_to_synthesize, language_code, aiohttp_session)[source]

Synthesise speech using Azure TTS model. Azure TTS Docs

utils

This is “utils.py”

language_service.utils.get_all_languages() list[source]

Query the list of all active languages

language_service.utils.get_language_by_code(code)[source]

Query Language instance by language code. Note: The original call was -> #def get_language_by_code(code: str) -> Language: For documentation purpose(Sphinx has issues with that definition).

language_service.utils.get_language_by_id(language_id)[source]

Query a specific language by the given language ID