eric6.Plugins.UiExtensionPlugins.Translator.TranslatorEngines.MicrosoftEngine
Module implementing the Microsoft translation engine.
Global Attributes
Classes
| MicrosoftEngine |
Class implementing the translation engine for the Microsoft translation service. |
Functions
MicrosoftEngine
Class implementing the translation engine for the Microsoft
translation service.
Derived from
TranslationEngine
Class Attributes
| AccessTokenUrl |
| TextToSpeechUrl |
| TranslatorUrl |
Class Methods
Methods
Static Methods
MicrosoftEngine (Constructor)
MicrosoftEngine(plugin, parent=None)
Constructor
- plugin
-
reference to the plugin object (TranslatorPlugin)
- parent
-
reference to the parent object (QObject)
MicrosoftEngine.__getAccessToken
__getAccessToken(requestObject)
Private slot to get an access token.
If the stored token is no longer valid, get a new one and store it.
- requestObject
-
reference to the request object
(TranslatorRequest)
- Returns:
-
access token (string)
MicrosoftEngine.__getClientDataAzure
__getClientDataAzure()
Private method to retrieve the client data.
- Returns:
-
tuple giving the API subscription key and a flag indicating
validity
- Return Type:
-
tuple of (str, bool)
MicrosoftEngine.__mapLanguageCode
__mapLanguageCode(code)
Private method to map a language code to the Microsoft code.
- code
-
language code (string)
- Returns:
-
mapped language code (string)
MicrosoftEngine.engineName
engineName()
Public method to return the name of the engine.
- Returns:
-
engine name (string)
MicrosoftEngine.getTextToSpeechData
getTextToSpeechData(requestObject, text, language)
Public method to pronounce the given text.
- requestObject
-
reference to the request object
(TranslatorRequest)
- text
-
text to be pronounced (string)
- language
-
language code of the text (string)
- Returns:
-
tuple with pronounce data (QByteArray) or error string (string)
and success flag (boolean)
MicrosoftEngine.getTranslation
getTranslation(requestObject, text, originalLanguage, translationLanguage)
Public method to translate the given text.
- requestObject
-
reference to the request object
(TranslatorRequest)
- text
-
text to be translated (string)
- originalLanguage
-
language code of the original (string)
- translationLanguage
-
language code of the translation (string)
- Returns:
-
tuple of translated text (string) and flag indicating
success (boolean)
MicrosoftEngine.hasTTS
hasTTS()
Public method indicating the Text-to-Speech capability.
- Returns:
-
flag indicating the Text-to-Speech capability (boolean)
MicrosoftEngine.supportedLanguages
supportedLanguages()
Public method to get the supported languages.
- Returns:
-
list of supported language codes (list of string)