0

I am making Speech to text application in C Sharp window form with Microsoft azure. I would also like to have a combo box on my form which allows the user enable or disable the punctuation which I have include in combo box which they would like to use. How can I implement such a feature?

How can I solve this?

Code to get list of region:

using System;
using System.Data;
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace WindowsFormsApp2
{
    public partial class Form2 : Form
    {
        [DllImport("winmm.dll", SetLastError = true)]
        static extern uint waveInGetNumDevs();

        [DllImport("winmm.dll", SetLastError = true, CharSet = CharSet.Auto)]
        public static extern uint waveInGetDevCaps(uint hwo, ref WAVEOUTCAPS pwoc, uint cbwoc);

        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
        public struct WAVEOUTCAPS
        {
            public ushort wMid;
            public ushort wPid;
            public uint vDriverVersion;
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]
            public string szPname;
            public uint dwFormats;
            public ushort wChannels;
            public ushort wReserved1;
            public uint dwSupport;
        }

        public void FillSoundDevicesInCombobox()
        {
            uint devices = waveInGetNumDevs();
            WAVEOUTCAPS caps = new WAVEOUTCAPS();
            for (uint i = 0; i < devices; i++)
            {
                waveInGetDevCaps(i, ref caps, (uint)Marshal.SizeOf(caps));
                CB1.Items.Add(caps.szPname);
            }

        }
        public Form2()
        {
            InitializeComponent();
        }


        private void Form2_Load(object sender, EventArgs e)
        {

            FillSoundDevicesInCombobox();

            // Only select the device if there is a value to load
            if (!String.IsNullOrWhiteSpace(Properties.Settings.Default.SelectedAudioDevice))
            {
                // find the device, matching on the value, not index
                var item = CB1.Items.Cast<string>().FirstOrDefault(x => x.Equals(Properties.Settings.Default.SelectedAudioDevice));
                // only select the device if we found one that matched the previous selection.
                if (item != null)
                    CB1.SelectedItem = item;
            }
        }


        private void button1_Click(object sender, EventArgs e)
        {
            Properties.Settings.Default.SelectedAudioDevice = CB1.SelectedItem?.ToString();
            Properties.Settings.Default.Save();
            MessageBox.Show("The Setting Has Been Save");
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void CB2_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
    }
}
Babar Ali
  • 133
  • 10
  • A `ComboBox` simply allows the user to select an item from a list. What you do with the selected item is irrelevant to the `ComboBox`. If you know how to change this region then you know how to change this region. Where you get the value you change it to is irrelevant to that. Treating multiple problems as though they were one is one of the biggest reasons beginners can't solve any of them. Learning to break your problem down into the smallest parts and addressing each part separately is one of the most important skills to learn as a developer. – John Aug 18 '22 at 06:39
  • @John can you tell me how to enable or disable the punctuation through combo box – Babar Ali Aug 18 '22 at 07:49

0 Answers0