Foro de elhacker.net

Programación => Programación Visual Basic => Mensaje iniciado por: LeandroA en 1 Diciembre 2010, 06:28 am



Título: [SPINET]Google Speak
Publicado por: LeandroA en 1 Diciembre 2010, 06:28 am
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)

Código
  1. Option Explicit
  2. '-----------------------------------------------------------------------------------------------------
  3. 'Autor: Leandro Ascierto
  4. 'Web: www.leandroascierto.com.ar
  5. 'Abreviaturas
  6. 'de, da, es, fi, fr, en, it, nl, pl, pt, sv"
  7. 'Alemán , Danés, Español, Finlandia, Francés, Inglés, Italiano, Neerlandés, Polaco, Portugués, Sueco
  8. '----------------------------------------------------------------------------------------------------
  9. 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
  10. 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
  11.  
  12.  
  13. Public Function GoogleSpeak(ByVal sText As String, Optional ByVal Language As String = "es", Optional ByVal bDoevents As Boolean) As Boolean
  14.    On Error Resume Next
  15.    Dim sTempPath As String, ml As String
  16.    Dim FileLength As Long
  17.  
  18.    sText = Replace(sText, vbCrLf, " ")
  19.  
  20.    If Len(sText) > 100 Then Exit Function
  21.  
  22.    sTempPath = Environ("Temp") & "\TempMP3.MP3"
  23.  
  24.    If URLDownloadToFile(0&, "http://translate.google.com/translate_tts?tl=" & Language & "&q=" & sText, sTempPath, 0&, 0&) = 0 Then
  25.  
  26.        If mciSendString("open " & Chr$(34) & sTempPath & Chr$(34) & " type MpegVideo" & " alias myfile", 0&, 0&, 0&) = 0 Then
  27.  
  28.            ml = String(30, 0)
  29.            Call mciSendString("status myfile length ", ml, 30, 0&)
  30.            FileLength = Val(ml)
  31.            If FileLength Then
  32.                If mciSendString("play myFile", 0&, 0&, 0&) = 0 Then
  33.                    Do While mciSendString("status myfile position ", ml, 30, 0&) = 0
  34.                        If Val(ml) = FileLength Then GoogleSpeak = True: Exit Do
  35.                        If bDoevents Then DoEvents
  36.                    Loop
  37.                End If
  38.            End If
  39.            Call mciSendString("close myfile", 0&, 0&, 0&)
  40.  
  41.        End If
  42.  
  43.        Kill sTempPath
  44.    End If
  45.  
  46. End Function
  47.  
  48.  
  49. Private Sub Command1_Click()
  50.   Debug.Print GoogleSpeak("Antes era sexo droga y rock and roll, ahora es paja mate y chamame", "es", True)
  51.    Debug.Print GoogleSpeak("Siamo fuori della copa. un giorno tristissimo", "it", True)
  52. End Sub
  53.  


Saludos.


Título: Re: [SPINET]Google Speak
Publicado por: agus0 en 1 Diciembre 2010, 10:51 am
Esta de Diez pero... "URLDownloadToFile" no hace saltar la Heuristica de bastantes antivirus??


Título: Re: [SPINET]Google Speak
Publicado por: LeandroA en 1 Diciembre 2010, 15:13 pm
Esta de Diez pero... "URLDownloadToFile" no hace saltar la Heuristica de bastantes antivirus??

si, puse esa api por practicidad pero se puede usar cual quier otro metodo para descargar, por ejemplo este (http://foro.elhacker.net/programacion_visual_basic/solucionado_descargar_un_archivo_de_internet-t312040.0.html;msg1548116#msg1548116)

Saludos.


Título: Re: [SPINET]Google Speak
Publicado por: agus0 en 1 Diciembre 2010, 18:59 pm
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