示例#1
0
 //Enable mic and start speech recognition if a device is chosen.
 private void btnEnableMic_Click(object sender, EventArgs e)
 {
     if (deviceComboBox != null)
     {
         recEngine.RecognizeAsync(RecognizeMode.Multiple);
         btnDisableMic.Enabled = true;
         btnEnableMic.Enabled  = false;
         timer.Enabled         = true;
         timer.Start();
         RunOnce.SetTimer();
     }
     else
     {
         MessageBox.Show("Please select a mic from the drop down selection box above.", "No Device Selected", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
示例#2
0
 /// <summary>
 /// Timer tick to set volume meter
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void timer_Tick(object sender, EventArgs e)
 {
     if (deviceComboBox.SelectedItem != null)
     {
         var   device = GetSelectedDevice();
         float volume = device.AudioMeterInformation.MasterPeakValue * 100;
         volumeMeter.Amplitude = volume;
         if (volume >= 50)
         {
             RunOnce.CheckVolumesOnce(CurrentWorkingPlayer, volume);
             volumeMeter.ForeColor = Color.Red;
         }
         else if (volume >= 5)
         {
             volumeMeter.ForeColor = Color.FromArgb(0, 192, 0);
         }
         else
         {
             RunOnce.CheckVolumesOnce(CurrentWorkingPlayer, volume);
             volumeMeter.ForeColor = Color.White;
         }
     }
 }