Condividi:        

[VB.NET 2013] registrare audio pc

Problemi di HTML? Di PHP, ASP, .NET, JSP, Perl, SQL, JavaScript, Visual Basic..?
Vuoi realizzare programmi in C, C++, Java, Ruby o Smalltalk, e non sai da che parte cominciare?
Entra qui e troverai le risposte!

Moderatori: Anthony47, Triumph Of Steel, archimede

[VB.NET 2013] registrare audio pc

Postdi nestor71 » 18/01/18 08:03

Ciao,
ho creato un programma che fa parlare il pc leggendo quello che c'è scritto in una textbox e registra il parlato in un file audio il codice è questo:
Codice: Seleziona tutto
Imports System.Speech.Synthesis
Imports System.Runtime.InteropServices
Public Class Form1
    Private speaker As New SpeechSynthesizer
    Private recording As Boolean = False
    Private file As String
    Private salva As New SaveFileDialog
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
        Dim CercaVoci() As String = CercaVoci_Nel_SintetizzatoreVocale()
        For Each Str As String In CercaVoci 'Elenca tutte le voci
            ComboBox1.Items.Add(Str.ToString)
        Next
        salva.Filter = "audio wave(*.wav)|*.wav"
    End Sub

    <DllImport("winmm.dll")>
    Private Shared Function mciSendString(ByVal command As String, ByVal buffer As String, ByVal bufferSize As Integer, ByVal hwndCallBack As IntPtr) As Integer
    End Function
    Private Sub speakButton_Click(sender As Object, e As EventArgs) Handles speakButton.Click
            If recording = False Then
                If file = "" Then
                    MsgBox("Imposta la directory di destinazione", MsgBoxStyle.Critical) : Exit Sub
                End If
                mciSendString("open new Type waveaudio alias recsound", "", 0, 0)
                mciSendString("record recsound", "", 0, 0)
                recording = True
                speaker.Rate = Convert.ToInt32(speedUpDown.Value)
                speaker.Volume = Convert.ToInt32(volumeUpDown.Value)
                speaker.SpeakAsync(speakTextBox.Text)
                playButton.Enabled = False
                speakButton.Text = "Stop"
            Else
                mciSendString("save recsound " & file, "", 0, 0)
                mciSendString("close recsound", "", 0, 0)
                recording = False
                playButton.Enabled = True
                speakButton.Text = "Speak"
            End If


    End Sub
    Private Sub directoryButton_Click(sender As Object, e As EventArgs) Handles directoryButton.Click
        If salva.ShowDialog = Windows.Forms.DialogResult.OK Then
            file = salva.FileName
        End If
    End Sub
    Function CercaVoci_Nel_SintetizzatoreVocale() As String()
        Dim oSpeech As New System.Speech.Synthesis.SpeechSynthesizer()
        Dim installedVoices As System.Collections.ObjectModel.
                                ReadOnlyCollection(Of System.Speech.Synthesis.InstalledVoice) _
                                = oSpeech.GetInstalledVoices

        Dim names(installedVoices.Count - 1) As String
        For i As Integer = 0 To installedVoices.Count - 1
            names(i) = installedVoices(i).VoiceInfo.Name
        Next

        Return names
    End Function
    Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
        speaker.SelectVoice(ComboBox1.Text)
    End Sub
End Class

il problema è che registra dal microfono quindi si sentono anche i rumori di sottofondo, io vorrei che registra l'audio del pc.
nestor71
Utente Junior
 
Post: 12
Iscritto il: 04/07/16 21:59

Sponsor
 

Postdi Dylan666 » 20/11/19 16:29

Devi abilitare la vice Missaggio Stereo (Stereo Mix) e selezionarla coma sorgente di registrazione.
Oppure usare VB-Audio Virtual Cable (l'ho sempre visto consigliato ma mai usato)
https://editinglux.blogspot.com/2017/10 ... puter.html
Avatar utente
Dylan666
Moderatore
 
Post: 39988
Iscritto il: 18/11/03 16:46


Torna a Programmazione


Topic correlati a "[VB.NET 2013] registrare audio pc":

Audio doppio monitor
Autore: Fra_rey
Forum: Software Windows
Risposte: 1

Chi c’è in linea

Visitano il forum: Nessuno e 11 ospiti