本文整理汇总了C#中SpeechSynthesizer.SetOutputToDefaultAudioDevice方法的典型用法代码示例。如果您正苦于以下问题:C# SpeechSynthesizer.SetOutputToDefaultAudioDevice方法的具体用法?C# SpeechSynthesizer.SetOutputToDefaultAudioDevice怎么用?C# SpeechSynthesizer.SetOutputToDefaultAudioDevice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpeechSynthesizer
的用法示例。
在下文中一共展示了SpeechSynthesizer.SetOutputToDefaultAudioDevice方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
string sURL;
sURL = "http://api.nytimes.com/svc/topstories/v1/yourAPIKey";
WebRequest wrGETURL;
wrGETURL = WebRequest.Create(sURL);
wrGETURL.Proxy = WebProxy.GetDefaultProxy();
Stream objStream;
objStream = wrGETURL.GetResponse().GetResponseStream();
StreamReader objReader = new StreamReader(objStream);
string line = "";
line = objReader.ReadLine();
line = line.Replace("\"abstract\"","\"abstra\"");
dynamic stories = JsonConvert.DeserializeObject<Rootobject>(line);
using (SpeechSynthesizer synth = new SpeechSynthesizer())
{
// Configure the audio output.
synth.SetOutputToDefaultAudioDevice();
for (int i = 0; i < stories.num_results; i++)
{
// Speak a string synchronously.
string number = i.ToString();
synth.Speak(number+ "\n" + stories.results[i].title);
synth.Speak(stories.results[i].abstra);
}
}
}
示例2: MainForm
public MainForm()
{
InitializeComponent();
message = new Dictionary<char, string>() {
{'+',"increase screen opacity"},
{'-',"decrease screen opacity"},
{'1',"change color"},
{'2',"change color"},
{'3',"red light on"},
{'4',"green light on"},
{'5',"switch to night time"},
{'6',"switch to day time"},
{'7',"make snows"},
{'8',"show rainbow"},
{'9',"show bunny"},
{'0',"make the bunny jump"}
};
synth = new SpeechSynthesizer();
synth.SetOutputToDefaultAudioDevice();
cars = new List<Car>();
bunny = new Bunny(new Point(20, 20));
rainbow = new Rainbow(new Point(0, 0));
snow = new Snow(new Point(0, 0));
traffic = new Traffic();
sun = new Sun(new Point(Size.Width - 250, 10));
moon = new Moon(new Point(Size.Width - 250, 10));
carSound = new SoundPlayer(@"carSounds.wav");
windSound = new SoundPlayer(@"Wind.wav");
brake = new SoundPlayer(@"car-brake.wav");
}
示例3: Form1_Load
private void Form1_Load(object sender, EventArgs e)
{
rastreamento = new Rastreamento();
speech = new SpeechSynthesizer();
speech.SetOutputToDefaultAudioDevice();
datas = new List<RastreamentoCorreios.Data>();
}
示例4: initVoice
/// <summary>
/// Initiate the SpeechSynthesizer.
/// </summary>
/// <returns></returns>
public static SpeechSynthesizer initVoice()
{
synth = new SpeechSynthesizer();
synth.SetOutputToDefaultAudioDevice();
synth.SelectVoice(voiceName);
return synth;
}
示例5: ConfigureVoice
public static bool ConfigureVoice(SpeechSynthesizer synth, string name, int speed, int volume, bool defaultOutput, int customOutput)
{
try
{
synth.SetOutputToDefaultAudioDevice();
if (!defaultOutput)
{
HackCustomDevice(synth, customOutput);
// do stuff.
}
}
catch
{
}
if (string.IsNullOrEmpty(name))
name = initialName;
try
{
if (!string.IsNullOrEmpty(name))
synth.SelectVoice(name);
}
catch
{
return false;
}
synth.Rate = speed;
synth.Volume = volume;
return true;
}
示例6: SpeechConversation
public SpeechConversation(SpeechSynthesizer speechSynthesizer = null, SpeechRecognitionEngine speechRecognition = null)
{
SessionStorage = new SessionStorage();
if(speechSynthesizer==null)
{
speechSynthesizer = new SpeechSynthesizer();
speechSynthesizer.SetOutputToDefaultAudioDevice();
}
_speechSynthesizer = speechSynthesizer;
if(speechRecognition==null)
{
speechRecognition = new SpeechRecognitionEngine(
new System.Globalization.CultureInfo("en-US")
);
// Create a default dictation grammar.
DictationGrammar defaultDictationGrammar = new DictationGrammar();
defaultDictationGrammar.Name = "default dictation";
defaultDictationGrammar.Enabled = true;
speechRecognition.LoadGrammar(defaultDictationGrammar);
// Create the spelling dictation grammar.
DictationGrammar spellingDictationGrammar = new DictationGrammar("grammar:dictation#spelling");
spellingDictationGrammar.Name = "spelling dictation";
spellingDictationGrammar.Enabled = true;
speechRecognition.LoadGrammar(spellingDictationGrammar);
// Configure input to the speech recognizer.
speechRecognition.SetInputToDefaultAudioDevice();
}
_speechRecognition = speechRecognition;
}
示例7: AerTalk
public AerTalk()
{
rand = new Random();
LastSpelledWord = "";
_synth = new SpeechSynthesizer();
_synth.SetOutputToDefaultAudioDevice();
}
示例8: Speaker
public Speaker(Language lang = Language.English)
{
this.lang = lang;
AsyncMode = false; // Default to synchron speech
UseSSML = false; // Default to non-SSML speech
try
{
// Create synthesizer
ss = new SpeechSynthesizer();
ss.SetOutputToDefaultAudioDevice();
// Select language
if (!UseSSML)
{
switch (lang)
{
case Language.English: ss.SelectVoice("Microsoft Server Speech Text to Speech Voice (en-GB, Hazel)"); break;
case Language.Finish: ss.SelectVoice("Microsoft Server Speech Text to Speech Voice (fi-FI, Heidi)"); break;
case Language.Norwegian: ss.SelectVoice("Microsoft Server Speech Text to Speech Voice (nb-NO, Hulda)"); break;
case Language.Russian: ss.SelectVoice("Microsoft Server Speech Text to Speech Voice (ru-RU, Elena)"); break;
case Language.Swedish: ss.SelectVoice("Microsoft Server Speech Text to Speech Voice (sv-SE, Hedvig)"); break;
default: ss.SelectVoice("Microsoft Server Speech Text to Speech Voice (en-GB, Hazel)"); break;
}
}
}
catch (Exception e)
{
Console.WriteLine("An error occured: '{0}'", e);
}
}
示例9: ConsoleSpeechChatSession
public ConsoleSpeechChatSession()
{
SessionStorage = new SessionStorage();
SpeechSynthesizer speechSynthesizer = new SpeechSynthesizer();
speechSynthesizer.SetOutputToDefaultAudioDevice();
_speechSynthesizer = speechSynthesizer;
}
示例10: Speech
public Speech()
{
sr = new SpeechRecognitionEngine();
ss = new SpeechSynthesizer();
sr.SetInputToDefaultAudioDevice();
ss.SelectVoice("Microsoft Anna");
ss.SetOutputToDefaultAudioDevice();
}
示例11: CoachSpeech
public CoachSpeech()
{
synth = new SpeechSynthesizer();
synth.SetOutputToDefaultAudioDevice();
synth.SpeakStarted += SpeakStarted;
synth.SpeakCompleted += SpeakCompleted;
synth.SelectVoice("Microsoft Server Speech Text to Speech Voice (en-US, Helen)");
}
示例12: Tts
/*
* Text to Speech
*/
public Tts()
{
//create speech synthesizer
tts = new SpeechSynthesizer();
tts.SetOutputToDefaultAudioDevice();
//set voice
tts.SelectVoiceByHints(VoiceGender.NotSet, VoiceAge.NotSet, 0, new System.Globalization.CultureInfo("pt-PT"));
}
示例13: Play
public void Play()
{
using (SpeechSynthesizer synth = new SpeechSynthesizer())
{
synth.SelectVoiceByHints(VoiceGender, VoiceAge, VoicePosition, new CultureInfo(CultureInfo));
synth.SetOutputToDefaultAudioDevice();
synth.Volume = Volume;
synth.Rate = Rate;
synth.Speak(Text);
}
}
示例14: AddEndpoint
public void AddEndpoint(string ID, Stream outstream)
{
SpeechSynthesizer voice = new SpeechSynthesizer();
if (outstream == null) voice.SetOutputToDefaultAudioDevice();
else voice.SetOutputToAudioStream(outstream, new System.Speech.AudioFormat.SpeechAudioFormatInfo(
16000, System.Speech.AudioFormat.AudioBitsPerSample.Sixteen, System.Speech.AudioFormat.AudioChannel.Mono));
//if (chkIVONA.Checked) voice.SelectVoice("IVONA 2 Amy");
//else voice.SelectVoice("Microsoft Anna")
voices.Add(ID, voice);
outStreams.Add(ID, outstream);
}
示例15: frmThankYou_Load
private void frmThankYou_Load(object sender, EventArgs e)
{
// Initialize a new instance of the SpeechSynthesizer.
SpeechSynthesizer synth = new SpeechSynthesizer();
// Configure the audio output.
synth.SetOutputToDefaultAudioDevice();
// Speak a string.
synth.Speak(lblQuestion.Text);
}