Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MicrosoftTranslate.text_to_speech is not working #81

Open
kuk71 opened this issue Apr 3, 2023 · 8 comments
Open

MicrosoftTranslate.text_to_speech is not working #81

kuk71 opened this issue Apr 3, 2023 · 8 comments

Comments

@kuk71
Copy link

kuk71 commented Apr 3, 2023

from translatepy.translators.microsoft import MicrosoftTranslate

t = MicrosoftTranslate()

result = t.text_to_speech("Hello", 65, "male", "eng")

Traceback (most recent call last):
File "D:\Project\Python\translate\123.py", line 3, in
t = MicrosoftTranslate()
File "D:\Project\Python\translate\translatepy\translators\microsoft.py", line 88, in init
self.session_manager = MicrosoftSessionManager(request)
File "D:\Project\Python\translate\translatepy\translators\microsoft.py", line 39, in init
self._parse_authorization_data()
File "D:\Project\Python\translate\translatepy\translators\microsoft.py", line 46, in parse_authorization_data
token_response = self.bing_session.send(url123, data={})
File "D:\Project\Python\translate\translatepy\translators\bing.py", line 106, in send
response = request.json()
File "D:\Project\Python\translate\translatepy\utils\request.py", line 80, in json
return loads(self.text, **kwargs)
File "C:\Users\Виктор\AppData\Local\Programs\Python\Python310\lib\json_init
.py", line 346, in loads
return _default_decoder.decode(s)
File "C:\Users\Виктор\AppData\Local\Programs\Python\Python310\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Users\Виктор\AppData\Local\Programs\Python\Python310\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Process finished with exit code 1

@ZhymabekRoman
Copy link
Contributor

Token fetch endpoint seems to shutdown and Microsoft Translate stops working. Need to drop Microsoft Translate class.

@Animenosekai
Copy link
Owner

Token fetch endpoint seems to shutdown and Microsoft Translate stops working. Need to drop Microsoft Translate class.

I think the author of d4n3436/GTranslate wrote a token generation function:

#62 (reply in thread)

@ZhymabekRoman
Copy link
Contributor

I think the author of d4n3436/GTranslate wrote a token generation function:

The author only uses TTS API endpoint of Bing Translate web interface.

In old days I was investigating that web version of Bing Translate has a special API endpoint that generates an API token to use Microsoft Translate API. And it's intended for TTS. Microsoft Translate is like Bing Translate, but paid. So I used this backdoor to use the whole Microsoft Translate service for free by using the API token generated by the Bing TTS endpoint. Now this endpoint is unavailable.

@kuk71
Copy link
Author

kuk71 commented Apr 4, 2023

Is it possible to restore access to the Bing Translate class? Now accessing this class throws an DEPRECATED exception.

@d4n3436
Copy link

d4n3436 commented Apr 5, 2023

I think the author of d4n3436/GTranslate wrote a token generation function:

The author only uses TTS API endpoint of Bing Translate web interface.

Hello, as I mentioned before in my comment, I reverse-engineered the signature generation of the Microsoft Translator Android app, so it's now possible to use the Microsoft Translate APIs without any tokens, except for the TTS endpoint. The code is in MicrosoftTranslator.cs.

@ZhymabekRoman
Copy link
Contributor

Hello, as I mentioned before in my comment, I reverse-engineered the signature generation of the Microsoft Translator Android app, so it's now possible to use the Microsoft Translate APIs without any tokens, except for the TTS endpoint.

Can we port your implementation to Python 3 and use it in translatepy?

@d4n3436
Copy link

d4n3436 commented May 27, 2023

Can we port your implementation to Python 3 and use it in translatepy?

Sure, you can.

@ZhymabekRoman
Copy link
Contributor

So I started to port the new Microsoft Translate implementation based on the d4n3436 version, but unfortunately I couldn't get it to work successfully. It's bad news. Good news - I implemented another endpoint by reverse engineering Microsoft SwiftKey. See #88

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants