Visual Basic Foro
Programación => Visual Basic .NET / C# => Mensaje iniciado por: _katze_ en Agosto 11, 2011, 10:18:58 pm
-
bueno ya que utilise la funcion de leandro del googlespeak ahora la pase a vb.net para aquellos que la necesiten...esta tal cual asi que creditos a el! tiene un try catch noc si sera el correcto pero la logica la es!
<System.Runtime.InteropServices.DllImport("winmm.dll")> _
Private Shared Function mciSendString(ByVal lpstrCommand As String, _
ByVal lpstrReturnString As StringBuilder, ByVal uReturnLength As Integer, ByVal hwndCallBack As Integer) As Integer
End Function
Public Sub GoogleSpeak(ByVal text As String, Optional ByVal lenguaje As String = "es", Optional ByVal bdoevents As Boolean = True)
Dim temp As String = Environment.CurrentDirectory & "\temp.mp3"
Dim uri As String = "http://translate.google.com/translate_tts?tl=" & lenguaje & "&q=" & text
Try
My.Computer.Network.DownloadFile(Uri, temp)
If mciSendString("open " & temp & " type MpegVideo" & " alias myfile", Nothing, 0, 0) = 0 Then
Dim buff As New StringBuilder(256)
Call mciSendString("status myfile length ", buff, 256, 0)
Dim lenght As Long = CType(Long.Parse(buff.ToString()) / 1000, Long)
If lenght Then
If mciSendString("play myFile", Nothing, 0, 0) = 0 Then
Do While mciSendString("status myfile position ", buff, 256, 0) = 0
If CType(Long.Parse(buff.ToString()) / 1000, Long) = lenght Then Exit Do
If bdoevents Then Application.DoEvents()
Loop
End If
End If
Call mciSendString("close myfile", Nothing, 0, 0)
System.IO.File.Delete(temp)
End If
Catch ex As System.IO.IOException
If System.IO.File.Exists(temp) Then
System.IO.File.Delete(temp)
End If
End Try
End Sub