/// <summary>Short Summary of Program.WriteText</summary> /// <param name="inTextToSpeak">A String containing the text to speak</param> private bool WriteText(string inTextToSpeak) { try { SpeechLib.SpFileStream speakStream = new SpeechLib.SpFileStream(); speakStream.Format.Type = SpeechLib.SpeechAudioFormatType.SAFT22kHz16BitMono; speakStream.Open(AppDomain.CurrentDomain.BaseDirectory + @"\" + outputFilename, SpeechLib.SpeechStreamFileMode.SSFMCreateForWrite, false); voice.AllowAudioOutputFormatChangesOnNextSet = false; voice.AudioOutputStream = speakStream; SpeechLib.ISpeechObjectTokens tokens = voice.GetVoices("", ""); voice.Voice = tokens.Item(0); voice.Rate = 8; //voice.EventInterests = SpeechLib.SpeechVoiceEvents.SVESentenceBoundary; //voice.Sentence += new SpeechLib._ISpeechVoiceEvents_SentenceEventHandler(sentence_Event); speakFlag = SpeechLib.SpeechVoiceSpeakFlags.SVSFDefault | SpeechLib.SpeechVoiceSpeakFlags.SVSFlagsAsync | SpeechLib.SpeechVoiceSpeakFlags.SVSFPurgeBeforeSpeak //| SpeechLib.SpeechVoiceSpeakFlags.SVSFNLPSpeakPunc //| SpeechLib.SpeechVoiceSpeakFlags.SVSFIsXML; ; voice.Speak(inTextToSpeak, speakFlag); voice.WaitUntilDone(Timeout.Infinite); speakStream.Close(); speakStream = null; SpeechLib.ISpeechObjectTokens Atokens = voice.GetAudioOutputs(null, ""); voice.AudioOutput = Atokens.Item(0); voice.AudioOutputStream.Format.Type = SpeechLib.SpeechAudioFormatType.SAFT22kHz16BitMono; voice.AudioOutputStream = voice.AudioOutputStream; voice.Speak("Speech has been completly written to the file, " + outputFilename, speakFlag); voice.WaitUntilDone(Timeout.Infinite); return(true); } catch (Exception) { return(false); } }
public override void Install(System.Collections.IDictionary stateSaver) { base.Install(stateSaver); System.String path = System.IO.Path.GetDirectoryName(Context.Parameters["assemblypath"]); SpeechLib.SpeechVoiceSpeakFlags SpFlags = SpeechLib.SpeechVoiceSpeakFlags.SVSFlagsAsync | SpeechLib.SpeechVoiceSpeakFlags.SVSFIsXML; SpeechLib.SpVoice speech = new SpeechLib.SpVoice(); SpeechLib.SpeechStreamFileMode SpFileMode = SpeechLib.SpeechStreamFileMode.SSFMCreateForWrite; SpeechLib.SpFileStream SpFileStream = new SpeechLib.SpFileStream(); SpFileStream.Open(System.String.Concat(path, "\\Welcome Message.wav"), SpFileMode, false); speech.AudioOutputStream = SpFileStream; System.String introText = "Thank-you for installing the play-out server from the broadcasting and presenting suite. " + "By default the server accepts connections on port 1350, the default login is username: admin and password: 1234. " + "The version of the server service is " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + ". " + "The version of the server components is " + System.Reflection.Assembly.GetAssembly(typeof(BAPSServerAssembly.Utility)).GetName().Version .ToString() + ". " + "Please refer to the documentation included with this application for further assistance."; speech.Speak(introText, SpFlags); speech.WaitUntilDone(System.Threading.Timeout.Infinite); SpFileStream.Close(); System.Xml.XmlDocument xd = new System.Xml.XmlDocument(); xd.Load(System.String.Concat("file://", path, "\\serverstate.xml")); System.Xml.XmlNode xn = xd.SelectSingleNode("/bapsserverstate/channel/playlist/entry[2]/filename"); xn.FirstChild.Value = System.String.Concat(path, "\\Welcome Message.wav"); xn = xd.SelectSingleNode("/bapsserverstate/channel/playlist/entry[1]/textdata"); xn.FirstChild.Value = introText; xd.Save(System.String.Concat(path, "\\serverstate.xml")); try { bapsServiceController.Start(); } catch (System.Exception) { /** ignore it **/ } }