From a898decf18c4c0ed56d020dc09df55df1ca0263a Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 9 Apr 2018 18:30:58 +0300 Subject: Lots of changes :/ --- .../Html/IHtmlPresenter.cs | 14 ++++ .../Speech/DefaultSpeechProvider.cs | 71 +++++++++++++++++++++ .../Speech/ISpeechProvider.cs | 31 +++++++++ .../Tango.MachineStudio.Common.csproj | 11 +++- .../Tango.MachineStudio.Common/bip.wav | Bin 0 -> 161420 bytes .../Tango.MachineStudio.Common/error.wav | Bin 0 -> 146748 bytes 6 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Html/IHtmlPresenter.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Speech/DefaultSpeechProvider.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Speech/ISpeechProvider.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/bip.wav create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/error.wav (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common') diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Html/IHtmlPresenter.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Html/IHtmlPresenter.cs new file mode 100644 index 000000000..549022050 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Html/IHtmlPresenter.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; + +namespace Tango.MachineStudio.Common.Html +{ + public interface IHtmlPresenter + { + bool DisplayHtml(HtmlPage html); + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Speech/DefaultSpeechProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Speech/DefaultSpeechProvider.cs new file mode 100644 index 000000000..fb34c8086 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Speech/DefaultSpeechProvider.cs @@ -0,0 +1,71 @@ +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 +{ + /// + /// Represents the default speech provider. + /// + /// + /// + public class DefaultSpeechProvider : ExtendedObject, ISpeechProvider + { + private SpeechSynthesizer _speech; + private SoundPlayer _soundPlayer; + private SoundPlayer _soundPlayerErr; + + private bool _mute; + /// + /// Gets or sets a value indicating whether this is mute. + /// + public bool Mute + { + get { return _mute; } + set { _mute = value; RaisePropertyChangedAuto(); } + } + + /// + /// Initializes a new instance of the class. + /// + 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); + } + + /// + /// Speaks the specified text associated with an information sound. + /// + /// The text. + public void SpeakInfo(string text) + { + if (!Mute) + { + _soundPlayer.Play(); + _speech.SpeakAsync(text); + } + } + + /// + /// Speaks the specified text associated with an error sound. + /// + /// The text. + public void SpeakError(string text) + { + if (!Mute) + { + _soundPlayerErr.Play(); + _speech.SpeakAsync(text); + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Speech/ISpeechProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Speech/ISpeechProvider.cs new file mode 100644 index 000000000..eb31bdc39 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Speech/ISpeechProvider.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.Common.Speech +{ + /// + /// Represents a text to speech engine. + /// + public interface ISpeechProvider + { + /// + /// Gets or sets a value indicating whether this is mute. + /// + bool Mute { get; set; } + + /// + /// Speaks the specified text associated with an information sound. + /// + /// The text. + void SpeakInfo(String text); + + /// + /// Speaks the specified text associated with an error sound. + /// + /// The text. + void SpeakError(String text); + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj index df553f502..bbbab06ab 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj @@ -66,6 +66,7 @@ + ..\..\packages\MahApps.Metro.1.5.0\lib\net45\System.Windows.Interactivity.dll @@ -104,10 +105,13 @@ + + + @@ -258,6 +262,11 @@ Tango.Video - + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/bip.wav b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/bip.wav new file mode 100644 index 000000000..5a1d74045 Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/bip.wav differ diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/error.wav b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/error.wav new file mode 100644 index 000000000..4dce7d623 Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/error.wav differ -- cgit v1.3.1