Comments (8)
Does this code try all the engines one by one or at the same time with multi-threads?
By default one at a time. You can set the fast
argument to do multi-threaded translation.
I want to set a global request timeout to make it fail quickly
I have tested all possible solutions in my opinion and it seems to me that there is no solution yet. As a workaround, I can recommend using the WARP proxy.
from translate.
I know that translatepy is working with multiple engines. Does this code try all the engines one by one or at the same time with multi-threads?
Yup, as said you can use the fast
parameter to test them all at once.
I want to set a global request timeout to make it fail quickly, like this
t = Translator(request=Request(timeout=10))
This should work :
Reopen the issue if you have any further question 👍
from translate.
Thanks for your replying. It looks like a good way to set this. but, I can't impot Session
from from translatepy.utils.request
from translatepy.utils.request import Session
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'Session' from 'translatepy.utils.request' (/Users/xxx/py3/lib/python3.11/site-packages/translatepy/utils/request.py)
This is my translatepy version.
~ % python -c "import translatepy; print(translatepy.__version__)"
translatepy v2.3
I tried another way:
from translatepy import Translate
from requests import Session
s=Session()
s.timeout=10
t = Translate(session=s)
Got error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: Translate.__init__() got an unexpected keyword argument 'session'
Actually, there is no parameter names session for Translate
from translate.
I've no privilege to reopen this issue. @Animenosekai
from translate.
I've no privilege to reopen this issue. @Animenosekai
Riiiight sorry I forgot let me reopen this real quick
from translate.
This is my translatepy version.
Try installing the new-models
branch version, as explained in #85 (comment) I'll try to merge it soon.
To install the new-models
branch version, you need to have git
installed on your computer and run :
pip install --upgrade git+https://github.com/Animenosekai/translate.git@new-models
from translate.
Also this is the code I wrote to quickly test the session system :
from translatepy import Translate
from translatepy.utils.request import Session
s = Session()
s.timeout = 10
t = Translate(session=s)
print(t.translate("Hello world", "Japanese"))
$ translatepy --version
translatepy v3.0(alpha) # output
from translate.
Thanks! Great job!
from translate.
Related Issues (20)
- Consider adding the formality and glossary feature to DeepL HOT 5
- Bulk Translation support? HOT 2
- NoResult: No service has returned a valid result HOT 8
- Missing spaces between tags when using translate_html HOT 2
- Bing Translator throwing error code 205 HOT 5
- Not accurate source language autodetection HOT 14
- Language auto detecting is broken in MyMemory HOT 3
- example() not working HOT 1
- Next: 3.0 HOT 24
- Different Translation on Yandex HOT 11
- Result mismatch Google Translate HOT 5
- MicrosoftTranslate.text_to_speech is not working HOT 8
- Is the DeepL split text correct? HOT 3
- [SERVER]: cannot import name 'General' from 'nasse.config' HOT 1
- the lang tr is not supported by deepl error (even though it has) HOT 1
- Links and hashtags seem to change after translation HOT 10
- ReversoTranslator BUG HOT 7
- No module named 'translatepy.utils' (on Windows) HOT 2
- Traditional Chinese HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from translate.