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)
{
}
}
}