Example #1
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();
                }
            }
        }
 //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;
     }
 }
Example #3
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);
            }
        }
Example #4
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 = "";
            }
        }
Example #5
0
 private void DisposeAll()
 {
     if (player != null)
     {
         player.Dispose();
     }
     if (wave != null)
     {
         wave.Dispose();
     }
 }
Example #6
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;
     }
 }
Example #8
0
        private void DisposeWave()
        {
            if (directSoundOut != null)
            {
                directSoundOut.Stop();
                directSoundOut.Dispose();
                directSoundOut = null;
            }
            if (wavReader != null)
            {
                wavReader.Dispose();
                wavReader = null;
            }

            btnOpenFile.Enabled = true;
        }
        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;
            }
        }
Example #10
0
 private void DisposeWave()
 {
     if (output != null)
     {
         if (buttonMute.Visible == true)
         {
             output.Stop();
         }
         output.Dispose();
         output = null;
     }
     if (wave != null)
     {
         wave.Dispose();
         wave = null;
     }
 }
Example #11
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;
     }
 }
Example #12
0
        public bool StopRecording()
        {
            if (waveOut != null)
            {
                waveOut.Stop();
                waveOut.Dispose();
                waveOut = null;
            }
            if (sourceStream != null)
            {
                sourceStream.StopRecording();
                sourceStream.Dispose();
                sourceStream = null;
            }

            return(true);
        }
Example #13
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);
            }
        }
Example #14
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;
     }
 }
Example #15
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;
     }
 }
Example #16
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;
     }
 }
Example #17
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;
     }
 }
 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;
     }
 }
Example #19
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;
            }
        }
Example #20
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;
            }
        }
Example #21
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 = "";
        }