//this ensures that all resources are correctly  closed and disposed of when recording is stopped
 private void stopRecording()
 {
     if (sourceStream != null)
     {
         if (waveOut != null) //stops sound from playing and disposes
         {
             waveOut.Stop();
             waveOut.Dispose();
             waveOut = null;
         }
         if (sourceStream != null) //stops sourcestream from recording and disposes
         {
             sourceStream.StopRecording();
             sourceStream.Dispose();
             sourceStream = null;
         }
         if (waveWriter != null)
         {
             waveWriter.Dispose();
             waveWriter = null;
         }
         isRecording = false;
         return;
     }
 }
Ejemplo n.º 2
0
        public void Sound(ToggleButton btn)
        {
            Ad_name.Adres("select name from music where id=" + Convert.ToString(btn.Name.ToString()[4]));
            name = Ad_name.muzic_name;

            if (btn_n != btn)
            {
                if (output != null)
                {
                    output.Stop();
                    output.Dispose();
                }
                gg(name);
                output.Play();
                btn_n = btn;
                del_(false);
            }
            else if (btn_n == btn)
            {
                if (output != null)
                {
                    output.Stop();
                    stream.Dispose();
                    output.Dispose();
                    output = null;
                }
                else if (output == null)
                {
                    gg(name);
                    output.Play();
                }
            }
        }
Ejemplo n.º 3
0
        // obsluga przycisku nagraj
        private void buttonRecord_Click(object sender, EventArgs e)
        {
            // jesli cos nie jest nagrywane
            if (wasRecored == false)
            {
                //jesli nie znaleziono urządzeń (mikrofonu)
                if (listBoxDevices.SelectedItems.Count == 0)
                {
                    return;
                }

                // jesli nie została wybrana scieżka do zapisu nagrania wyświetl komunikat
                if (fileRecordPath == "")
                {
                    MessageBox.Show("Wybierz miejsce w którym chcesz zapisać plik!");
                }
                else
                {
                    // nagrywanie do wczesniej wybranego pliku
                    int deviceNumber = listBoxDevices.SelectedIndex;

                    sourceStream = new NAudio.Wave.WaveIn();
                    sourceStream.DeviceNumber = deviceNumber;
                    sourceStream.WaveFormat   = new NAudio.Wave.WaveFormat(44100, NAudio.Wave.WaveIn.GetCapabilities(deviceNumber).Channels); // nadanie czestotliwosci nagrywania, i standardu mono czy stereo wynikającego z urządzenia

                    sourceStream.DataAvailable += new EventHandler <NAudio.Wave.WaveInEventArgs>(sourceStream_DataAvailable);
                    waveFileWriter              = new NAudio.Wave.WaveFileWriter(fileRecordPath, sourceStream.WaveFormat);

                    sourceStream.StartRecording();

                    buttonRecord.Text = "Nagrywanie...";
                    wasRecored        = true;
                }
            }
            else if (wasRecored == true) // jesli jest już coś nagrywane to zatrzymaj obecne nagrywanie i zmien tekst na przyciskach
            {
                if (soundOut != null)
                {
                    soundOut.Stop();
                    soundOut.Dispose();
                    soundOut          = null;
                    buttonRecord.Text = "Nagraj";
                }
                if (sourceStream != null)
                {
                    sourceStream.StopRecording();
                    sourceStream.Dispose();
                    sourceStream      = null;
                    buttonRecord.Text = "Nagraj";
                }
                if (waveFileWriter != null)
                {
                    waveFileWriter.Dispose();
                    waveFileWriter    = null;
                    buttonRecord.Text = "Nagraj";
                }

                labelRecording.Text = "";
            }
        }
Ejemplo n.º 4
0
        private void btnStopSpeech_Click(object sender, EventArgs e)
        {
            this.micClient.EndMicAndRecognition();
            //this.micClient = null;
            boxSpeech.Text    = "";
            btnSpeech.Enabled = true;


            if (waveOut != null)
            {
                waveOut.Stop();
                waveOut.Dispose();
                waveOut = null;
            }
            if (sourceStream != null)
            {
                sourceStream.StopRecording();
                sourceStream.Dispose();
                sourceStream = null;
            }
            if (waveWriter != null)
            {
                waveWriter.Dispose();
                waveWriter = null;
            }

            string _selectedFile = "C:\\Users\\Mac\\Desktop\\check.wav";

            if (identify)
            {
                identifySpeaker(_selectedFile);
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Stops the sound
 /// </summary>
 public void StopSound()
 {
     if (output != null)
     {
         output.Stop();
     }
 }
Ejemplo n.º 6
0
 private void StopMusic()
 {
     if (Borodin.PlaybackState == NAudio.Wave.PlaybackState.Playing)
     {
         Borodin.Stop();
     }
 }
Ejemplo n.º 7
0
 private void pictureBox4_Click(object sender, EventArgs e)
 {
     if (player != null)
     {
         player.Stop();
         DisposeAll();
     }
 }
Ejemplo n.º 8
0
 private void button3_Click(object sender, EventArgs e)
 {
     if (waveOut != null)
     {
         waveOut.Stop();
         waveOut.Dispose();
         waveOut = null;
     }
     if (sourceStream != null)
     {
         sourceStream.StopRecording();
         sourceStream.Dispose();
         sourceStream = null;
     }
     if (waveWriter != null)
     {
         waveWriter.Dispose();
         waveWriter = null;
     }
 }
 private void DisposeWave()
 {
     if (output != null)
     {
         if (output.PlaybackState == NAudio.Wave.PlaybackState.Playing) output.Stop();
         output.Dispose();
         output = null;
     }
     if (stream != null)
     {
         stream.Dispose();
         stream = null;
     }
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Stop playing
        /// </summary>
        public void Stop()
        {
            if (dso != null)
            {
                dso.Stop();
            }
            if (buffer != null)
            {
                buffer.ClearBuffer();
            }

            //  Force NAudio reset when we next play something.
            buffer = null;
            dso    = null;
        }
        private void DisposeWave()
        {
            output = new NAudio.Wave.DirectSoundOut();
            if (output.PlaybackState == NAudio.Wave.PlaybackState.Playing)
            {
                output.Stop();
            }
            output.Dispose();
            output = null;

            if (wave != null)
            {
                wave.Dispose();
                wave = null;
            }
        }
Ejemplo n.º 12
0
        private void DisposeWave()
        {
            if (directSoundOut != null)
            {
                directSoundOut.Stop();
                directSoundOut.Dispose();
                directSoundOut = null;
            }
            if (wavReader != null)
            {
                wavReader.Dispose();
                wavReader = null;
            }

            btnOpenFile.Enabled = true;
        }
Ejemplo n.º 13
0
        public bool StopRecording()
        {
            if (waveOut != null)
            {
                waveOut.Stop();
                waveOut.Dispose();
                waveOut = null;
            }
            if (sourceStream != null)
            {
                sourceStream.StopRecording();
                sourceStream.Dispose();
                sourceStream = null;
            }

            return(true);
        }
Ejemplo n.º 14
0
 private void DisposeWave()
 {
     if (output != null)
     {
         if (buttonMute.Visible == true)
         {
             output.Stop();
         }
         output.Dispose();
         output = null;
     }
     if (wave != null)
     {
         wave.Dispose();
         wave = null;
     }
 }
Ejemplo n.º 15
0
 private void DisposeWave()
 {
     if (output != null)
     {
         if (output.PlaybackState == NAudio.Wave.PlaybackState.Playing)
         {
             output.Stop();
         }
         output.Dispose();
         output = null;
     }
     if (wave != null)
     {
         wave.Dispose();
         wave = null;
     }
 }
Ejemplo n.º 16
0
        public void StopRecording()
        {
            try
            {
                if (waveOut != null)
                {
                    waveOut.Stop();
                    waveOut.Dispose();
                    waveOut = null;
                }
                try
                {
                    if (sourceStream != null)
                    {
                        //th.Abort();
                        sourceStream.StopRecording();
                        sourceStream.Dispose();
                        sourceStream = null;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }

                try
                {
                    if (waveWriter != null)
                    {
                        waveWriter.Dispose();
                        waveWriter = null;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
            catch (Exception e2)
            {
                Console.WriteLine(e2.Message);
            }
        }
Ejemplo n.º 17
0
 public void StopRecording()
 {
     if (m_oWaveOut != null)
     {
         m_oWaveOut.Stop();
         m_oWaveOut.Dispose();
         m_oWaveOut = null;
     }
     if (m_oSourceStream != null)
     {
         m_oSourceStream.StopRecording();
         m_oSourceStream.Dispose();
         m_oSourceStream = null;
     }
     if (m_oWaveWriter != null)
     {
         m_oWaveWriter.Dispose();
         m_oWaveWriter = null;
     }
 }
Ejemplo n.º 18
0
 private void StopAudioRecording()
 {
     if (waveOut != null)
     {
         waveOut.Stop();
         waveOut.Dispose();
         waveOut = null;
     }
     if (sourceStream != null)
     {
         sourceStream.StopRecording();
         sourceStream.Dispose();
         sourceStream = null;
     }
     if (waveWriter != null)
     {
         waveWriter.Dispose();
         waveWriter = null;
     }
 }
Ejemplo n.º 19
0
 private void StopRecording()
 {
     btnRecord.Content = "Record";
     if (waveOut != null)
     {
         waveOut.Stop();
         waveOut.Dispose();
     }
     if (SourceStream != null)
     {
         SourceStream.StopRecording();
         SourceStream.Dispose();
     }
     if (waveWriter != null)
     {
         waveWriter.Dispose();
         waveWriter = null;
     }
     if (output != null)
     {
         if (output.PlaybackState == NAudio.Wave.PlaybackState.Playing || output.PlaybackState == NAudio.Wave.PlaybackState.Paused)
         {
             output.Stop();
             output.Dispose();
             output = null;
         }
     }
     if (stopWatch.IsRunning)
     {
         stopWatch.Stop();
         currentTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                     0, 0, 0, 0);
         //txtBox.Text = currentTime;
     }
     else
     {
         currentTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                     0, 0, 0, 0);
         //txtBox.Text = currentTime;
     }
 }
Ejemplo n.º 20
0
 private void btnStop_Click(object sender, RoutedEventArgs e)
 {
     if (waveOut != null)
     {
         waveOut.Stop();
         waveOut.Dispose();
     }
     if (SourceStream != null)
     {
         SourceStream.StopRecording();
         SourceStream.Dispose();
     }
     if (waveWriter != null)
     {
         waveWriter.Dispose();
         waveWriter = null;
     }
     if (output != null)
     {
         if (output.PlaybackState == NAudio.Wave.PlaybackState.Playing || output.PlaybackState == NAudio.Wave.PlaybackState.Paused)
         {
             output.Stop();
             output.Dispose();
             output = null;
         }
     }
     if (stopWatch.IsRunning)
     {
         stopWatch.Stop();
         currentTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                     0, 0, 0, 0);
         txtBox.Text = currentTime;
     }
     else
     {
         currentTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                     0, 0, 0, 0);
         txtBox.Text = currentTime;
     }
 }
Ejemplo n.º 21
0
 private void DisposeWave()
 {
     //dispose of song from stream. To ensure no memory leaks
     if (stream == null)
     {
         txtNowPlaying.Text = "Nothing to stop...";
     }
     if (output != null)
     {
         if (output.PlaybackState == NAudio.Wave.PlaybackState.Playing)
         {
             output.Stop();
         }
         output.Dispose();
         output = null;
     }
     if (stream != null)
     {
         stream.Dispose();
         stream = null;
     }
 }
Ejemplo n.º 22
0
        //Stops the recording process used to start translating
        private void button3_Click(object sender, EventArgs e)
        {
            label1.Text = "Stop Recording";
            if (wavout != null)
            {
                wavout.Stop();
                wavout.Dispose();
                wavout = null;
            }
            if (sourcestream != null)
            {
                sourcestream.StopRecording();
                sourcestream.Dispose();
                sourcestream = null;
            }

            if (wavewriter != null)
            {
                wavewriter.Dispose();
                wavewriter = null;
            }
        }
Ejemplo n.º 23
0
        public void DisposeWave()
        {
            if (output != null)
            {
                if (output.PlaybackState == NAudio.Wave.PlaybackState.Playing)
                {
                    output.Stop();
                }
                output.Dispose();
                output = null;
            }

            if (wave != null)
            {
                wave.Dispose();
                wave = null;
            }

            if (stream != null)
            {
                stream.Dispose();
                stream = null;
            }
        }
Ejemplo n.º 24
0
        private async void StopRec()
        {
            panel1.Visible = false;
            label1.Visible = false;
            label2.Visible = true;
            if (waveOut != null)
            {
                waveOut.Stop();
                waveOut.Dispose();
                waveOut = null;
            }
            if (sourceStream != null)
            {
                sourceStream.StopRecording();
                sourceStream.Dispose();
                sourceStream = null;
            }
            if (waveWriter != null)
            {
                waveWriter.Dispose();
                waveWriter = null;
            }
            await Task.Delay(30);//let the wav audio file be created properly.

            int    senti;
            string line = Recognition();

            // line.TrimEnd(' ');
            line           = line + ".";
            senti          = nlp.SentiAnalysis(line);
            Console.Text   = "\n" + line;
            label2.Visible = false;
            if (senti >= 2)
            {
                SentiBox.Text = senti.ToString();
                nlp.SentenceParser(line);
                string[] depText = nlp.dependency.Split(new string[] { ")," }, StringSplitOptions.None);

                foreach (string s in depText)
                {
                    BasicDep.Text += "\r\n" + s + ")";
                }



                foreach (KeyValuePair <string, string> tt in nlp.propsUsed)
                {
                    ProcessedBox.Text += "\r\nKey is : " + tt.Key + " value is :" + tt.Value;
                }
                DrawImage(nlp.propsUsed, nlp.key);
                nlp.propsUsed.Clear();
            }
            else
            {
                ProcessedBox.Text += "\n Sentiment is negative.";
                SentiBox.Text      = senti.ToString();
            }
            button1.Enabled = true;

            nlp.key = "";
        }