You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Aucma.Scada/HighWayIot.Common/SpeechStr.cs

36 lines
772 B
C#

7 months ago
using System;
using System.Runtime.InteropServices;
using System.Speech.Synthesis;
using System.Text;
namespace HighWayIot.Common
{
public class SpeechStr
{
private static readonly Lazy<SpeechStr> lazy = new Lazy<SpeechStr>(() => new SpeechStr());
public static SpeechStr Instance
{
get
{
return lazy.Value;
}
}
public async void SpeakAsync(string str)
{
SpeechSynthesizer speech = new SpeechSynthesizer();
speech.Rate = 3;//设置语速
speech.Volume = 100;//设置音量
speech.SelectVoice("Microsoft Huihui Desktop");//设置播音员(中文)
speech.SpeakAsync(str);
}
}
}