-
Notifications
You must be signed in to change notification settings - Fork 61
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
BingTranslate.text_to_speech is not working #24
Comments
Ref: #23 (comment) |
Hmm, it looks like Bing has slightly changed the response, issue fix patch:
|
git clone --depth 1 https://github.com/Animenosekai/translate && cd translate
mv translatepy/translators/bing.py translatepy/translators/bing.py.bak
sed '202s/)/, 200&/' translatepy/translators/bing.py.bak > translatepy/translators/bing.py
mv setup.py setup.py.bak
sed -E '/version =/s/"([^"]+)"/"\1b"/' setup.py.bak > setup.py
python -m pip install -U . from translatepy.translators.bing import BingTranslate
t = BingTranslate()
r = t.text_to_speech("こんにちは")
print(type(r)) <class 'translatepy.models.TextToSpechResult'> |
git clone -q --depth 1 https://github.com/Animenosekai/translate && cd translate ?[main]
mv translatepy/utils/request.py translatepy/utils/request.py.bak
sed '84s/"/# &/' translatepy/utils/request.py.bak > translatepy/utils/request.py
mv translatepy/translators/bing.py translatepy/translators/bing.py.bak
sed '202s/)/, 200&/' translatepy/translators/bing.py.bak > translatepy/translators/bing.py
mv setup.py setup.py.bak
sed -E '/version =/s/"([^"]+)"/"\1c"/' setup.py.bak > setup.py
python -m pip install -U .
|
When executing test, it is possible that continuous execution without wait has an effect. from translatepy.translators.bing import BingTranslate
t = BingTranslate()
r = t.text_to_speech("Привет")
print(type(r)) <class 'translatepy.models.TextToSpechResult'> |
Thank you, yes, indeed, tests fall with an error. I can assume that the problem is getting a token from the dictionary, most likely the Bing servers started returning slightly different keys and values. I will try to fix it in the near future. Sample code that causes the error:
|
https://github.com/Animenosekai/translate/runs/3588219963 from random import ramdom
from time import sleep
def rand_sleep(base: float = 0.1, rand: float = 2.5) -> None:
sleep(base + rand * random()) |
Deepl also have very strict restrictions
Will it save from the rate limit? It seems to me that it is best to pass all traffic through a proxy (or write a Tor Request adapter-class) |
I found this sleep function in one of my old project from time import sleep as _sleep
from random import random, randrange
def sleep(duration: float, deviation: float = 0):
"""
Stops the execution for the given number of seconds, with randomness from the given deviation
The deviation is calculated as follow:
random() gives a number between 0 and 1
We change it's range to 0 ~ DEVIATION
We determine if it will be added or substracted (multiply by 1 or -1)
We divide it by 100 to get the the result between 0 and 1 (the deviation is a percentage)
We change it's range to 0 ~ duration
We restrict the result to be positive
"""
deviation = (random() * deviation) * (1 if randrange(2) == 0 else -1) / 100 * duration
duration += deviation
if duration < 0:
duration = 0
_sleep(duration) |
True, but that's why there is the
Hmmm I guess that's what the |
Oops GitHub automatically closed the issue after the merge... Let me know if someone wanted to add anything, in which case I'll reopen it |
In translatepy 2.0:
The text was updated successfully, but these errors were encountered: