منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب

نسخة كاملة : قراءة النص باستخدام جوجل Google Text To Speech
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
أول شيء يتم إضافة المكتبة من Reference
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