Fuente original
Código
Option Explicit '----------------------------------------------------------------------------------------------------- 'Autor: Leandro Ascierto 'Web: www.leandroascierto.com.ar 'Abreviaturas 'de, da, es, fi, fr, en, it, nl, pl, pt, sv" 'Alemán , Danés, Español, Finlandia, Francés, Inglés, Italiano, Neerlandés, Polaco, Portugués, Sueco '---------------------------------------------------------------------------------------------------- Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long Public Function GoogleSpeak(ByVal sText As String, Optional ByVal Language As String = "es", Optional ByVal bDoevents As Boolean) As Boolean On Error Resume Next Dim sTempPath As String, ml As String Dim FileLength As Long sText = Replace(sText, vbCrLf, " ") If Len(sText) > 100 Then Exit Function sTempPath = Environ("Temp") & "\TempMP3.MP3" If URLDownloadToFile(0&, "http://translate.google.com/translate_tts?tl=" & Language & "&q=" & sText, sTempPath, 0&, 0&) = 0 Then If mciSendString("open " & Chr$(34) & sTempPath & Chr$(34) & " type MpegVideo" & " alias myfile", 0&, 0&, 0&) = 0 Then ml = String(30, 0) Call mciSendString("status myfile length ", ml, 30, 0&) FileLength = Val(ml) If FileLength Then If mciSendString("play myFile", 0&, 0&, 0&) = 0 Then Do While mciSendString("status myfile position ", ml, 30, 0&) = 0 If Val(ml) = FileLength Then GoogleSpeak = True: Exit Do If bDoevents Then DoEvents Loop End If End If Call mciSendString("close myfile", 0&, 0&, 0&) End If Kill sTempPath End If End Function Private Sub Command1_Click() Debug.Print GoogleSpeak("Antes era sexo droga y rock and roll, ahora es paja mate y chamame", "es", True) Debug.Print GoogleSpeak("Siamo fuori della copa. un giorno tristissimo", "it", True) End Sub
Saludos.