Home ⌂Doc Index ◂Up ▴

eric6.Plugins.UiExtensionPlugins.Translator.TranslatorEngines.MicrosoftEngine

Module implementing the Microsoft translation engine.

Global Attributes

None

Classes

MicrosoftEngine Class implementing the translation engine for the Microsoft translation service.

Functions

None


MicrosoftEngine

Class implementing the translation engine for the Microsoft translation service.

Derived from

TranslationEngine

Class Attributes

AccessTokenUrl
TextToSpeechUrl
TranslatorUrl

Class Methods

None

Methods

MicrosoftEngine Constructor
__getAccessToken Private slot to get an access token.
__getClientDataAzure Private method to retrieve the client data.
__mapLanguageCode Private method to map a language code to the Microsoft code.
engineName Public method to return the name of the engine.
getTextToSpeechData Public method to pronounce the given text.
getTranslation Public method to translate the given text.
hasTTS Public method indicating the Text-to-Speech capability.
supportedLanguages Public method to get the supported languages.

Static Methods

None

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)
Up



Home ⌂Doc Index ◂Up ▴