【问题标题】:Retrieve sound file检索声音文件
【发布时间】:2013-08-12 01:01:21
【问题描述】:

我正在使用 VB.NET 2008 和 SQL Server 2005 传统版制作字典,用户编写单词并获取单词的翻译和发音,我面临从数据库检索部分的问题。我无法从数据库中检索声音文件。

这是我使用的代码

 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    cmd.CommandText = " select voice from lang where arabic = N'" & txtFrom.Text & "'"
    Dim dt As New DataTable()
    'rdr = cmd.ExecuteReader()
    cmd.Connection = con
    Try
        con.Open()
        rdr = cmd.ExecuteReader
        While rdr.Read
            dt.Load(rdr)
            Dim stream As Byte()
            If stream Is DirectCast(dt.Rows(0)(1), Byte()) Then
                File.WriteAllBytes("D:\mad.wma", stream)

                AxWindowsMediaPlayer1.URL = "D:\mad.wma"
            End If
        End While
        con.Close()
    Catch ex As Exception
        MsgBox(ex.Message)
        con.Close()
    End Try

End Sub

【问题讨论】:

  • 数据库端的数据类型是什么?你可能想看看blobs
  • 你没有说你遇到了什么问题。你有例外吗?文件没有创建吗?文件是否已检索但不播放?

标签: vb.net audio


【解决方案1】:

您可能想访问此站点:Make a text-to-speech program。这会容易得多。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-05-24
    • 1970-01-01
    • 1970-01-01
    • 2013-08-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多