Recently received a request. A friend’s office needs to make an outpatient call number. The process is as follows: the patient selects a doctor-swipes the ID card to queue-the doctor clicks on the patient’s name to call the number.
Through the efforts of the team, a simple outpatient calling system has been completed. Record each function now for easy viewing later.
1. Voice calling
The calling DLL: DotNetSpeech.dll
The test code is as follows:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using DotNetSpeech;
namespace voice
{
public partial class Form1: Form
{
public Form1()
{
InitializeComponent();
}
///
/// Voice list
///
List _voice = new List();
private void btnSound_Click(object sender, EventArgs e)
{
this.AddVoice(txtVoice1.Text, int.Parse(txtVolume1.Text), int.Parse(txtRate1.Text));
this.AddVoice(txtVoice2.Text, int.Parse(txtVolume2.Text), int.Parse(txtRate2.Text));
for (int i = 0; i <_voice.Count(); i++)
{
try
{
//Call number based on text
_voice[i].Speak(this.txtVoiceText.Text, SpeechVoiceSpeakFlags.SVSFlagsAsync);
}
catch (Exception ex)
{
txtError.Text = DateTime.Now.ToString() + ex.ToString() + "" + txtError.Text;
}
}
}
///
/// Add voice library
///
/// Voice library name
/// Volume
/// Speed of sound
public void AddVoice(string p_Name, int? p_Volume, int? p_Rate)
{
try
{
for (int i = 0; i <_voice.Count(); i++)
{
if (_voice[i].Voice.GetAttribute("name") == p_Name)
{
_voice[i].Rate = p_Rate == null? -3: p_Rate.Value;
if (p_Volume != null) _voice[i].Volume = p_Volume.Value;
return;
}
}
SpVoice voice = new SpVoice();
voice.Voice = voice.GetVoices(string.Format("name={0}", p_Name), "").Item(0);
voice.Rate = p_Rate == null? -3: p_Rate.Value;
if (p_Volume != null) voice.Volume = p_Volume.Value;
_voice.Add(voice);
}
catch(Exception ex) {
txtError.Text = DateTime.Now.ToString()+ex.ToString() + "" + txtError.Text;
}
}
}
}
The test interface is as follows:

Notes: DotNetSpeech.dll does not support 64-bit, the startup program must be compiled to X86, DLL compilation requires ANYCPU, which is very strange, I can’t find the reason
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using DotNetSpeech;
namespace voice
{
public partial class Form1: Form
{
public Form1()
{
InitializeComponent();
}
///
/// Voice list
///
List _voice = new List();
private void btnSound_Click(object sender, EventArgs e)
{
this.AddVoice(txtVoice1.Text, int.Parse(txtVolume1.Text), int.Parse(txtRate1.Text));
this.AddVoice(txtVoice2.Text, int.Parse(txtVolume2.Text), int.Parse(txtRate2.Text));
for (int i = 0; i <_voice.Count(); i++)
{
try
{
//Call number based on text
_voice[i].Speak(this.txtVoiceText.Text, SpeechVoiceSpeakFlags.SVSFlagsAsync);
}
catch (Exception ex)
{
txtError.Text = DateTime.Now.ToString() + ex.ToString() + "" + txtError.Text;
}
}
}
///
/// Add voice library
///
/// Voice library name
/// Volume
/// Speed of sound
public void AddVoice(string p_Name, int? p_Volume, int? p_Rate)
{
try
{
for (int i = 0; i <_voice.Count(); i++)
{
if (_voice[i].Voice.GetAttribute("name") == p_Name)
{
_voice[i].Rate = p_Rate == null? -3: p_Rate.Value;
if (p_Volume != null) _voice[i].Volume = p_Volume.Value;
return;
}
}
SpVoice voice = new SpVoice();
voice.Voice = voice.GetVoices(string.Format("name={0}", p_Name), "").Item(0);
voice.Rate = p_Rate == null? -3: p_Rate.Value;
if (p_Volume != null) voice.Volume = p_Volume.Value;
_voice.Add(voice);
}
catch(Exception ex) {
txtError.Text = DateTime.Now.ToString()+ex.ToString() + "" + txtError.Text;
}
}
}
}
