Holas, esta es una simple función para utilizar el api de google speak, sirve para llevar un texto a vos, el apis se limita solo a 100 caracteres, cuenta con tres parámetros el primero es el texto a pronunciar, el segundo la acentuación (español ="es"), y el tercero para llamar a DoEvents si se quiere.
Fuente original (http://www.leandroascierto.com.ar/tips.php#GOOGLE_SPEAK)
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.
Esta de Diez pero... "URLDownloadToFile" no hace saltar la Heuristica de bastantes antivirus??
jajaja me imagine que se puede usar cualquiera solo te decía.
Ya lo vi el método ese si me lo paso BlackZeroX a mi :P