Google Translate API with Python

แชร์
ฝัง
  • เผยแพร่เมื่อ 24 ต.ค. 2024

ความคิดเห็น • 83

  • @ParwizForogh
    @ParwizForogh  3 ปีที่แล้ว +1

    You can support me on Patreon
    www.patreon.com/parwizforogh

  • @datasci1044
    @datasci1044 3 ปีที่แล้ว +21

    Showing error :AttributeError: 'NoneType' object has no attribute 'group'

    • @RomaxRajeev
      @RomaxRajeev 3 ปีที่แล้ว +18

      You would need to install a specific version of GoogleTrans package.
      pip3 uninstall googletrans
      pip3 install googletrans==3.1.0a0
      This is one of the solutions mentioned in Github issues.

    • @karankalani4002
      @karankalani4002 2 ปีที่แล้ว

      I m still getting the same error

    • @vincentlaizer
      @vincentlaizer 8 หลายเดือนก่อน

      any solution?

    • @vincentlaizer
      @vincentlaizer 8 หลายเดือนก่อน

      @@karankalani4002 any solution?

  • @dbsppesquisa1846
    @dbsppesquisa1846 2 ปีที่แล้ว +7

    Hi!!! I'm following your tutorial, but the following error appears: AttributeError: 'NoneType' object has no att. How to solve?

    • @492_alokjha9
      @492_alokjha9 2 ปีที่แล้ว +3

      were you able to fingure it out?If yes do share

    • @mathperson6927
      @mathperson6927 2 ปีที่แล้ว +5

      @@492_alokjha9 I got the same problem. Google Translate API has been updated. In your terminal, run this command: pip install googletrans==3.1.0a0
      This command will install the new googletranslate API. It will remove this error.
      Also, when you translate, make sure you say: translator.translate(text, dest="en"). The dest="en" makes sure that you are translating to english. If you wanted to translate to french, you would use dest="fr".
      I hope this helped!

    • @492_alokjha9
      @492_alokjha9 2 ปีที่แล้ว

      @@mathperson6927 Yes bro I was able to figure it out later. Thanks though

    • @lankydog2130
      @lankydog2130 2 ปีที่แล้ว +4

      @@mathperson6927 You now need to do:
      pip install googletrans==4.0.0-rc1

    • @mathperson6927
      @mathperson6927 2 ปีที่แล้ว

      Oh, there’s a new version now? Good to know!
      Thanks

  • @keqi2892
    @keqi2892 2 ปีที่แล้ว +2

    Hi, when I try to do exactly that kind of translate, I get this kind of error:
    httpcore._exceptions.ConnectTimeout: _ssl.c:1106: The handshake operation timed out

  • @rafialfarisi7462
    @rafialfarisi7462 3 ปีที่แล้ว +5

    i got this error AttributeError: 'NoneType' object has no attribute 'group'

    • @phgodoycosta5956
      @phgodoycosta5956 3 ปีที่แล้ว

      me too

    • @TheGeniusfire
      @TheGeniusfire 3 ปีที่แล้ว +13

      i got this too because of some issues of this module,but i fixed it with another version of googletrans.You can use "pip install googletrans==3.1.0a0" instead,everything work fine now.But as i found,this module is no longer supported and you should use google cloud translate for better result.

    • @youngandy7304
      @youngandy7304 3 ปีที่แล้ว +1

      @@TheGeniusfire +1 respect for "Đồng Bào"

    • @justaverage8111
      @justaverage8111 3 ปีที่แล้ว +1

      @@TheGeniusfire Thank you so much

    • @ashvinpkumar574
      @ashvinpkumar574 3 ปีที่แล้ว +1

      @@TheGeniusfire I was looking for this solution for 2 hours thank your soo much....u are my saver

  • @divyasingh3856
    @divyasingh3856 3 ปีที่แล้ว +2

    Getting an error of SSL: Certificate_verify_failed, what to do for this can you suggest

  • @mathewaju
    @mathewaju 3 ปีที่แล้ว +2

    Is it possible to pass an entire document for translation to this api? Like docx or pdf

  • @lavizlay
    @lavizlay 3 ปีที่แล้ว +4

    Hi, when I try to do exactly that kind of translate, I get this kind of error;
    Traceback (most recent call last):
    File "c:\Users\Momentum\Desktop\yandexTranslateTxt.py", line 15, in
    translated_text = Translator().translate(text, src='en', dest='tr')
    File "C:\Users\Momentum\AppData\Local\Programs\Python\Python39\lib\site-packages\googletrans\client.py", line 182, in translate
    data = self._translate(text, dest, src, kwargs)
    File "C:\Users\Momentum\AppData\Local\Programs\Python\Python39\lib\site-packages\googletrans\client.py", line 78, in _translate
    token = self.token_acquirer.do(text)
    File "C:\Users\Momentum\AppData\Local\Programs\Python\Python39\lib\site-packages\googletrans\gtoken.py", line 194, in do
    self._update()
    File "C:\Users\Momentum\AppData\Local\Programs\Python\Python39\lib\site-packages\googletrans\gtoken.py", line 62, in _update
    code = self.RE_TKK.search(r.text).group(1).replace('var ', '')
    AttributeError: 'NoneType' object has no attribute 'group'

    • @mfatihy70
      @mfatihy70 3 ปีที่แล้ว +12

      You would need to install a specific version of GoogleTrans package.
      pip3 uninstall googletrans
      pip3 install googletrans==3.1.0a0
      yukardaki eleman yazmis gördün mü bilmem ama

    • @alifurkan3106
      @alifurkan3106 3 ปีที่แล้ว

      @@mfatihy70 Reis birşey sorabilir miyim?

    • @mfatihy70
      @mfatihy70 3 ปีที่แล้ว

      @@alifurkan3106 hayir mi diyecrm knk sor

    • @alifurkan3106
      @alifurkan3106 3 ปีที่แล้ว

      @@mfatihy70 Bu uygulamayla birlikte artık çeviriyi istediğimiz zaman kullanabiliriz demi? Yani mesela diyelim ki google ücret getirdi ve artık translate belli bir ücret karşılığında internetten kullanılmaya başlanacak peki bu uygulama üzerinden yine kullanabilecek miyiz? Sağolasın. Sorumun özeti şu bu yapılan şey yine internette ki çeviriye muhtaç mı?

    • @mfatihy70
      @mfatihy70 3 ปีที่แล้ว

      @@alifurkan3106 evet translate sunucularına bağlanıyor direkt çeviri dosyalarını indirmiyor

  • @akshayjain8302
    @akshayjain8302 3 ปีที่แล้ว +4

    Is there is any limitations of using google trans library as I can see after certain searches it won't work and provide the same results as what we are giving as input

    • @priyankasaxena802
      @priyankasaxena802 2 ปีที่แล้ว

      did u get any solution?

    • @kirito9991
      @kirito9991 2 ปีที่แล้ว

      @@priyankasaxena802 if you are making a loop, try time.sleep(10) in between each interation, otherwise google will just end up temporarily banning your ip

  • @montezmusic
    @montezmusic 3 ปีที่แล้ว +1

    I'm getting this error please help me sir.
    Listening...
    Recognizing...
    User said: translate hello
    'NoneType' object has no attribute 'group'
    Code:elif 'translate' in query:
    try:
    speak('translating your sentences or words.....')
    query=query.replace("translate", " ")
    translator =Translator()
    result=translator.translate(query,dest='hi')
    speak('according the google translate')
    print(result.pronunciation)
    speak(result.pronunciation)
    except Exception as e:
    print(e)
    speak("try with the another sentences or try after sometime")

    • @lankydog2130
      @lankydog2130 2 ปีที่แล้ว +1

      You need to get the updated version, pip install googletrans==4.0.0-rc1

  • @amrmagdy_smarthome
    @amrmagdy_smarthome 3 ปีที่แล้ว +3

    Pls How can i print my translated words only ??

    • @cesaroliva5043
      @cesaroliva5043 6 หลายเดือนก่อน

      print(translator.translate(text, dest='en').text)
      Too late, but for anyone who need it

  • @explorerofinfinity722
    @explorerofinfinity722 ปีที่แล้ว

    Hi.. it is showing ModuleNotFoundError: No module named 'googletrans' after 'pip install googletrans'.

  • @SilverMiraii
    @SilverMiraii 2 ปีที่แล้ว +3

    it doesn't work anymore

    • @kyozuperso5613
      @kyozuperso5613 2 ปีที่แล้ว

      Why ?

    • @kyozuperso5613
      @kyozuperso5613 2 ปีที่แล้ว

      it dosnn"t work for me to. but why.

    • @mathperson6927
      @mathperson6927 2 ปีที่แล้ว +2

      @@kyozuperso5613 there is a new googletranslate update. you need to run this in your terminal: pip install googletrans==3.1.0a0
      im not really sure what your error is but it looks like thats what the majority of the comments here are asking for so im going to guess that you have the same problem
      hope this helped!

    • @kyozuperso5613
      @kyozuperso5613 2 ปีที่แล้ว

      @@mathperson6927 i already solved the problem but yea it was. Thanks you :)

    • @SilverMiraii
      @SilverMiraii ปีที่แล้ว

      @mathperson6927 confirmed, works, thank you

  • @bridgetanon9030
    @bridgetanon9030 3 ปีที่แล้ว +1

    It's not really translating, thought, is it? It's just substituting variables

  • @shehikes5888
    @shehikes5888 2 ปีที่แล้ว

    Hi,
    Do we get my memory warning error.
    i mean , is there any limit to translate words?

  • @programacaosimples
    @programacaosimples 3 ปีที่แล้ว

    Is it possible to get the examples and definition of the word in the native language if you use this package? For example, if I translate the word "luego" from spanish I get "soon" as a translation, but I also get an example: "primero comieron y luego tomaron café." and the word definition in spanish: "Más tarde en el tiempo, inmediatamente después o en un momento no muy lejano; puede referirse tanto al tiempo del cual se habla como al momento en el que se habla o se escribe".
    My point is: I want to construct a database with the original word, the translation, the example and the definition too. Is it possible? I did it using selenium, but it takes too much time.

    • @teajay6545
      @teajay6545 2 ปีที่แล้ว +1

      Hey I don’t know if you still need this but Google now how’s an advance glossary feature with let’s you set a predefined custom definition like you described.

  • @ThunderLightning-go5wj
    @ThunderLightning-go5wj 4 หลายเดือนก่อน +1

    the ratio is broken

  • @rainerpavletic4814
    @rainerpavletic4814 ปีที่แล้ว

    How can we use this to translate an HTML page?

  • @amitaggarwal4908
    @amitaggarwal4908 3 ปีที่แล้ว

    very helpful for app I am making

  • @ShoaibShoobi
    @ShoaibShoobi 4 ปีที่แล้ว +1

    how to use this for dataset column please guide

    • @abhishekchavan6943
      @abhishekchavan6943 3 ปีที่แล้ว

      you can select the entire column by using df['column_name'] = df['Orginalcolumn'].apply(translator.translate, src='en', dest='hi').apply(getattr, args=('text',))

  • @Good_Morning_Musa
    @Good_Morning_Musa ปีที่แล้ว

    Thanks from Russia

  • @Gia_Java
    @Gia_Java 3 ปีที่แล้ว

    Helpful! Thanks!

  • @nefertaripramudhita5611
    @nefertaripramudhita5611 3 ปีที่แล้ว

    im sorry but your mic pick up too much high frequency making it unpleasant to hear. but good tutorial anyway!

  • @buddhadebsarkar1708
    @buddhadebsarkar1708 2 ปีที่แล้ว +1

    no longer working.

  • @seyedsomaye
    @seyedsomaye ปีที่แล้ว

    دمت گرم

  • @zeyadrhadi2285
    @zeyadrhadi2285 3 ปีที่แล้ว +1

    very excellent

  • @adoni820
    @adoni820 2 ปีที่แล้ว

    thank you.

  • @ortasekerli
    @ortasekerli 3 ปีที่แล้ว

    Nice to see Turkish

  • @lankydog2130
    @lankydog2130 2 ปีที่แล้ว +1

    If you want the translated text do translator.translate(text2).text

  • @WisdomShortvids
    @WisdomShortvids 3 ปีที่แล้ว

    no longer works

  • @arat9573
    @arat9573 3 ปีที่แล้ว

    the error i keep getting TypeError: translate() missing 1 required positional argument: 'text'

    • @mathperson6927
      @mathperson6927 2 ปีที่แล้ว

      Ah yes. You need to put in the text you want to translate. For example:
      import googletrans
      from googletrans import Translator
      translator = Translator()
      result = translator.translate("Hola", dest="en")
      print(result)
      The translator.translate requires you to put in the text you want to translate, and what language you want to translate it to. This program should print out an array, and in the array, one of the elements should be: text=hello
      I hope this helped!

  • @ThunderLightning-go5wj
    @ThunderLightning-go5wj 4 หลายเดือนก่อน

    views are way more than the likes

  • @Shobhikagarg
    @Shobhikagarg 4 ปีที่แล้ว

    Can u pls make a video on how to photo upload n nested serialiser by django rest API

  • @kripo_se
    @kripo_se ปีที่แล้ว

    The S sound is hurting my ears

  • @UsmanKhan-hu8hw
    @UsmanKhan-hu8hw 2 ปีที่แล้ว

    is it free?

    • @mathperson6927
      @mathperson6927 2 ปีที่แล้ว

      Yes it is!
      Just type “pip install googletrans==4.0.0-rc1” in your terminal and wait for it to install. Then it will be free to use!

  • @emr_yasa_
    @emr_yasa_ 4 ปีที่แล้ว +4

    +1

    • @alifurkan3106
      @alifurkan3106 3 ปีที่แล้ว

      Kanka bir soru sorabilir miyim?

    • @emr_yasa_
      @emr_yasa_ 3 ปีที่แล้ว

      @@alifurkan3106 Sorabilirsin ;)

  • @fyigittemur
    @fyigittemur 2 ปีที่แล้ว

    im turkish :)) 3:01

  • @TrendTrajectory
    @TrendTrajectory 2 ปีที่แล้ว

    How can I translate a text file using this api

    • @mathperson6927
      @mathperson6927 2 ปีที่แล้ว

      you can use files
      for example, you could say
      filevar = open("filename.txt", r)
      #iterate through file
      #create list to append characters to
      lst = []
      for characters in filevar:
      #adds characters to list
      lst.append(characters)
      #join list
      words = lst.join("")
      words is a string, so now you can use the googletranslate api.
      translator = Translator()
      translation = translator.translate(words, dest="en") #converts whatever language the file is, to english
      print(translation)
      The entire code would be:
      import googletrans
      from googletrans import Translator
      translator = Translator()
      filevar = open("filename.txt", r)
      #iterate through file
      #create list to append characters to
      lst = []
      for characters in filevar:
      #adds characters to list
      lst.append(characters)
      #join list
      words = lst.join("")
      translator = Translator()
      translation = translator.translate(words, dest="en") #converts whatever language the file is, to english
      print(translation)
      #----------------------------------------------------------------------------
      Now say you wanted to replace the file with the translated text. You could do this by overwriting the file. This would be done by running the following code:
      import googletrans
      from googletrans import Translator
      translator = Translator()
      filevar = open("filename.txt", "r") #reads file
      #iterate through file
      #create list to append characters to
      lst = []
      for characters in filevar:
      #adds characters to list
      lst.append(characters)
      filevar.close() #closes the file because you are done using it
      #join list
      words = lst.join("")
      translator = Translator()
      translation = translator.translate(words, dest="en") #converts whatever language the file is, to english
      filevar1 = open("filename.txt", "w") #instead of reading file, its going to write in the file. If you wanted to add content to the current file, you could use "a" instead of "w". "a" stands for append.
      filevar1.write(words) #overwrites the file and replaces the old text with the new translated text
      filevar1.close()
      #-------------------------------------------------------------------------
      you can now view the file and hopefully there should be new text
      note: i haven't run any of this code yet. There might be a few errors but I hope this gave you an idea of what you can do.
      Hope this helped!