get Google Translate TTs Speech

Dossfm0q

Banned User
Joined
Mar 9, 2009
Messages
570
Office Version
  1. 2019
Platform
  1. Windows
how to get URL below from Google TTS speech after click Liston Button from inspect Element >> F11 window >> then Network?
can I filter what I need as Medea then copy it through VBA ?
I have problem with ( "Ctrl+4 " SendKeys String:="^4") Some time works and some not, also Keyboard " Num Lock" deactivate how to reactivate

"https://translate.google.com.sa/tra...n=3&tk=656820.834353&client=webapp&prev=input"
VBA Code:
Public Sub Google_TTS()

''''''''''''''
ClosingIE ' Close open IE
'''''''''''''''
    Dim IE As InternetExplorer
    Set IE = Nothing
    Set IE = CreateObject("InternetExplorer.application")
    IELang = "hl=" & "en"
    TrnsFrom = "sl=" & "en"
    TrnsTo = "tl=" & "ar"
    TXT = "My Car" ' orActiveCell
    StrUrl = "https://translate.google.com/?" & IELang & "&tab=wT1&authuser=0#view=home&op=translate&" & TrnsFrom & "&" & TrnsTo & "&text=" & TXT
    With IE
    .Navigate StrUrl
    .Visible = True
  
        SendKeys String:="{F12}" ' call  Inspect Elements
      
        While .Busy Or .ReadyState < 4: DoEvents: Wend
        '.Document.queryselector(".ttsbutton").Click ' or
         Application.Wait Now + TimeValue("00:00:01")
        .Visible = True ' reactive IE for "Ctrl+4 "  SendKeys String:="^4"
        
        ' Some time work smoe not work
        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
         SendKeys String:="^4" ' call  Inspect Elements Network
        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
         While .Busy Or .ReadyState < 4: DoEvents: Wend

        .Document.queryselector(".src-tts").Click ' all of them work will
      
       '.Quit
       Set IE = Nothing
    End With
End Sub
Private Sub ClosingIE()

On Error Resume Next
    Dim objWMI As Object, objProcess As Object, objProcesses As Object
    Set objWMI = GetObject("winmgmts://.")
    Set objProcesses = objWMI.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'iexplore.exe'")
    For Each objProcess In objProcesses
        Call objProcess.Terminate
    Next
    Set objProcesses = Nothing: Set objWMI = Nothing
    On Error GoTo 0
End Sub
 

Attachments

  • network.gif
    network.gif
    232 KB · Views: 26

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Hi - this is a good attempt. There are a few suggestions I would make about changing your code because a fair bit of it is unnecessary.

I know that this has been accomplished by someone in Python (and not VBA), and it does it really well - called gTTS. You could always run that through a shell in VBA and create mp3s that way. It'd be easier. The point is, reading how they had to do it in python suggests that it's going to be a bit tricky.

If you really want to do it only in VBA, I suppose you could always record a WAV file through your microphone as you play the sound. There is VBA code that can do that. It wouldn't sound great though.
 
Upvote 0

Forum statistics

Threads
1,223,934
Messages
6,175,492
Members
452,649
Latest member
mr_bhavesh

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top