using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Phone.Speech.Synthesis;
namespace Flashcard
{
class Text_to_speech
{
private static Text_to_speech uniqueInstance;
private SpeechSynthesizer _speechSynthesizer;//声明音响合成器
private Text_to_speech() {
_speechSynthesizer = new SpeechSynthesizer();
}
public static Text_to_speech getInstance() {
if (uniqueInstance == null) {
uniqueInstance = new Text_to_speech();
}
return uniqueInstance;
}
public async void _text_to_speak(string text) {
try {
if (!string.IsNullOrEmpty(text))
{
await _speechSynthesizer.SpeakTextAsync(text);
}
else {
}
}
catch(Exception ex){
}
}
}
}