blob: 094cf9227c01c136972464286bc15d2c9fcbd08a (
plain)
1
2
3
4
5
6
7
8
9
|
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CommonServiceLocator" version="1.3" targetFramework="net461" />
<package id="EntityFramework" version="6.2.0" targetFramework="net461" />
<package id="Expression.Blend.Sdk" version="1.0.2" targetFramework="net461" />
<package id="MahApps.Metro" version="1.5.0" targetFramework="net461" />
<package id="MaterialDesignColors" version="1.1.2" targetFramework="net461" />
<package id="MaterialDesignThemes" version="2.3.1.953" targetFramework="net461" />
</packages>
/* Literal.String.Doc */
.highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
.highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
.highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
.highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #336699 } /* Name.Variable.Class */
.highlight .vg { color: #dd7700 } /* Name.Variable.Global */
.highlight .vi { color: #3333bb } /* Name.Variable.Instance */
.highlight .vm { color: #336699 } /* Name.Variable.Magic */
.highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */using System;
using System.Collections.Generic;
using System.Linq;
using System.Media;
using System.Speech.Synthesis;
using System.Text;
using System.Threading.Tasks;
using Tango.Core;
using Tango.Core.Helpers;
namespace Tango.MachineStudio.Common.Speech
{
/// <summary>
/// Represents the default speech provider.
/// </summary>
/// <seealso cref="Tango.Core.ExtendedObject" />
/// <seealso cref="Tango.MachineStudio.Common.Speech.ISpeechProvider" />
public class DefaultSpeechProvider : ExtendedObject, ISpeechProvider
{
private SpeechSynthesizer _speech;
private SoundPlayer _soundPlayer;
private SoundPlayer _soundPlayerErr;
private bool _mute;
/// <summary>
/// Gets or sets a value indicating whether this <see cref="ISpeechProvider" /> is mute.
/// </summary>
public bool Mute
{
get { return _mute; }
set { _mute = value; RaisePropertyChangedAuto(); }
}
/// <summary>
/// Initializes a new instance of the <see cref="DefaultSpeechProvider"/> class.
/// </summary>
public DefaultSpeechProvider()
{
_speech = new SpeechSynthesizer();
_soundPlayer = new SoundPlayer(EmbeddedResourceHelper.GetEmbeddedResourceStream("Tango.MachineStudio.Common.bip.wav"));
_soundPlayerErr = new SoundPlayer(EmbeddedResourceHelper.GetEmbeddedResourceStream("Tango.MachineStudio.Common.error.wav"));
_speech.SelectVoice(_speech.GetInstalledVoices().LastOrDefault(x => x.VoiceInfo.Gender == VoiceGender.Female).VoiceInfo.Name);
}
/// <summary>
/// Speaks the specified text associated with an information sound.
/// </summary>
/// <param name="text">The text.</param>
public void SpeakInfo(string text)
{
if (!Mute)
{
_soundPlayer.Play();
_speech.SpeakAsync(text);
}
}
/// <summary>
/// Speaks the specified text associated with an error sound.
/// </summary>
/// <param name="text">The text.</param>
public void SpeakError(string text)
{
if (!Mute)
{
_soundPlayerErr.Play();
_speech.SpeakAsync(text);
}
}
}
}
|