01-04-15, 05:30 PM
أول شيء يتم إضافة المكتبة من Reference
Reference:> [COM] Windows Media Player :>wmp.dll
Reference:> [COM] Windows Media Player :>wmp.dll
كود :
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
GoogleTextToSpeech("ar", TextBox1.Text)
End Sub
Private Sub GoogleTextToSpeech(ByVal lang As String, ByVal text As String)
Try
Dim wc As New Net.WebClient()
wc.Headers.Add(Net.HttpRequestHeader.UserAgent, "Mozilla/5.0")
Dim data As Byte() = wc.DownloadData(String.Format("http://translate.google.com/translate_tts?tl={0}&q={1}", lang, text))
Dim file As String = IO.Path.GetTempFileName.Replace(".tmp", "") & ".mp3"
IO.File.WriteAllBytes(file, data)
Dim mp As New WMPLib.WindowsMediaPlayer()
mp.URL = file
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub