Skip to content

Much faster translating speed using deep_translator google translate

License

Notifications You must be signed in to change notification settings

MasterOvO/deep_translator_improvedBatchTranslate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

deep_translator_improvedBatchTranslate

-Much faster translating speed using deep_translator google translate

#improve version of deep_translator googletranslator .translate_batch function

#cause orignal batch_translate cant run >5000 character, and slow

#use mutiple thread to run faster

example of usage:

#test for speed

testing_lst = [f"你很快嗎, 我比較快{n}" for n in range(200)]

slow_translator = GoogleTranslator(target="en")

improve_translator = threading_googletranslator(target="en")

start_time_slow = time.time()

#a = slow_translator.translate_batch(testing_lst)

end_time_slow = time.time()

print("Runtime of original batch translator: ", end_time_slow-start_time_slow, "s")

#runtime = 50s

start_time_improve = time.time()

b = improve_translator.improved_translate_batch(testing_lst, thread_count=10)

end_time_improve = time.time()

print(b)

print("Runtime of improve batch translator: ", end_time_improve-start_time_improve, "s")

#runtime = 7s

About

Much faster translating speed using deep_translator google translate

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages