تقييم الموضوع :
  • 1 أصوات - بمعدل 1
  • 1
  • 2
  • 3
  • 4
  • 5
[سؤال] arabic text to speech
#6
تفضلوا التطبيق



بما انه بالسي شارب سأضع الدالة الرئيسية لجلب الصوت وتشغيله >

PHP كود :
Private Sub DownloadAndPlay()
    Try
        
'main delecration'
        
Dim soundData As Byte()
        
Dim url As String String.Format("http://translate.google.com/translate_tts?tl={0}&q={1}"comboBox1.Text.ToLower(), textBox1.Text.Trim())

        
'create requset'
        
Dim rq As HttpWebRequest TryCast(WebRequest.Create(url), HttpWebRequest)
        
rq.UserAgent "Mozilla/5.0 (Windows NT 6.1; rv:27.0) Gecko/20100101 Firefox/27.0"

        'read response'
        
Dim response As HttpWebResponse TryCast(rq.GetResponse(), HttpWebResponse)
        
Using stream As New BinaryReader(response.GetResponseStream())
            
soundData stream.ReadBytes(CInt(response.ContentLength))
            
stream.Close()
            
response.Close()
        
End Using


        
'create voice file in windows-temprary folder'
        
Dim tempFilePath As String CreateTempFile(soundData)

        
'play temprary-file sound'
        
PlaySound(tempFilePath)

    Catch 
ex As Exception
        MessageBox
.Show(ex.Message)
    
End Try
End Sub

Private Function CreateTempFile(data As Byte()) As String
    
'sound format is mpeg'
    
Dim soundFileName As String System.IO.Path.GetTempPath() & Guid.NewGuid().ToString() & ".mpeg"
    
File.WriteAllBytes(soundFileNamedata)
    Return 
soundFileName
End 
Function

Private 
Sub PlaySound(file As String)
    
'initlize player'
    
Dim player As New WMPLib.WindowsMediaPlayer()
    
player.settings.volume 100
    player
.settings.autoStart True
    AddHandler player
.PlayStateChangeAddressOf player_PlayStateChange
    player
.URL file
End Sub

Private Sub player_PlayStateChange(NewState As Integer)
    
Application.DoEvents()
    If 
NewState CInt(WMPLib.WMPPlayState.wmppsMediaEndedThen
        
'release everything'
        
toolStripProgressBar1.Style ProgressBarStyle.Blocks
    End 
If
End Sub 


طبعا لاتنسوا اضافة مكتبة Windows Media Player المسؤولة عن تشغيل الاصوات (موجود في تاب COM في Add Reference)




الملفات المرفقة
.rar   WordSpeaker.rar (الحجم : 169.89 ك ب / التحميلات : 559)
الرد }}}
تم الشكر بواسطة: Sajad , Basil Abdallah , Basil Abdallah , a7med saba , abiza


الردود في هذا الموضوع
arabic text to speech - بواسطة beep - 29-04-14, 01:52 AM
RE: arabic text to speech - بواسطة nkkin - 29-04-14, 02:29 AM
RE: arabic text to speech - بواسطة beep - 29-04-14, 11:57 AM
RE: arabic text to speech - بواسطة beep - 30-04-14, 03:35 PM
RE: arabic text to speech - بواسطة الشاكي لله - 01-05-14, 04:03 PM
RE: arabic text to speech - بواسطة الشاكي لله - 01-05-14, 06:23 PM
RE: arabic text to speech - بواسطة beep - 02-05-14, 06:17 PM
RE: arabic text to speech - بواسطة beep - 03-05-14, 06:00 PM
RE: arabic text to speech - بواسطة Sajad - 03-05-14, 06:17 PM
RE: arabic text to speech - بواسطة beep - 03-05-14, 08:17 PM
RE: arabic text to speech - بواسطة mohdy - 06-11-14, 04:51 PM
RE: arabic text to speech - بواسطة hadeel yaghi - 19-05-16, 04:17 PM
RE: arabic text to speech - بواسطة EnormousSoft - 03-01-17, 01:40 PM


التنقل السريع :


يقوم بقرائة الموضوع: