trengine package¶
Submodules¶
trengine.exceptions module¶
trengine.google module¶
- class trengine.google.AsyncGoogleTranslator[source]¶
Bases:
object
- async static translate(text: str, to_language: str = 'en', source_language: str = 'auto') GoogleTranslateResult [source]¶
Translate a text using google engine.
- Parameters:
text (str) – the text to translate.
to_language (str, optional) – The lang code of target lang. Defaults to “en”.
source_language (str, optional) – Source lang of the text. Defaults to “auto”.
- class trengine.google.GoogleTranslator[source]¶
Bases:
object
- static translate(text: str, to_language: str = 'en', source_language: str = 'auto') GoogleTranslateResult [source]¶
Translate a text using google engine.
- Parameters:
text (str) – the text to translate.
to_language (str, optional) – The lang code of target lang. Defaults to “en”.
source_language (str, optional) – Source lang of the text. Defaults to “auto”.
trengine.hozory module¶
- class trengine.hozory.AsyncHozoryTranslator[source]¶
Bases:
object
- async static translate(text: str, target: str = 'en') HozoryTranslateResult [source]¶
Translate a text using hozory engine.
- Parameters:
text (str) – the text to translate.
target (str, optional) – The lang code of target lang. Defaults to “en”.
- class trengine.hozory.HozoryTranslator[source]¶
Bases:
object
- static translate(text: str, target: str = 'en') HozoryTranslateResult [source]¶
Translate a text using hozory engine.
- Parameters:
text (str) – the text to translate.
target (str, optional) – The lang code of target lang. Defaults to “en”.
trengine.identify_music module¶
- class trengine.identify_music.AsyncIdentifyMusic[source]¶
Bases:
object
- async static identify(file_path: str) IdentifyMusicResult [source]¶
Identify music using shazam.
- Parameters:
file_path (str) – The path to the audio file to be identified. This should be a valid path to an audio file
- class trengine.identify_music.IdentifyMusic[source]¶
Bases:
object
- static identify(file_path: str) IdentifyMusicResult [source]¶
Identify music using shazam.
- Parameters:
file_path (str) – The path to the audio file to be identified. This should be a valid path to an audio file
trengine.ocr module¶
trengine.speech_to_text module¶
- class trengine.speech_to_text.AsyncSpeechToText[source]¶
Bases:
object
- async static to_text(file_path: str, language: str = 'en') SpeechToTextResult [source]¶
Speech to text using google cloud.
- Parameters:
file_path (str) – The path to the audio file to be transcribed into text. This should be a valid path to an audio file
language (str, optional) – the source language code of the audio file. Defaults to “en”. Supported languages are: en, ar
- class trengine.speech_to_text.SpeechToText[source]¶
Bases:
object
- static to_text(file_path: str, language: str = 'en') SpeechToTextResult [source]¶
Speech to text using google cloud.
- Parameters:
file_path (str) – The path to the audio file to be transcribed into text. This should be a valid path to an audio file
language (str, optional) – the source language code of the audio file. Defaults to “en”. Supported languages are: en, ar
trengine.tdict module¶
trengine.text_to_speech module¶
- class trengine.text_to_speech.AsyncTextToSpeech[source]¶
Bases:
object
- async static to_speech(text: str, output_path: str, language: str = 'en') TextToSpeechResult [source]¶
Text to speech using google translate.
- Parameters:
text (str) – The text to be converted into speech
language (str, optional) – the source language code of the text. Defaults to “en”.
out_put_path (str) – The path to save the output audio file
- class trengine.text_to_speech.TextToSpeech[source]¶
Bases:
object
- static to_speech(text: str, output_path: str, language: str = 'en') TextToSpeechResult [source]¶
Text to speech using google translate.
- Parameters:
text (str) – The text to be converted into speech
language (str, optional) – the source language code of the text. Defaults to “en”.
out_put_path (str) – The path to save the output audio file
trengine.tr module¶
- class trengine.tr.AsyncTranslator[source]¶
Bases:
object
- async static detect(text: str) str [source]¶
Detect language code from text.
- Parameters:
text (str) – The text.
- async static translate(text: str, translated_lang: str = 'en', source_lang: str | None = None) AjaxTranslateResult [source]¶
Translate a text using tr engine.
- Parameters:
text (str) – the text to translate.
translated_lang (str, optional) – The lang code of target lang. Defaults to “en”.
source_lang (str, optional) – Source lang of the text. Defaults to None.
- class trengine.tr.Translator[source]¶
Bases:
object
- static detect(text: str) str [source]¶
Detect language code from text.
- Parameters:
text (str) – The text.
- static translate(text: str, translated_lang: str = 'en', source_lang: str | None = None) AjaxTranslateResult [source]¶
Translate a text using tr engine.
- Parameters:
text (str) – the text to translate.
translated_lang (str, optional) – The lang code of target lang. Defaults to “en”.
source_lang (str, optional) – Source lang of the text. Defaults to None.
trengine.types module¶
- class trengine.types.AjaxTranslateResult(original_text: str, translated_text: str, translation_language: str, original_language: str)[source]¶
Bases:
Base
- original_language: str¶
- original_text: str¶
- static parse(d: dict, org: str) AjaxTranslateResult [source]¶
- translated_text: str¶
- translation_language: str¶
- class trengine.types.GoogleTranslateResult(translated_text: str, original_language: str, dest_language: str)[source]¶
Bases:
Base
- dest_language: str¶
- original_language: str¶
- static parse(d: list, dest: str, source: str | None = None) GoogleTranslateResult [source]¶
- translated_text: str¶
- class trengine.types.HozoryTranslateResult(translated_text: str, translation_language: str, voice_link: str)[source]¶
Bases:
Base
- static parse(d: dict, dest: str) HozoryTranslateResult [source]¶
- translated_text: str¶
- translation_language: str¶
- voice_link: str¶
- class trengine.types.IdentifyMusicResult(status: bool, file_path: str, tracks: list)[source]¶
Bases:
Base
- file_path: str¶
- static parse(d: dict, p: str) IdentifyMusicResult [source]¶
- status: bool¶
- tracks: list¶
Module contents¶
- class trengine.AsyncEngine[source]¶
Bases:
object
- property google: AsyncGoogleTranslator¶
Use google engine.
- Returns:
Google Engine Class.
- Return type:
- property hozory: AsyncHozoryTranslator¶
Use hozory engine.
- Returns:
Hozory Engine Class.
- Return type:
- property identify_music: AsyncIdentifyMusic¶
Use identify_music service.
- Returns:
identify_music Engine Class.
- Return type:
- property speech_to_text: AsyncSpeechToText¶
Use speech_to_text service.
- Returns:
speech_to_text Engine Class.
- Return type:
- property tdict: AsyncTdictTranslator¶
Use tdict engine.
- Returns:
tdict Engine Class.
- Return type:
- property text_to_speech: AsyncTextToSpeech¶
Use text_to_speech service.
- Returns:
text_to_speech Engine Class.
- Return type:
- property tr: AsyncTranslator¶
Use tr engine.
- Returns:
Ajax Engine Class.
- Return type:
ajax.AsyncAjaxTranslator
- class trengine.Engine[source]¶
Bases:
object
- property google: GoogleTranslator¶
Use google engine.
- Returns:
Google Engine Class.
- Return type:
- property hozory: HozoryTranslator¶
Use hozory engine.
- Returns:
Hozory Engine Class.
- Return type:
- property identify_music: IdentifyMusic¶
Use identify_music service.
- Returns:
identify_music Engine Class.
- Return type:
- property speech_to_text: SpeechToText¶
Use speech_to_text service.
- Returns:
speech_to_text Engine Class.
- Return type:
- property tdict: TdictTranslator¶
Use tdict engine.
- Returns:
tdict Engine Class.
- Return type:
- property text_to_speech: TextToSpeech¶
Use text_to_speech service.
- Returns:
text_to_speech Engine Class.
- Return type:
- property tr: Translator¶
Use tr engine.
- Returns:
Ajax Engine Class.
- Return type:
ajax.AjaxTranslator