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.
37 lines
809 B
C#
37 lines
809 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Speech.Synthesis;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Aucma.Core.Palletiz.Common
|
|
{
|
|
public class SpeechStr
|
|
{
|
|
private static readonly Lazy<SpeechStr> lazy = new Lazy<SpeechStr>(() => new SpeechStr());
|
|
|
|
public static SpeechStr Instance {
|
|
get
|
|
{
|
|
return lazy.Value;
|
|
}
|
|
}
|
|
|
|
public void speech(string str) {
|
|
|
|
SpeechSynthesizer speech = new SpeechSynthesizer();
|
|
speech.Rate = 3;//设置语速
|
|
speech.Volume = 100;//设置音量
|
|
speech.SelectVoice("Microsoft Huihui Desktop");//设置播音员(中文)
|
|
speech.SpeakAsync(str);
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|