gpt4 book ai didi

ms-access - 在 MS Access 中录制和播放音频

转载 作者:行者123 更新时间:2023-12-02 22:47:51 26 4
gpt4 key购买 nike

我一直在寻找高处和低处,正处于绝望的境地。我想要完成的是简单地从麦克风录制音频,将其保存到文件中然后播放。我尝试过的事情:

  • 命令行录音。我找到了几个选择,但没有一个我可以开始工作。
  • http://support.microsoft.com/kb/210067我认为这适用于 XP 但不适用于 Vista/7。
  • http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/Q_26416850.html (您可以通过单击 Here 获得完整的内容,然后它对我来说是第 5 个。)此解决方案运行顺利,但从不记录任何内容。

  • 就像我说的,我对任何我可以使用任何人能想到的可怕技巧自动化的事情持开放态度。有什么建议么?来吧,你可以再次拯救我...... :-)

    最佳答案

    我知道这是一篇旧帖子,但我多次来到这里寻找使用 vba 录制音频的解决方案。我终于在 http://www.vbarchiv.net 上找到了解决方案我想分享:
    把它放在一个模块中,我们把它命名为 sndmodule:

    Option Compare Database
    Option Explicit

    REM found at http://www.vbarchiv.net

    Public Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" _
    (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

    Const SND_SYNC = &H0
    Const SND_ASYNC = &H1
    Const SND_FILENAME = &H20000

    Public Declare Function mciSendString Lib "winmm.dll" _
    Alias "mciSendStringA" ( _
    ByVal lpstrCommand As String, _
    ByVal lpstrReturnString As String, _
    ByVal uReturnLength As Long, _
    ByVal hwndCallback As Long) As Long

    Public Enum BitsPerSec
    Bits16 = 16
    Bits8 = 8
    End Enum

    Public Enum SampelsPerSec
    Sampels8000 = 8000
    Sampels11025 = 11025
    Sampels12000 = 12000
    Sampels16000 = 16000
    Sampels22050 = 22050
    Sampels24000 = 24000
    Sampels32000 = 32000
    Sampels44100 = 44100
    Sampels48000 = 48000
    End Enum

    Public Enum Channels
    Mono = 1
    Stereo = 2
    End Enum

    Public Sub play(file As String)
    Dim wavefile
    wavefile = file
    Call sndPlaySound(wavefile, SND_ASYNC Or SND_FILENAME)
    End Sub


    Public Sub StartRecord(ByVal BPS As BitsPerSec, _
    ByVal SPS As SampelsPerSec, ByVal Mode As Channels)

    Dim retStr As String
    Dim cBack As Long
    Dim BytesPerSec As Long

    retStr = Space$(128)
    BytesPerSec = (Mode * BPS * SPS) / 8
    mciSendString "open new type waveaudio alias capture", retStr, 128, cBack
    mciSendString "set capture time format milliseconds" & _
    " bitspersample " & CStr(BPS) & _
    " samplespersec " & CStr(SPS) & _
    " channels " & CStr(Mode) & _
    " bytespersec " & CStr(BytesPerSec) & _
    " alignment 4", retStr, 128, cBack
    mciSendString "record capture", retStr, 128, cBack
    End Sub

    Public Sub SaveRecord(strFile)
    Dim retStr As String
    Dim TempName As String
    Dim cBack As Long
    Dim fs, F

    TempName = strFile 'Left$(strFile, 3) & "Temp.wav"
    retStr = Space$(128)
    mciSendString "stop capture", retStr, 128, cBack
    mciSendString "save capture " & TempName, retStr, 128, cBack
    mciSendString "close capture", retStr, 128, cBack

    End Sub

    在您的代码中,您可以像这样使用它:
    Private Sub StartRecord_Click()
    sndmodule.StartRecord Bits16, Sampels32000, Mono
    End Sub

    Private Sub EndRecord_Click()
    sndmodule.SaveRecord "C:\Users\Johanness\Downloads\test.wav"
    End Sub

    Private Sub Play_Click()
    sndmodule.play "C:\Users\Johanness\Downloads\test.wav"
    End Sub

    关于ms-access - 在 MS Access 中录制和播放音频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5491943/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com