|
1 <!DOCTYPE html> |
|
2 <html><head> |
|
3 <title>eric6.Plugins.UiExtensionPlugins.Translator.TranslatorEngines.MicrosoftEngine</title> |
|
4 <meta charset="UTF-8"> |
|
5 <style> |
|
6 body { |
|
7 background: #EDECE6; |
|
8 margin: 0em 1em 10em 1em; |
|
9 color: black; |
|
10 } |
|
11 |
|
12 h1 { color: white; background: #85774A; } |
|
13 h2 { color: white; background: #85774A; } |
|
14 h3 { color: white; background: #9D936E; } |
|
15 h4 { color: white; background: #9D936E; } |
|
16 |
|
17 a { color: #BA6D36; } |
|
18 |
|
19 </style> |
|
20 </head> |
|
21 <body><a NAME="top" ID="top"></a> |
|
22 <h1>eric6.Plugins.UiExtensionPlugins.Translator.TranslatorEngines.MicrosoftEngine</h1> |
|
23 <p> |
|
24 Module implementing the Microsoft translation engine. |
|
25 </p> |
|
26 <h3>Global Attributes</h3> |
|
27 <table> |
|
28 <tr><td>None</td></tr> |
|
29 </table> |
|
30 <h3>Classes</h3> |
|
31 <table> |
|
32 <tr> |
|
33 <td><a href="#MicrosoftEngine">MicrosoftEngine</a></td> |
|
34 <td>Class implementing the translation engine for the Microsoft translation service.</td> |
|
35 </tr> |
|
36 </table> |
|
37 <h3>Functions</h3> |
|
38 <table> |
|
39 <tr><td>None</td></tr> |
|
40 </table> |
|
41 <hr /><hr /> |
|
42 <a NAME="MicrosoftEngine" ID="MicrosoftEngine"></a> |
|
43 <h2>MicrosoftEngine</h2> |
|
44 <p> |
|
45 Class implementing the translation engine for the Microsoft |
|
46 translation service. |
|
47 </p> |
|
48 <h3>Derived from</h3> |
|
49 TranslationEngine |
|
50 <h3>Class Attributes</h3> |
|
51 <table> |
|
52 <tr><td>AccessTokenUrl</td></tr><tr><td>TextToSpeechUrl</td></tr><tr><td>TranslatorUrl</td></tr> |
|
53 </table> |
|
54 <h3>Class Methods</h3> |
|
55 <table> |
|
56 <tr><td>None</td></tr> |
|
57 </table> |
|
58 <h3>Methods</h3> |
|
59 <table> |
|
60 <tr> |
|
61 <td><a href="#MicrosoftEngine.__init__">MicrosoftEngine</a></td> |
|
62 <td>Constructor</td> |
|
63 </tr><tr> |
|
64 <td><a href="#MicrosoftEngine.__getAccessToken">__getAccessToken</a></td> |
|
65 <td>Private slot to get an access token.</td> |
|
66 </tr><tr> |
|
67 <td><a href="#MicrosoftEngine.__getClientDataAzure">__getClientDataAzure</a></td> |
|
68 <td>Private method to retrieve the client data.</td> |
|
69 </tr><tr> |
|
70 <td><a href="#MicrosoftEngine.__mapLanguageCode">__mapLanguageCode</a></td> |
|
71 <td>Private method to map a language code to the Microsoft code.</td> |
|
72 </tr><tr> |
|
73 <td><a href="#MicrosoftEngine.engineName">engineName</a></td> |
|
74 <td>Public method to return the name of the engine.</td> |
|
75 </tr><tr> |
|
76 <td><a href="#MicrosoftEngine.getTextToSpeechData">getTextToSpeechData</a></td> |
|
77 <td>Public method to pronounce the given text.</td> |
|
78 </tr><tr> |
|
79 <td><a href="#MicrosoftEngine.getTranslation">getTranslation</a></td> |
|
80 <td>Public method to translate the given text.</td> |
|
81 </tr><tr> |
|
82 <td><a href="#MicrosoftEngine.hasTTS">hasTTS</a></td> |
|
83 <td>Public method indicating the Text-to-Speech capability.</td> |
|
84 </tr><tr> |
|
85 <td><a href="#MicrosoftEngine.supportedLanguages">supportedLanguages</a></td> |
|
86 <td>Public method to get the supported languages.</td> |
|
87 </tr> |
|
88 </table> |
|
89 <h3>Static Methods</h3> |
|
90 <table> |
|
91 <tr><td>None</td></tr> |
|
92 </table> |
|
93 <a NAME="MicrosoftEngine.__init__" ID="MicrosoftEngine.__init__"></a> |
|
94 <h4>MicrosoftEngine (Constructor)</h4> |
|
95 <b>MicrosoftEngine</b>(<i>plugin, parent=None</i>) |
|
96 <p> |
|
97 Constructor |
|
98 </p><dl> |
|
99 <dt><i>plugin</i></dt> |
|
100 <dd> |
|
101 reference to the plugin object (TranslatorPlugin) |
|
102 </dd><dt><i>parent</i></dt> |
|
103 <dd> |
|
104 reference to the parent object (QObject) |
|
105 </dd> |
|
106 </dl><a NAME="MicrosoftEngine.__getAccessToken" ID="MicrosoftEngine.__getAccessToken"></a> |
|
107 <h4>MicrosoftEngine.__getAccessToken</h4> |
|
108 <b>__getAccessToken</b>(<i>requestObject</i>) |
|
109 <p> |
|
110 Private slot to get an access token. |
|
111 </p><p> |
|
112 If the stored token is no longer valid, get a new one and store it. |
|
113 </p><dl> |
|
114 <dt><i>requestObject</i></dt> |
|
115 <dd> |
|
116 reference to the request object |
|
117 (TranslatorRequest) |
|
118 </dd> |
|
119 </dl><dl> |
|
120 <dt>Returns:</dt> |
|
121 <dd> |
|
122 access token (string) |
|
123 </dd> |
|
124 </dl><a NAME="MicrosoftEngine.__getClientDataAzure" ID="MicrosoftEngine.__getClientDataAzure"></a> |
|
125 <h4>MicrosoftEngine.__getClientDataAzure</h4> |
|
126 <b>__getClientDataAzure</b>(<i></i>) |
|
127 <p> |
|
128 Private method to retrieve the client data. |
|
129 </p><dl> |
|
130 <dt>Returns:</dt> |
|
131 <dd> |
|
132 tuple giving the API subscription key and a flag indicating |
|
133 validity |
|
134 </dd> |
|
135 </dl><dl> |
|
136 <dt>Return Type:</dt> |
|
137 <dd> |
|
138 tuple of (str, bool) |
|
139 </dd> |
|
140 </dl><a NAME="MicrosoftEngine.__mapLanguageCode" ID="MicrosoftEngine.__mapLanguageCode"></a> |
|
141 <h4>MicrosoftEngine.__mapLanguageCode</h4> |
|
142 <b>__mapLanguageCode</b>(<i>code</i>) |
|
143 <p> |
|
144 Private method to map a language code to the Microsoft code. |
|
145 </p><dl> |
|
146 <dt><i>code</i></dt> |
|
147 <dd> |
|
148 language code (string) |
|
149 </dd> |
|
150 </dl><dl> |
|
151 <dt>Returns:</dt> |
|
152 <dd> |
|
153 mapped language code (string) |
|
154 </dd> |
|
155 </dl><a NAME="MicrosoftEngine.engineName" ID="MicrosoftEngine.engineName"></a> |
|
156 <h4>MicrosoftEngine.engineName</h4> |
|
157 <b>engineName</b>(<i></i>) |
|
158 <p> |
|
159 Public method to return the name of the engine. |
|
160 </p><dl> |
|
161 <dt>Returns:</dt> |
|
162 <dd> |
|
163 engine name (string) |
|
164 </dd> |
|
165 </dl><a NAME="MicrosoftEngine.getTextToSpeechData" ID="MicrosoftEngine.getTextToSpeechData"></a> |
|
166 <h4>MicrosoftEngine.getTextToSpeechData</h4> |
|
167 <b>getTextToSpeechData</b>(<i>requestObject, text, language</i>) |
|
168 <p> |
|
169 Public method to pronounce the given text. |
|
170 </p><dl> |
|
171 <dt><i>requestObject</i></dt> |
|
172 <dd> |
|
173 reference to the request object |
|
174 (TranslatorRequest) |
|
175 </dd><dt><i>text</i></dt> |
|
176 <dd> |
|
177 text to be pronounced (string) |
|
178 </dd><dt><i>language</i></dt> |
|
179 <dd> |
|
180 language code of the text (string) |
|
181 </dd> |
|
182 </dl><dl> |
|
183 <dt>Returns:</dt> |
|
184 <dd> |
|
185 tuple with pronounce data (QByteArray) or error string (string) |
|
186 and success flag (boolean) |
|
187 </dd> |
|
188 </dl><a NAME="MicrosoftEngine.getTranslation" ID="MicrosoftEngine.getTranslation"></a> |
|
189 <h4>MicrosoftEngine.getTranslation</h4> |
|
190 <b>getTranslation</b>(<i>requestObject, text, originalLanguage, translationLanguage</i>) |
|
191 <p> |
|
192 Public method to translate the given text. |
|
193 </p><dl> |
|
194 <dt><i>requestObject</i></dt> |
|
195 <dd> |
|
196 reference to the request object |
|
197 (TranslatorRequest) |
|
198 </dd><dt><i>text</i></dt> |
|
199 <dd> |
|
200 text to be translated (string) |
|
201 </dd><dt><i>originalLanguage</i></dt> |
|
202 <dd> |
|
203 language code of the original (string) |
|
204 </dd><dt><i>translationLanguage</i></dt> |
|
205 <dd> |
|
206 language code of the translation (string) |
|
207 </dd> |
|
208 </dl><dl> |
|
209 <dt>Returns:</dt> |
|
210 <dd> |
|
211 tuple of translated text (string) and flag indicating |
|
212 success (boolean) |
|
213 </dd> |
|
214 </dl><a NAME="MicrosoftEngine.hasTTS" ID="MicrosoftEngine.hasTTS"></a> |
|
215 <h4>MicrosoftEngine.hasTTS</h4> |
|
216 <b>hasTTS</b>(<i></i>) |
|
217 <p> |
|
218 Public method indicating the Text-to-Speech capability. |
|
219 </p><dl> |
|
220 <dt>Returns:</dt> |
|
221 <dd> |
|
222 flag indicating the Text-to-Speech capability (boolean) |
|
223 </dd> |
|
224 </dl><a NAME="MicrosoftEngine.supportedLanguages" ID="MicrosoftEngine.supportedLanguages"></a> |
|
225 <h4>MicrosoftEngine.supportedLanguages</h4> |
|
226 <b>supportedLanguages</b>(<i></i>) |
|
227 <p> |
|
228 Public method to get the supported languages. |
|
229 </p><dl> |
|
230 <dt>Returns:</dt> |
|
231 <dd> |
|
232 list of supported language codes (list of string) |
|
233 </dd> |
|
234 </dl> |
|
235 <div align="right"><a href="#top">Up</a></div> |
|
236 <hr /> |
|
237 </body></html> |