public SpeechScope(VoiceInfo voiceInfo, params string[] phrases) { _phrases = phrases; _synth = new SpeechSynthesizer(); _synth.SelectVoice(voiceInfo != null ? voiceInfo.Name : _synth.GetInstalledVoices() .Where(v => v.VoiceInfo.Culture.Equals(CultureInfo.CurrentCulture)) .RandomElement().VoiceInfo.Name); }
public void NotifyOccured(NotifyType notifyType, Socket socket, BaseInfo baseInfo) { Database database = Database.GetInstance(); Server server = Server.GetInstance(); Users users = Users.GetInstance(); ResultInfo resultInfo = new ResultInfo(); switch (notifyType) { case NotifyType.Request_EnterMeeting: { UserInfo userInfo = Users.GetInstance().FindUser(socket); if (userInfo == null) { SetError(ErrorType.Unknown_User, "알수 없는 사용자입니다."); Main.ReplyError(socket); return; } AskChatInfo askChatInfo = (AskChatInfo)baseInfo; UserInfo targetInfo = Users.GetInstance().FindUser(askChatInfo.TargetId); if (targetInfo == null) { SetError(ErrorType.Unknown_User, "채팅대상이 존재하지 않습니다."); Main.ReplyError(socket); return; } askChatInfo.TargetId = userInfo.Id; server.Send(targetInfo.Socket, NotifyType.Request_EnterMeeting, askChatInfo); } break; case NotifyType.Reply_EnterMeeting: { AskChatInfo askChatInfo = (AskChatInfo)baseInfo; UserInfo targetInfo = Users.GetInstance().FindUser(askChatInfo.TargetId); if (targetInfo == null) { SetError(ErrorType.Unknown_User, "채팅대상이 존재하지 않습니다."); Main.ReplyError(socket); return; } if (askChatInfo.Agree == 0) { server.Send(targetInfo.Socket, NotifyType.Reply_EnterMeeting, askChatInfo); return; } RoomInfo meetingInfo = EnterMeeting(socket, askChatInfo); if (meetingInfo == null) { Main.ReplyError(socket); return; } } break; case NotifyType.Request_OutMeeting: { RoomInfo roomInfo = (RoomInfo)baseInfo; UserInfo userInfo = OutMeeting(socket, roomInfo); if (userInfo == null) { Main.ReplyError(socket); } } break; case NotifyType.Request_RoomList: { UserInfo userInfo = Users.GetInstance().FindUser(socket); if (userInfo == null) { SetError(ErrorType.Unknown_User, "알수 없는 사용자가 방목록을 요구하였습니다."); Main.ReplyError(socket); return; } List <RoomInfo> rooms = null; if (userInfo.Kind == (int)UserKind.ServiceWoman) { rooms = database.GetAllRooms(); } else { rooms = GetRooms(); } if (rooms == null) { Main.ReplyError(socket); return; } RoomListInfo roomListInfo = new RoomListInfo(); roomListInfo.Rooms = rooms; server.Send(socket, NotifyType.Reply_RoomList, roomListInfo); } break; case NotifyType.Request_MakeRoom: { RoomInfo roomInfo = (RoomInfo)baseInfo; UserInfo userInfo = users.FindUser(socket); if (userInfo == null) { Main.ReplyError(socket); return; } roomInfo.Owner = userInfo.Id; if (database.AddRoom(roomInfo) == false) { Main.ReplyError(socket); return; } string str = string.Format("{0} 님이 방 {1} 을 만들었습니다.", userInfo.Id, roomInfo.Id); LogView.AddLogString(str); server.Send(socket, NotifyType.Reply_MakeRoom, roomInfo); View._isUpdateRoomList = true; ReplyRoomList(); } break; case NotifyType.Request_UpdateRoom: { RoomInfo updateInfo = (RoomInfo)baseInfo; RoomInfo roomInfo = Database.GetInstance().FindRoom(updateInfo.Id); if (roomInfo == null) { Main.ReplyError(socket); return; } roomInfo.Body = updateInfo; if (Database.GetInstance().UpdateRoom(roomInfo) == false) { Main.ReplyError(socket); return; } server.Send(socket, NotifyType.Reply_UpdateRoom, roomInfo); } break; case NotifyType.Request_DelRoom: { RoomInfo delInfo = (RoomInfo)baseInfo; if (FindRoom(delInfo.Id) != null) { SetError(ErrorType.Live_Room, "유저들이 들어있는 방입니다."); Main.ReplyError(socket); return; } if (Database.GetInstance().FindRoom(delInfo.Id) == null) { SetError(ErrorType.Invalid_RoomId, "삭제하려는 방이 없습니다."); Main.ReplyError(socket); return; } if (Database.GetInstance().DelRoom(delInfo.Id) == false) { Main.ReplyError(socket); return; } server.Send(socket, NotifyType.Reply_DelRoom, delInfo); } break; case NotifyType.Request_EnterRoom: { OutRoom(socket); RoomInfo enterInfo = (RoomInfo)baseInfo; UserInfo userInfo = EnterRoom(socket, enterInfo.Id); if (userInfo == null) { Main.ReplyError(socket); return; } } break; case NotifyType.Request_RoomInfo: { RoomInfo enterInfo = (RoomInfo)baseInfo; UserInfo userInfo = Users.GetInstance().FindUser(socket); if (userInfo == null) { Main.ReplyError(socket); return; } //RoomInfo roomInfo = FindRoom(userInfo.RoomId); RoomInfo roomInfo = FindRoom(enterInfo.Id); if (roomInfo == null) { //roomInfo = FindMeeting(userInfo.RoomId); roomInfo = FindMeeting(enterInfo.Id); } if (roomInfo == null) { Main.ReplyError(socket); return; } roomInfo.Cash = enterInfo.Cash; BroadCast(enterInfo.Id, NotifyType.Reply_RoomInfo, enterInfo, null); ReplyRoomList(); } break; case NotifyType.Request_RoomPrice: { UserInfo userInfo = Users.GetInstance().FindUser(socket); if (userInfo == null) { Main.ReplyError(socket); return; } RoomInfo replyInfo = (RoomInfo)baseInfo; bool bMeeting = false; RoomInfo roomInfo = Chat.GetInstance().FindRoom(replyInfo.Id); if (roomInfo == null) { roomInfo = Chat.GetInstance().FindMeeting(replyInfo.Id); bMeeting = true; } if (roomInfo == null) { BaseInfo.SetError(ErrorType.Unknown_User, "알수 없는 사용자가 선물하려고 합니다."); Main.ReplyError(socket); return; } if (Cash.GetInstance().ProcessChatCash(userInfo, roomInfo, bMeeting) == false) { Main.ReplyError(socket); return; } userInfo.WaitSecond = -1; userInfo.CashTime = DateTime.Now.AddMinutes(1); //BroadCast(roomPrice.RoomId, NotifyType.Reply_RoomPrice, roomPrice, null); } break; case NotifyType.Request_OutRoom: { if (OutRoom(socket) == null) { Main.ReplyError(socket); break; } } break; case NotifyType.Request_RoomDetail: { RoomInfo roomInfo = (RoomInfo)baseInfo; ReplyRoomDetailInfo(roomInfo.Id); } break; case NotifyType.Request_StringChat: { StringInfo stringInfo = (StringInfo)baseInfo; UserInfo userInfo = users.FindUser(socket); if (userInfo == null) { BaseInfo.SetError(ErrorType.Unknown_User, "알수 없는 사용자가 채팅하려고 합니다."); Main.ReplyError(socket); return; } stringInfo.UserId = userInfo.Id; //BroadCast(userInfo.RoomId, NotifyType.Reply_StringChat, stringInfo, null ); BroadCast(stringInfo.strRoomID, NotifyType.Reply_StringChat, stringInfo, stringInfo.UserId); } break; case NotifyType.Request_SendIP: { AVMsg avMsg = (AVMsg)baseInfo; UserInfo userInfo = users.FindUser(socket); if (userInfo == null) { BaseInfo.SetError(ErrorType.Unknown_User, "알수 없는 사용자가 채팅하려고 합니다."); Main.ReplyError(socket); return; } BroadCast(avMsg._strRoomID, NotifyType.Reply_SendIP, avMsg, userInfo.Id); } break; case NotifyType.Request_VideoInfo: { AVMsg avMsg = (AVMsg)baseInfo; UserInfo userInfo = users.FindUser(socket); if (userInfo == null) { BaseInfo.SetError(ErrorType.Unknown_User, "알수 없는 사용자가 채팅하려고 합니다."); Main.ReplyError(socket); return; } BroadCast(avMsg._strRoomID, NotifyType.Reply_VideoInfo, avMsg, userInfo.Id); } break; case NotifyType.Request_VoiceChat: { VoiceInfo voiceInfo = (VoiceInfo)baseInfo; UserInfo userInfo = users.FindUser(socket); if (userInfo == null) { BaseInfo.SetError(ErrorType.Unknown_User, "알수 없는 사용자가 채팅하려고 합니다."); Main.ReplyError(socket); return; } voiceInfo.UserId = userInfo.Id; BroadCast(userInfo.RoomId, NotifyType.Reply_VoiceChat, voiceInfo, userInfo.Id); } break; case NotifyType.Request_VideoChat: { VideoInfo videoInfo = (VideoInfo)baseInfo; UserInfo userInfo = users.FindUser(socket); if (userInfo == null) { BaseInfo.SetError(ErrorType.Unknown_User, "알수 없는 사용자가 채팅하려고 합니다."); Main.ReplyError(socket); return; } videoInfo.UserId = userInfo.Id; BroadCast(userInfo.RoomId, NotifyType.Reply_VideoChat, videoInfo, userInfo.Id); } break; case NotifyType.Request_Give: { UserInfo userInfo = users.FindUser(socket); if (userInfo == null) { BaseInfo.SetError(ErrorType.Unknown_User, "알수 없는 사용자가 선물하려고 합니다."); Main.ReplyError(socket); return; } PresentHistoryInfo presentInfo = (PresentHistoryInfo)baseInfo; presentInfo.SendId = userInfo.Id; UserInfo targetInfo = database.FindUser(presentInfo.ReceiveId); if (targetInfo == null) { BaseInfo.SetError(ErrorType.Unknown_User, "받으려는 사용자정보가 정확치 않습니다."); Main.ReplyError(socket); return; } if (Cash.GetInstance().ProcessPresent(presentInfo) == false) { Main.ReplyError(socket); return; } //BroadCast(userInfo.RoomId, NotifyType.Reply_Give, baseInfo, null); BroadCast(presentInfo.strRoomID, NotifyType.Reply_Give, baseInfo, null); //ReplyRoomDetailInfo(userInfo.RoomId); users.ReplyUserList(null); View._isUpdateUserList = true; } break; case NotifyType.Request_MusiceInfo: { UserInfo userInfo = users.FindUser(socket); if (userInfo == null) { BaseInfo.SetError(ErrorType.Unknown_User, "不明会员准备删除过照片信息."); Main.ReplyError(socket); return; } MusiceInfo musiceInfo = (MusiceInfo)baseInfo; BroadCast(userInfo.RoomId, NotifyType.Reply_MusiceInfo, musiceInfo, null); //server.Send(socket, NotifyType.Reply_MusiceInfo, musiceInfo); } break; case NotifyType.Request_MusiceStateInfo: { UserInfo userInfo = users.FindUser(socket); if (userInfo == null) { BaseInfo.SetError(ErrorType.Unknown_User, "不明会员准备删除过照片信息."); Main.ReplyError(socket); return; } MusiceStateInfo musiceStateInfo = (MusiceStateInfo)baseInfo; BroadCast(userInfo.RoomId, NotifyType.Reply_MusiceStateInfo, musiceStateInfo, null); //server.Send(socket, NotifyType.Reply_MusiceStateInfo, musiceStateInfo); } break; } }
private LocalVoice CreateLocalVoiceAudioAndSource() { switch (SourceType) { case InputSourceType.Microphone: { if (this.MicrophoneType == MicType.Photon) { #if UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX var hwMicDev = this.PhotonMicrophoneDeviceId; #else var hwMicDev = -1; #endif #if UNITY_STANDALONE_WIN && !UNITY_EDITOR || UNITY_EDITOR_WIN if (this.Logger.IsInfoEnabled) { this.Logger.LogInfo("Setting recorder's source to Photon microphone device {0}", hwMicDev); } inputSource = new Windows.WindowsAudioInPusher(hwMicDev); if (this.Logger.IsInfoEnabled) { this.Logger.LogInfo("Setting recorder's source to WindowsAudioInPusher"); } break; #elif (UNITY_IOS || UNITY_STANDALONE_OSX) && !UNITY_EDITOR || UNITY_EDITOR_OSX inputSource = new Apple.AppleAudioInPusher(hwMicDev); if (this.Logger.IsInfoEnabled) { this.Logger.LogInfo("Setting recorder's source to AppleAudioInPusher"); } break; #elif UNITY_ANDROID && !UNITY_EDITOR inputSource = new UnityAndroidAudioInAEC(); if (this.Logger.IsInfoEnabled) { this.Logger.LogInfo("Setting recorder's source to UnityAndroidAudioInAEC"); } break; #else if (this.Logger.IsWarningEnabled) { this.Logger.LogWarning("Photon microphone type is not supported for the current platform. Using Unity microphone."); } #endif } if (Microphone.devices.Length < 1) { if (this.Logger.IsInfoEnabled) { this.Logger.LogInfo("No Microphone"); } return(LocalVoiceAudioDummy.Dummy); } var micDev = this.UnityMicrophoneDevice; if (this.Logger.IsInfoEnabled) { this.Logger.LogInfo("Setting recorder's source to microphone device {0}", micDev); } // mic can ignore passed sampling rate and set it's own inputSource = new MicWrapper(micDev, (int)SamplingRate); } break; case InputSourceType.AudioClip: { if (AudioClip == null) { if (this.Logger.IsErrorEnabled) { this.Logger.LogError("AudioClip property must be set for AudioClip audio source"); } return(LocalVoiceAudioDummy.Dummy); } inputSource = new AudioClipWrapper(AudioClip); if (this.LoopAudioClip) { ((AudioClipWrapper)inputSource).Loop = true; } } break; case InputSourceType.Factory: { if (InputFactory == null) { if (this.Logger.IsErrorEnabled) { this.Logger.LogError("Recorder.InputFactory must be specified if Recorder.Source set to Factory"); } return(LocalVoiceAudioDummy.Dummy); } inputSource = InputFactory(); } break; default: if (this.Logger.IsErrorEnabled) { this.Logger.LogError("unknown Source value {0}", SourceType); } return(LocalVoiceAudioDummy.Dummy); } VoiceInfo voiceInfo = VoiceInfo.CreateAudioOpus(SamplingRate, inputSource.SamplingRate, inputSource.Channels, FrameDuration, Bitrate, UserData); return(client.CreateLocalVoiceAudioFromSource(voiceInfo, inputSource, forceShort)); }
private bool StartPlaying() { if (!this.IsLinked) { if (this.Logger.IsWarningEnabled) { this.Logger.LogWarning("Cannot start playback because speaker is not linked"); } return(false); } if (this.PlaybackStarted) { if (this.Logger.IsWarningEnabled) { this.Logger.LogWarning("Playback is already started"); } return(false); } if (!this.initialized) { if (this.Logger.IsWarningEnabled) { this.Logger.LogWarning("Cannot start playback because not initialized yet"); } return(false); } if (this.isActiveAndEnabled && this.PlaybackOnlyWhenEnabled) { if (this.Logger.IsWarningEnabled) { this.Logger.LogWarning("Cannot start playback because PlaybackOnlyWhenEnabled is true and Speaker is not enabled or its GameObject is not active in the hierarchy."); } return(false); } if (this.audioOutput == null) { if (this.Logger.IsErrorEnabled) { this.Logger.LogWarning("Cannot start playback because audioOutput is null"); } return(false); } VoiceInfo voiceInfo = this.remoteVoiceLink.Info; if (voiceInfo.Channels == 0) { if (this.Logger.IsErrorEnabled) { this.Logger.LogError("Cannot start playback because remoteVoiceLink.Info.Channels == 0"); } return(false); } if (this.Logger.IsInfoEnabled) { this.Logger.LogInfo("Speaker about to start playback (v#{0}/p#{1}/c#{2}), i=[{3}], d={4}", this.remoteVoiceLink.VoiceId, this.remoteVoiceLink.PlayerId, this.remoteVoiceLink.ChannelId, voiceInfo, this.playbackDelaySettings); } this.audioOutput.Start(voiceInfo.SamplingRate, voiceInfo.Channels, voiceInfo.FrameDurationSamples); this.remoteVoiceLink.FloatFrameDecoded += this.OnAudioFrame; this.PlaybackStarted = true; this.playbackExplicitlyStopped = false; if (this.useSeparateCoroutine) { this.playbackCoroutine = this.StartCoroutine(this.PlaybackCoroutine()); } return(true); }
private void OptionsDialog_Loaded(object sender, System.Windows.RoutedEventArgs e) { StartUpComboBox.SelectedIndex = Document.Editor.My.Settings.Options_StartupMode; ShowStartupDialogCheckBox.IsChecked = Document.Editor.My.Settings.Options_ShowStartupDialog; ThemeComboBox.SelectedIndex = Document.Editor.My.Settings.Options_Theme; EnableGlassCheckBox.IsChecked = Document.Editor.My.Settings.Options_EnableGlass; ComboBox1.SelectedIndex = Document.Editor.My.Settings.Options_Tabs_SizeMode; FontFaceComboBox.SelectedItem = Document.Editor.My.Settings.Options_DefaultFont; FontSizeTextBox.Value = Document.Editor.My.Settings.Options_DefaultFontSize; SpellCheckBox.IsChecked = Document.Editor.My.Settings.Options_SpellCheck; TabPlacementComboBox.SelectedIndex = Document.Editor.My.Settings.Options_TabPlacement; if (Document.Editor.My.Computer.Info.OSVersion >= "6.0") { if (Document.Editor.My.Settings.Options_EnableGlass) { AppHelper.ExtendGlassFrame(this, new Thickness(-1, -1, -1, -1)); } } ReadOnlyCollection <InstalledVoice> Voices = speech.GetInstalledVoices(System.Globalization.CultureInfo.CurrentCulture); VoiceInfo VoiceInformation = Voices[0].VoiceInfo; foreach (InstalledVoice Voice in Voices) { VoiceInformation = Voice.VoiceInfo; TTSComboBox.Items.Add(VoiceInformation.Name.ToString()); } TTSComboBox.SelectedIndex = Document.Editor.My.Settings.Options_TTSV; TTSSlider.Value = Document.Editor.My.Settings.Options_TTSS; CloseButtonComboBox.SelectedIndex = Document.Editor.My.Settings.Options_Tabs_CloseButtonMode; if (Document.Editor.My.Settings.Options_ShowRecentDocuments) { RecentDocumentsCheckBox.IsChecked = true; } else { RecentDocumentsCheckBox.IsChecked = false; } RulerMeasurementComboBox.SelectedIndex = Document.Editor.My.Settings.Options_RulerMeasurement; foreach (string f in Document.Editor.My.Computer.FileSystem.GetFiles(Document.Editor.My.Application.Info.DirectoryPath + "\\Templates\\")) { System.IO.FileInfo template = new System.IO.FileInfo(f); if (template.Extension == ".xaml") { ListBoxItem item = new ListBoxItem(); item.Height = 32; item.Content = template.Name.Remove(template.Name.Length - 5); TemplatesListBox.Items.Add(item); } } if (Document.Editor.My.Settings.Options_EnablePlugins) { PluginsCheckBox.IsChecked = true; } else { PluginsCheckBox.IsChecked = false; } foreach (string f in Document.Editor.My.Computer.FileSystem.GetFiles(Document.Editor.My.Application.Info.DirectoryPath + "\\Plugins\\")) { System.IO.FileInfo plugin = new System.IO.FileInfo(f); ListBoxItem item = new ListBoxItem(); item.Height = 32; item.Content = plugin.Name.Remove(plugin.Name.Length - 3); PluginsListBox.Items.Add(item); } }
public Form1() { InitializeComponent(); foreach (InstalledVoice voice in synthesizer.GetInstalledVoices()) { VoiceInfo info = voice.VoiceInfo; consoleTab1.Text += info.Name + Environment.NewLine; } consoleTab1.Enabled = true; consoleTab1.ReadOnly = true; consoleTab1.BackColor = Color.White; consoleTab2.Enabled = true; consoleTab2.ReadOnly = true; consoleTab2.BackColor = Color.White; comboBox1.Items.Add("English"); comboBox1.Items.Add("German"); comboBox1.Items.Add("Italian"); comboBox1.Items.Add("Serbian Latin"); comboBox2.Items.Add("Arial 10point text"); comboBox2.Items.Add("Arial 14point text"); comboBox2.Items.Add("Arial 20point text"); comboBox2.Items.Add("Times New Roman 10point text"); comboBox2.Items.Add("Times New Roman 14point text"); comboBox2.Items.Add("Times New Roman 20point text"); staticOcr.Enabled = false; synthesizer.Volume = 100; // 0...100 synthesizer.Rate = -2; // -10...10 synthesizer.SpeakCompleted += new EventHandler <SpeakCompletedEventArgs>(synth_SpeakCompleted); button1.Enabled = false; getImageToolStripMenuItem.Enabled = false; button2.Enabled = false; getTextToolStripMenuItem.Enabled = false; button3.Enabled = false; speakToolStripMenuItem.Enabled = false; button4.Enabled = false; cancelSpeakingToolStripMenuItem.Enabled = false; DirectoryInfo di2 = new DirectoryInfo(Environment.CurrentDirectory + @"/mp3/"); if (di2.GetFiles() != null) { foreach (FileInfo file in di2.GetFiles()) { file.Delete(); } } // Ocisti sve prethodne slike DirectoryInfo di = new DirectoryInfo(imageDir); if (di.GetFiles() != null) { foreach (FileInfo file in di.GetFiles()) { file.Delete(); } } }
public csgo_tts_main() { InitializeComponent(); synthesizer.SetOutputToDefaultAudioDevice(); bw.DoWork += backgroundWorker1_DoWork; bw.RunWorkerCompleted += backgroundWorker1_RunWorkerCompleted; bw.WorkerReportsProgress = false; bw.WorkerSupportsCancellation = true; //i will come back for this but it works for now, finally, ive spent way to long on this AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); string configFile = configPath + @"config.txt"; int g = 0; //gender in numeral int r = 0; //region index in culture drop down //check for //string latestVersion = await GetLatestVersion(); //create config file if (!File.Exists(configFile)) { if (!Directory.Exists(configPath)) { Directory.CreateDirectory(configPath); } CreateConfig(configFile); } if (!File.Exists(configPath + "Core14.profile.xml")) { File.WriteAllText(configPath + "Core14.profile.xml", Properties.Resources.Core14_profile); } //read config file if (File.ReadAllLines(configFile).Length < 10) { File.Delete(configFile); CreateConfig(configFile); } path = File.ReadLines(configFile).Skip(0).Take(1).First().Split('=')[1]; timeout = Int16.Parse(File.ReadLines(configFile).Skip(1).Take(1).First().Split('=')[1]); readNames = bool.Parse(File.ReadLines(configFile).Skip(2).Take(1).First().Split('=')[1]); filler = bool.Parse(File.ReadLines(configFile).Skip(3).Take(1).First().Split('=')[1]); readSpots = bool.Parse(File.ReadLines(configFile).Skip(4).Take(1).First().Split('=')[1]); combine = bool.Parse(File.ReadLines(configFile).Skip(5).Take(1).First().Split('=')[1]); region = File.ReadLines(configFile).Skip(6).Take(1).First().Split('=')[1]; genderStr = File.ReadLines(configFile).Skip(7).Take(1).First().Split('=')[1]; useAlias = bool.Parse(File.ReadLines(configFile).Skip(8).Take(1).First().Split('=')[1]); translate = bool.Parse(File.ReadLines(configFile).Skip(9).Take(1).First().Split('=')[1]); letters = File.ReadLines(configFile).Skip(10).Take(1).First().Split('=')[1].ToCharArray().ToList(); messageOrder = File.ReadLines(configFile).Skip(10).Take(1).First().Split('=')[1]; //convert variables from config file to usable if (genderStr == "Female") { gender = VoiceGender.Female; g = 1; } else { gender = VoiceGender.Male; g = 0; } //refresh ui if (readNames) { checkName.Checked = true; checkAlias.Enabled = true; } else { checkAlias.Enabled = false; } if (readSpots) { checkSpot.Checked = true; } if (combine) { checkCombine.Checked = true; } if (filler) { checkFiller.Checked = true; } if (useAlias) { checkAlias.Checked = true; } if (translate) { checkTranslate.Checked = true; } numTimeout.Value = timeout; textPath.Text = path; dropGender.SelectedIndex = g; btnRefresh.Enabled = false; using (SpeechSynthesizer synth = new SpeechSynthesizer()) { foreach (InstalledVoice voice in synth.GetInstalledVoices()) { VoiceInfo info = voice.VoiceInfo; if (dropRegion.FindStringExact(info.Culture.ToString()) != -1) { dropRegion.Items.RemoveAt(dropRegion.FindStringExact(info.Culture.ToString())); } dropRegion.Items.Add(info.Culture); if (info.Culture.ToString() == region) { r = dropRegion.FindStringExact(region); } } } dropRegion.SelectedIndex = r; if (!Directory.Exists(path + @"\csgo")) { MessageBox.Show("Please set up your CS:GO folder path by pressing the browse button!", "Folder not found.", MessageBoxButtons.OK, MessageBoxIcon.Information); textPath.ForeColor = Color.Red; } if (btnDelete.Enabled) { if (IsFileUsed(path + @"\csgo\console.log")) { btnDelete.Enabled = false; btnDelete.Text = "In Use"; } } else { if (!IsFileUsed(path + @"\csgo\console.log")) { btnDelete.Enabled = true; btnDelete.Text = "Delete"; } } init = false; UpdateFileSize(); CheckForUpdates(); }
public SystemVoice(VoiceInfo voice, TextToSpeechEngine parent) : base(parent) { _voice = voice; Name = _voice.Name; Gender = _voice.Gender; Age = _voice.Age; Culture = _voice.Culture.Name; }
public void Home() { HomeStart(this, EventArgs.Empty); Stop(); //Load settings into Home Dialog home.installedVoicesComboBox.Items.Clear(); VoiceInfo currentVoice = synthesizer.Voice; foreach (var voice in synthesizer.GetInstalledVoices()) { home.installedVoicesComboBox.Items.Add(voice.VoiceInfo); } home.installedVoicesComboBox.DisplayMember = "Description"; home.installedVoicesComboBox.SelectedItem = currentVoice; lock (DisplayControlsLock) { home.showMediaControls.Checked = MediaControlsVisible; home.showTextDisplay.Checked = TextDisplayVisible; home.DisplayFont = textDisplay.DisplayFont; home.ForegroundColor = textDisplay.ForegroundColor; home.BackgroundColor = textDisplay.BackgroundColor; switch (textDisplay.TextLocation) { case TextDisplay.DisplayLocation.Top: home.LocationTopRadio.Checked = true; break; case TextDisplay.DisplayLocation.Bottom: home.LocationBottomRadio.Checked = true; break; case TextDisplay.DisplayLocation.Center: home.LocationBottomRadio.Checked = true; break; default: throw new InvalidOperationException(); } } home.volumeTrackbar.Value = synthesizer.Volume; home.volumeLabel.Text = "Volume : " + synthesizer.Volume; home.rateTrackbar.Value = synthesizer.Rate; home.rateLabel.Text = "Rate : " + synthesizer.Rate; if (home.ShowDialog() == System.Windows.Forms.DialogResult.OK) { SpeechVoice = ((VoiceInfo)home.installedVoicesComboBox.SelectedItem).Name; SpeechVolume = synthesizer.Volume = home.volumeTrackbar.Value; SpeechRate = synthesizer.Rate = home.rateTrackbar.Value; UpdateSynthesizer(); lock (DisplayControlsLock) { textDisplay.DisplayFont = home.DisplayFont; textDisplay.ForegroundColor = home.ForegroundColor; textDisplay.BackgroundColor = home.BackgroundColor; if (home.LocationTopRadio.Checked) { textDisplay.TextLocation = TextDisplay.DisplayLocation.Top; } else if (home.LocationBottomRadio.Checked) { textDisplay.TextLocation = TextDisplay.DisplayLocation.Bottom; } else if (home.LocationCenterRadio.Checked) { textDisplay.TextLocation = TextDisplay.DisplayLocation.Center; } else { throw new InvalidOperationException(); } } if (home.showTextDisplay.Checked) { ShowTextDisplay(); } else { HideTextDisplay(); } if (home.showMediaControls.Checked) { restoreMediaControls = true; ShowMediaControls(); } else { restoreMediaControls = false; HideMediaControls(); } } HomeEnd(this, EventArgs.Empty); }
private void sRecognize_SpeechRecognized(object sender, SpeechRecognizedEventArgs e) { //THIS IS WHERE YOU ADD COMMANDS //Take note: GREEN TEXT IS CODE THAT IS STILL IN DEVELOPMENT. //YOU MAY CHOOSE TO USE IT OR DELETE IT. THIS DOCUMENT WILL BE //UPDATED EVERY TIME I MAKE A MAJOR UPDATE. //if(exitCondition) //{ // Thread.Sleep(100); // if (e.Result.Text == "yes") // { // sSynth.SpeakAsyncCancelAll(); // sRecognize.RecognizeAsyncCancel(); // Application.Exit(); // return; // } // else { exitCondition = false; speakText("Exit Cancelled"); return; } //} switch (e.Result.Text) { case "name": listBox2.Items.Add(e.Result.Text.ToString()); speakText("iam voice recognitio application"); break; case "old": listBox2.Items.Add(e.Result.Text.ToString()); speakText("iam still baby"); break; case "hello": listBox2.Items.Add(e.Result.Text.ToString()); speakText("Hello uncle eysa"); break; case "invisable": if (ActiveForm.Visible == true) { listBox2.Items.Add(e.Result.Text.ToString()); ActiveForm.ShowInTaskbar = false; ActiveForm.Hide(); speakText("I am now invisible. You can access me by clicking on the icon down here in the tray."); break; } else { break; } case "salam": listBox2.Items.Add(e.Result.Text.ToString()); //speakText("Hello, " + Environment.UserName.ToString()); speakText("waalaykom el-salam warahmato allah wabarakato"); break; case "exit": listBox2.Items.Add(e.Result.Text.ToString()); speakText("Are you sure you want to exit?"); Thread.Sleep(3000); Application.Exit(); //MessageBox.Show("are you sure"); //exitCondition = true; break; case "no": listBox2.Items.Add(e.Result.Text.ToString()); speakText("welcome ya sleeem ya zalooooot?"); exitCondition = true; break; case "thank you": listBox2.Items.Add(e.Result.Text.ToString()); speakText("ala eih yasta eysa habeeb alby"); break; case "change voice": listBox2.Items.Add(e.Result.Text.ToString()); foreach (InstalledVoice voice in sSynth.GetInstalledVoices()) { bool first = true; StreamReader sr = new StreamReader(@"C:\Temp\Speakvoice.txt"); string name = sr.ReadLine(); sr.Close(); VoiceInfo vi = voice.VoiceInfo; //comboBox1.Items.Add(vi.Name.ToString()); if (first) { first = false; // comboBox1.Text = name; } } // comboBox1.Show(); break; case "stop talking": listBox2.Items.Add(e.Result.Text.ToString()); cancelSpeech(); break; case "lock computer": listBox2.Items.Add(e.Result.Text.ToString()); lockComputer(); break; case "be quiet": listBox2.Items.Add(e.Result.Text.ToString()); cancelSpeech(); sSynth.SpeakAsyncCancelAll(); break; case "chrome": listBox2.Items.Add(e.Result.Text.ToString()); speakText("One moment yasta."); //Process pr = new Process(); //pr.StartInfo.FileName = "http://www.google.com/"; //pr.Start(); Process.Start("chrome.exe", ""); break; case "stop listening": listBox2.Items.Add(e.Result.Text.ToString()); speakText("Ok."); // btnStop.Visible = true; sRecognize.RecognizeAsyncCancel(); sRecognize.RecognizeAsyncStop(); break; case "calculator": Process p2 = new Process(); p2 = System.Diagnostics.Process.Start("calc.exe"); break; case "show commands": listBox2.Items.Add(e.Result.Text.ToString()); bool working = true; while (working) { try { listBox1.Show(); listBox1.Items.Add(CommandsReader.ReadLine()); } catch { working = false; break; } } break; case "maximize": try { ActiveForm.WindowState = FormWindowState.Maximized; listBox2.Items.Add(e.Result.Text.ToString()); break; } catch { listBox2.Items.Add(e.Result.Text.ToString() + "[FAILED]"); break; } case "if one": listBox2.Items.Add(e.Result.Text.ToString()); bool worrking = true; while (worrking) { try { listBox1.Show(); listBox1.Items.Add(CommandsReader.ReadLine()); } catch { worrking = false; break; } } break; case "eject drive": OpenCloseCD(); listBox2.Items.Add(e.Result.Text.ToString()); break; case "hide": break; case "what about you": listBox2.Items.Add(e.Result.Text.ToString()); speakText("iam an artificial intelegence application"); break; case "your friend": listBox2.Items.Add(e.Result.Text.ToString()); speakText("it is muhammad eysa"); break; case "my facebook account": Process.Start("chrome.exe", "https://www.facebook.com/eng.eissa.39"); break; } }
static void Main(string[] args) { synth.SetOutputToDefaultAudioDevice(); bool first = true; foreach (InstalledVoice voice in synth.GetInstalledVoices()) { VoiceInfo info = voice.VoiceInfo; string AudioFormats = ""; foreach (SpeechAudioFormatInfo fmt in info.SupportedAudioFormats) { AudioFormats += String.Format("{0}\n", fmt.EncodingFormat.ToString()); } // extract the names for gendered voices, but make sure we have no empties if (first) { for (int i = (int)VoiceGender.NotSet; i <= (int)VoiceGender.Neutral; i++) { voicename[i] = info.Name; } } else { voicename[(int)info.Gender] = info.Name; } #if DEBUG Console.WriteLine(" Name: " + info.Name); Console.WriteLine(" Culture: " + info.Culture); Console.WriteLine(" Age: " + info.Age); Console.WriteLine(" Gender: " + info.Gender); Console.WriteLine(" Description: " + info.Description); Console.WriteLine(" ID: " + info.Id); Console.WriteLine(" Enabled: " + voice.Enabled); if (info.SupportedAudioFormats.Count != 0) { Console.WriteLine(" Audio formats: " + AudioFormats); } else { Console.WriteLine(" No supported audio formats found"); } string AdditionalInfo = ""; foreach (string key in info.AdditionalInfo.Keys) { AdditionalInfo += String.Format(" {0}: {1}\n", key, info.AdditionalInfo[key]); } Console.WriteLine(" Additional Info - " + AdditionalInfo); Console.WriteLine(); #endif first = false; } if (args.Count() > 0) { foreach (string arg in args) { if (SelectVoiceFromString(arg)) { continue; } synth.Speak(arg); } } else { string line; if (Console.IsInputRedirected) { // redirects do something special-- they let the synth process SSML tags using (StreamReader reader = new StreamReader(Console.OpenStandardInput(), Console.InputEncoding)) { string ssml = reader.ReadToEnd(); synth.SpeakSsml(ssml); } } else { // read lines from the console and say them until, ostensibly, ctrl-z is pressed while (!string.IsNullOrEmpty(line = Console.ReadLine())) { // switch to a different voice? if (SelectVoiceFromString(line)) { Console.WriteLine("[new voice selected: \"" + synth.Voice.Name + "\""); continue; } synth.Speak(line); } } } }
private MicrosoftSpeechXmlSynthesizer(VoiceInfo voice) { Voice = voice; }
private void sRecognize_SpeechRecognized(object sender, SpeechRecognizedEventArgs e) { sRecognize.RecognizeAsyncCancel(); //MessageBox.Show("Speech Recognised: " + e.Result.Text.ToString()); SetText(e.Result.Text.ToString()); if (e.Result.Text == "sleep") { sleep = true; } else if (e.Result.Text == "wake") { sleep = false; } if (sleep == false) { if (exitcondition == true) { if (e.Result.Text == "yes") { speaktext("Bye Bye"); sSynth.SpeakAsyncCancelAll(); Application.Exit(); } else if (e.Result.Text == "no" || e.Result.Text == "cancel") { exitcondition = false; speaktext("Exit Aborted."); } else { exitcondition = false; } } if (cv == true) { switch (e.Result.Text) { case "David": name = "Microsoft David Mobile"; cv = false; break; case "Hazel": name = "Microsoft Hazel Mobile"; cv = false; break; case "Zira": name = "Microsoft Zira Mobile"; cv = false; break; } } switch (e.Result.Text) { case "exit": case "close": case "quit": speaktext("Are you sure you want to exit?"); exitcondition = true; break; case "minimize": if (!isMinimized) { Invoke(new Action(() => { this.WindowState = FormWindowState.Minimized; })); isMinimized = true; speaktext("Apologies for coming in your way."); } else { speaktext("I am already minimized!"); } break; case "maximize": if (isMinimized) { Invoke(new Action(() => { this.WindowState = FormWindowState.Normal; })); isMinimized = false; speaktext("I'm back!"); } else { speaktext("I am already maximized!"); } break; case "hello": case "hi": //speaktext("Hello,"+Environment.UserName+", What can I do for you?"); speaktext("Hello, what can I do for you?"); break; case "change voice": cv = true; foreach (InstalledVoice voice in sSynth.GetInstalledVoices()) { VoiceInfo info = voice.VoiceInfo; vn += info.Name + ", "; } speaktext("Select a voice "); speaktext(vn); vn = ""; break; case "how are you": speaktext("I am fine, and you?"); break; case "who are you": speaktext("I am Jarvis your personal assistant"); break; case "open firefox": case "browser": Process.Start(@"C:\Program Files (x86)\Mozilla Firefox\firefox.exe"); speaktext("Firing your web browser"); break; case "close firefox": case "close browser": killProg("firefox"); break; case "next": SendKeys.SendWait("{RIGHT}"); break; case "previous": case "back": SendKeys.SendWait("{LEFT}"); break; case "play": case "pause": SendKeys.SendWait(" "); break; case "escape": SendKeys.SendWait("{ESC}"); break; case "what is today's date": case "date": pBuilder.ClearContent(); pBuilder.AppendText("Today's date is, "); pBuilder.AppendTextWithHint(DateTime.Now.ToString("M/dd/yyyy"), SayAs.Date); sSynth.SelectVoice(name); //sSynth.Rate = -2; sSynth.Speak(pBuilder); break; case "what time is now": case "time": pBuilder.ClearContent(); pBuilder.AppendText("It is, "); pBuilder.AppendTextWithHint(DateTime.Now.ToString("hh:mm tt"), SayAs.Time12); sSynth.SelectVoice(name); //sSynth.Rate = -2; sSynth.Speak(pBuilder); break; case "how's the weather": case "weather": if (getweather()) { speaktext("The weather in " + Town + " is " + Condition + " at " + Temperature + " degrees celsius. There is a wind speed of " + Windspeed + " kilometers per hour and a humidity of " + Humidity); } else { speaktext("Sorry! Error retrieving weather info."); } break; case "what's tomorrow's forecast": case "forecast": getweather(); speaktext("It looks like tomorrow will be " + TFCond + " with a high of " + TFHigh + " degree centrigrade and a low of " + TFLow + " degree centrigrade"); break; default: if (e.Result.Text.ToString().ToLower().Contains("search")) { string query = e.Result.Text.ToString().Replace("search", ""); query = HttpUtility.UrlEncode(query); pr.StartInfo.FileName = "http://google.com/search?q=" + query; pr.Start(); speaktext("Here is your search result."); } break; } } sRecognize.RecognizeAsync(RecognizeMode.Multiple); }
public SynthesizerVoice(VoiceInfo voiceInfo) { _voiceInfo = voiceInfo; }
} // Dummy constructor internal EncoderFloat(VoiceInfo i, ILogger logger) { } // 0x0000000180F1C660-0x0000000180F1C700
private void OnRemoteVoiceInfo(int channelId, int playerId, byte voiceId, VoiceInfo voiceInfo, ref RemoteVoiceOptions options) { if (voiceInfo.Codec != Codec.AudioOpus) { if (this.Logger.IsDebugEnabled) { this.Logger.LogInfo("OnRemoteVoiceInfo skipped as coded {4} is not Opus, channel {0} player {1} voice #{2} userData {3}", channelId, playerId, voiceId, voiceInfo.UserData, voiceInfo.Codec); } return; } if (this.Logger.IsInfoEnabled) { this.Logger.LogInfo("OnRemoteVoiceInfo channel {0} player {1} voice #{2} userData {3}", channelId, playerId, voiceId, voiceInfo.UserData); } bool duplicate = false; for (int i = 0; i < this.cachedRemoteVoices.Count; i++) { RemoteVoiceLink remoteVoiceLink = this.cachedRemoteVoices[i]; if (remoteVoiceLink.PlayerId == playerId && remoteVoiceLink.VoiceId == voiceId) { if (this.Logger.IsWarningEnabled) { this.Logger.LogWarning("Duplicate remote voice info event channel {0} player {1} voice #{2} userData {3}", channelId, playerId, voiceId, voiceInfo.UserData); } duplicate = true; this.cachedRemoteVoices.RemoveAt(i); break; } } RemoteVoiceLink remoteVoice = new RemoteVoiceLink(voiceInfo, playerId, voiceId, channelId, ref options); this.cachedRemoteVoices.Add(remoteVoice); if (RemoteVoiceAdded != null) { RemoteVoiceAdded(remoteVoice); } remoteVoice.RemoteVoiceRemoved += delegate { if (this.Logger.IsInfoEnabled) { this.Logger.LogInfo("RemoteVoiceRemoved channel {0} player {1} voice #{2} userData {3}", channelId, playerId, voiceId, voiceInfo.UserData); } if (!this.cachedRemoteVoices.Remove(remoteVoice) && this.Logger.IsWarningEnabled) { this.Logger.LogWarning("Cached remote voice info not removed for channel {0} player {1} voice #{2} userData {3}", channelId, playerId, voiceId, voiceInfo.UserData); } }; if (this.SpeakerFactory != null) { Speaker speaker = this.SpeakerFactory(playerId, voiceId, voiceInfo.UserData); if (speaker != null && duplicate && speaker.IsLinked) { if (this.Logger.IsWarningEnabled) { this.Logger.LogWarning("Overriding speaker link for channel {0} player {1} voice #{2} userData {3}", channelId, playerId, voiceId, voiceInfo.UserData); } speaker.OnRemoteVoiceRemove(); } this.LinkSpeaker(speaker, remoteVoice); } }
// Methods public void Open(VoiceInfo i) { }
public void SetVoiceInfo(VoiceInfo info) { synthesizer.SelectVoice(info.Name); }
/// <summary> /// Initializes a new instance of the <see cref="VoiceInfoImplementation" /> class. /// </summary> /// <param name="voiceInfo">The voice info.</param> public VoiceInfoImplementation(VoiceInfo voiceInfo) { this.voiceInfo = voiceInfo; }
void initEncounterPlugin() { if (!InvokeRequired) { this.list_log.Columns.Add("Local Time", -1); this.list_log.Columns.Add("StopWatch", -2, HorizontalAlignment.Right); this.list_log.Columns.Add("Event", 200); this.list_log.Columns.Add("Details", -1); logFileName_active = getLatestFile(logFolder); log("Log File", false, logFileName_active); synthesizer.Volume = this.trackBar_volumeSlider.Value; // 0...100 //init server //myTTTVServer = new tttvserver(); //get installed voice foreach (InstalledVoice voice in synthesizer.GetInstalledVoices()) { VoiceInfo info = voice.VoiceInfo; combo_voiceSelector.Items.Add(info.Name); } combo_voiceSelector.SelectedIndex = int.Parse(txt_voiceIndex.Text); //add ACT synch speak engine combo_voiceSelector.Items.Add("ACT synch mode (Not Reccomended)"); //set fight timer fightTimer = new System.Timers.Timer(1000); // Create a timer with a 1 second interval. fightTimer.Elapsed += OnTimedEvent; // Hook up the Elapsed event for the timer. fightTimer.AutoReset = true; fightTimer.Enabled = false; #region create joblist ffxiv_jobList = new string[] { "whm", "ast", "sch", "war", "drk", "pld", "smn", "blm", "mch", "brd", "nin", "drg", "mnk" }; ffxiv_jobSortOrder = new string[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m" }; ffxiv_classList = new string[] { "heal", "heal", "heal", "tank", "tank", "tank", "caster", "caster", "range", "range", "melee", "melee", "melee" }; ffxiv_jobSkillList.Add("#cure#, #cure ii#, #regen#, #stone iii#, #medica ii#"); //whm ffxiv_jobSkillList.Add("#helios#, #benefic ii#, #aspected benefic#, #combust ii#, #essential dignity#"); //ast ffxiv_jobSkillList.Add("#physick#, #adloquium#, #succor#, #lustrate#, #indomitability#, #broil#, #sacred soil#"); //sch ffxiv_jobSkillList.Add("#heavy swing#, #maim#, #skull Sunder#, #berserk#, #tomahawk#, #deliverance#"); //war ffxiv_jobSkillList.Add("#hard slash#, #unmend#, #plunge#"); //drk ffxiv_jobSkillList.Add("#fast blade#, #shield lob#"); //pld ffxiv_jobSkillList.Add("#fester#, #painflare#, #tri-disaster#, #deathflare#, #dreadwyrm trance#"); //smn ffxiv_jobSkillList.Add("#fire ii#, #fire iii#"); //blm ffxiv_jobSkillList.Add("#split shot#"); //mch ffxiv_jobSkillList.Add("#heavy shot#, #windbite#, #straight shot#, #venomous bite#"); //brd ffxiv_jobSkillList.Add("#spinning edge#"); //nin ffxiv_jobSkillList.Add("#heavy thrust#, #true thrust#"); //drg ffxiv_jobSkillList.Add("#bootshine#, #true strike#, #snap punch#, #twin snakes#"); //mnk #endregion #region get xml files list string[] files = Directory.EnumerateFiles(pluginFolderName, "*.xml", SearchOption.AllDirectories).Select(Path.GetFileName).ToArray();// System.IO.Directory.GetFiles("ffxiv.encounter\\xml"); this.combo_xml_fightFile.Items.AddRange(files); #endregion #region Auto Update Stuff //log(System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Major.ToString()); #endregion this.grid_players.DataSource = ffxiv_player_list; } else { Invoke(new Action(initEncounterPlugin)); } }
private void Speak_Click(object sender, RoutedEventArgs e) { if (!String.IsNullOrEmpty(TextInFile.Text)) { using (SpeechSynthesizer synth = new SpeechSynthesizer()) { synth.SetOutputToDefaultAudioDevice(); synth.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Child, 20, CultureInfo.GetCultureInfo(0x00000411)); synth.SpeakAsync(TextInFile.Text); foreach (InstalledVoice voice in synth.GetInstalledVoices()) { VoiceInfo info = voice.VoiceInfo; string AudioFormats = ""; foreach (SpeechAudioFormatInfo fmt in info.SupportedAudioFormats) { AudioFormats += String.Format("{0}\n", fmt.EncodingFormat.ToString()); } Info.Text += (" \nName: " + info.Name); Info.Text += ("\n Culture: " + info.Culture); Info.Text += (" \nAge: " + info.Age); Info.Text += (" \nGender: " + info.Gender); Info.Text += (" \nDescription: " + info.Description); Info.Text += (" \nID: " + info.Id); Info.Text += (" \nEnabled: " + voice.Enabled); if (info.SupportedAudioFormats.Count != 0) { Info.Text += ("\n Audio formats: " + AudioFormats); } else { Info.Text += (" \nNo supported audio formats found"); } string AdditionalInfo = ""; foreach (string key in info.AdditionalInfo.Keys) { AdditionalInfo += String.Format(" {0}: {1}\n", key, info.AdditionalInfo[key]); } Info.Text += ("\n Additional Info - " + AdditionalInfo); //// Retrieve the DrawingContext in order to draw into the visual object. //DrawingContext drawingContext = drawingVisual.RenderOpen(); //// Draw a rectangle into the DrawingContext. //Rect rect = new Rect(new Point(160, 100), new Size(320, 80)); //drawingContext.DrawRectangle(Brushes.LightBlue, (Pen)null, rect); //// Draw a formatted text string into the DrawingContext. //drawingContext.DrawText( // new FormattedText("Hello, world", //CultureInfo.GetCultureInfo("en-us"), // FlowDirection.LeftToRight, // new Typeface("Verdana"), // 36, Brushes.Black), // new Point(200, 116)); //// Persist the drawing content. //drawingContext.Close(); } } } }
public VoiceInfoDict(VoiceInfo voice) : base() { var dict = this; dict["id"] = voice.Id; string name = cmdVoiceDescribe.saneName(voice); dict["name"] = name; dict["culture"] = voice.Culture.ToString(); string agegroup = voice.Age.ToString().ToLower(); dict["agegroup"] = agegroup; dict["gender"] = voice.Gender.ToString().ToLower(); dict["descr"] = voice.Description; foreach (KeyValuePair <string, string> pair in voice.AdditionalInfo) { var key = pair.Key; var val = pair.Value; if (strUtil.empty(key)) { continue; } var lcKey = key.ToLower(); if (lcKey == "age") { if (val == agegroup) { continue; } if (val.ToLower() == agegroup) { continue; } } if (lcKey == "name") { if (val == name) { continue; } if (val == voice.Name) { continue; } if (val == voice.Description) { continue; } } if (dict.ContainsKey(lcKey)) { var lcHasVal = dict[lcKey]; if (lcHasVal == val) { continue; } if (lcHasVal == val.ToLower()) { continue; } } dict[key] = val; } }
public void init() { //fill the lookups for match cases with external script Emphasisvalues.Add("Moderate", PromptEmphasis.Moderate); Emphasisvalues.Add("None", PromptEmphasis.None); Emphasisvalues.Add("NotSet", PromptEmphasis.NotSet); Emphasisvalues.Add("Reduced", PromptEmphasis.Reduced); Emphasisvalues.Add("Strong", PromptEmphasis.Strong); Ratevalues.Add("ExtraFast", PromptRate.ExtraFast); Ratevalues.Add("ExtraSlow", PromptRate.ExtraSlow); Ratevalues.Add("Fast", PromptRate.Fast); Ratevalues.Add("Medium", PromptRate.Medium); Ratevalues.Add("NotSet", PromptRate.NotSet); Ratevalues.Add("Slow", PromptRate.Slow); //Fill Deepener names Deepener_names.Add("Deepener_1.txt"); Deepener_names.Add("Deepener_2.txt"); string query = "<QueryMulti:<Anchor1>,<Anchor2>,<Anchor3>,<Anchor4>,Name1,Name2,Name3,Name4>>"; //QueryMulti(query); List <String> vnames = new List <String>(); foreach (InstalledVoice voice in reader.GetInstalledVoices()) { VoiceInfo info = voice.VoiceInfo; //Console.WriteLine(" Voice Name: " + info.Name); vnames.Add(info.Name); } string use_name = ""; foreach (string n in vnames) { if (n.Contains("Zira")) { string name = n; use_name = n; break; } } //reader.SelectVoice("IVONA 2 Salli"); //reader.SelectVoice("Microsoft Anna"); //reader.SelectVoice(use_name); QueryMulti selectvoice = new QueryMulti(); string[] voices = vnames.ToArray(); selectvoice.One.Text = voices[0]; selectvoice.Two.Text = voices[1]; selectvoice.Three.Text = voices[2]; selectvoice.Four.Text = voices[3]; selectvoice.Text = "Select a voice"; selectvoice.ShowDialog(); string voiceselected = selectvoice.returnvalue; switch (voiceselected) { case "One": reader.SelectVoice(voices[0]); break; case "Two": reader.SelectVoice(voices[1]); break; case "Three": reader.SelectVoice(voices[2]); break; case "Four": reader.SelectVoice(voices[3]); break; } //reader.SelectVoice("IVONA 2 Emma"); //reader.SelectVoice("Microsoft Anna"); }
private SystemSpeechXmlSynthesizer(VoiceInfo voice) { Voice = voice; }
/* * Text to Speech constructor */ public TTS() { Console.WriteLine("TTS constructor called"); //create new speech synthesizer tts = new SpeechSynthesizer(); //show voices //initialize a new instance of the SpeechSynthesizer using (SpeechSynthesizer synth = new SpeechSynthesizer()) { //output information for all installed voices Console.WriteLine("Installed voices -> "); foreach (InstalledVoice voice in synth.GetInstalledVoices()) { VoiceInfo voice_info = voice.VoiceInfo; string AudioFormats = ""; foreach (SpeechAudioFormatInfo format in voice_info.SupportedAudioFormats) { AudioFormats += String.Format("{0}\n", format.EncodingFormat.ToString()); format.EncodingFormat.ToString(); } //write voice information Console.WriteLine("<--------- VOICE INFO --------->"); Console.WriteLine("Name: " + voice_info.Name); Console.WriteLine("Culture: " + voice_info.Culture); Console.WriteLine("Age: " + voice_info.Age); Console.WriteLine("Gender: " + voice_info.Gender); Console.WriteLine("Description: " + voice_info.Description); Console.WriteLine("ID: " + voice_info.Id); Console.WriteLine("Enabled: " + voice.Enabled); //write voice audio formats if (voice_info.SupportedAudioFormats.Count != 0) { Console.WriteLine("Audio Formats: " + AudioFormats); } else { Console.WriteLine("No Supported Audio Formats Found!"); } //write additional information string add_info = ""; foreach (string key in voice_info.AdditionalInfo.Keys) { add_info += String.Format("{0}:{1}\n", key, voice_info.AdditionalInfo[key]); } Console.WriteLine("Additional Information -> " + add_info); Console.WriteLine(); } } //quit //Console.WriteLine("Press any key to quit..."); //Console.ReadKey(); //set voice tts.SelectVoiceByHints(VoiceGender.Male, VoiceAge.NotSet, 0, new System.Globalization.CultureInfo("pt-PT")); //set voice function to play audio tts.SpeakCompleted += new EventHandler <SpeakCompletedEventArgs>(tts_SpeakCompleted); }
private LocalVoice CreateLocalVoiceAudioAndSource() { switch (SourceType) { case InputSourceType.Microphone: { if (this.MicrophoneType == MicType.Photon) { #if UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX || UNITY_EDITOR_WIN var hwMicDev = this.PhotonMicrophoneDeviceId; if (this.Logger.IsInfoEnabled) { this.Logger.LogInfo("Setting recorder's source to Photon microphone device [{0}] \"{1}\"", hwMicDev, PhotonMicrophoneEnumerator.NameAtIndex(hwMicDev)); } #else if (this.Logger.IsInfoEnabled) { this.Logger.LogInfo("Setting recorder's source to Photon microphone device"); } #endif #if UNITY_STANDALONE_WIN && !UNITY_EDITOR || UNITY_EDITOR_WIN if (this.Logger.IsInfoEnabled) { this.Logger.LogInfo("Setting recorder's source to WindowsAudioInPusher"); } inputSource = new Windows.WindowsAudioInPusher(hwMicDev, this.Logger); #elif UNITY_IOS && !UNITY_EDITOR IOS.AudioSessionParameters audioSessionParameters = IOS.AudioSessionParametersPresets.Game; if (this.Logger.IsInfoEnabled) { this.Logger.LogInfo("Setting recorder's source to IOS.AudioInPusher with session {0}", audioSessionParameters); } inputSource = new IOS.AudioInPusher(audioSessionParameters, this.Logger); #elif UNITY_STANDALONE_OSX && !UNITY_EDITOR || UNITY_EDITOR_OSX if (this.Logger.IsInfoEnabled) { this.Logger.LogInfo("Setting recorder's source to MacOS.AudioInPusher"); } inputSource = new MacOS.AudioInPusher(hwMicDev, this.Logger); #elif UNITY_ANDROID && !UNITY_EDITOR if (this.Logger.IsInfoEnabled) { this.Logger.LogInfo("Setting recorder's source to UnityAndroidAudioInAEC"); } inputSource = new UnityAndroidAudioInAEC(this.Logger); #else inputSource = new AudioDesc(0, 0, "Photon microphone type is not supported for the current platform."); #endif if (inputSource.Error == null) { break; } if (this.Logger.IsErrorEnabled) { this.Logger.LogError("Photon microphone input source creation failure: {0}. Falling back to Unity microphone", inputSource.Error); } } if (Microphone.devices.Length < 1) { if (this.Logger.IsInfoEnabled) { this.Logger.LogInfo("No Microphone"); } return(LocalVoiceAudioDummy.Dummy); } var micDev = this.UnityMicrophoneDevice; if (this.Logger.IsInfoEnabled) { this.Logger.LogInfo("Setting recorder's source to Unity microphone device {0}", micDev); } // mic can ignore passed sampling rate and set its own inputSource = new MicWrapper(micDev, (int)SamplingRate, this.Logger); if (inputSource.Error != null && this.Logger.IsErrorEnabled) { this.Logger.LogError("Unity microphone input source creation failure: {0}.", inputSource.Error); } } break; case InputSourceType.AudioClip: { if (AudioClip == null) { if (this.Logger.IsErrorEnabled) { this.Logger.LogError("AudioClip property must be set for AudioClip audio source"); } return(LocalVoiceAudioDummy.Dummy); } inputSource = new AudioClipWrapper(AudioClip); // never fails, no need to check Error if (this.LoopAudioClip) { ((AudioClipWrapper)inputSource).Loop = true; } } break; case InputSourceType.Factory: { if (InputFactory == null) { if (this.Logger.IsErrorEnabled) { this.Logger.LogError("Recorder.InputFactory must be specified if Recorder.Source set to Factory"); } return(LocalVoiceAudioDummy.Dummy); } inputSource = InputFactory(); if (inputSource.Error != null && this.Logger.IsErrorEnabled) { this.Logger.LogError("InputFactory creation failure: {0}.", inputSource.Error); } } break; default: if (this.Logger.IsErrorEnabled) { this.Logger.LogError("unknown Source value {0}", SourceType); } return(LocalVoiceAudioDummy.Dummy); } VoiceInfo voiceInfo = VoiceInfo.CreateAudioOpus(SamplingRate, inputSource.SamplingRate, inputSource.Channels, FrameDuration, Bitrate, UserData); return(client.CreateLocalVoiceAudioFromSource(voiceInfo, inputSource, forceShort)); }
internal VoiceChangeEventArgs(Prompt prompt, VoiceInfo voice) : base(prompt) { _voice = voice; }
internal TTSVoice(ITtsEngineProxy engine, VoiceInfo voiceId) { _engine = engine; _voiceId = voiceId; }
} // Dummy constructor public RemoteVoiceLink(VoiceInfo info, int playerId, int voiceId, int channelId, ref RemoteVoiceOptions options) { } // 0x0000000180F44050-0x0000000180F44150
// Display information about a synthesizer voice. internal static void OutputVoiceInfo(VoiceInfo info) { Console.WriteLine(" Name: {0}, culture: {1}, gender: {2}, age: {3}.", info.Name, info.Culture, info.Gender, info.Age); Console.WriteLine(" Description: {0}", info.Description); }
static bool CreateSynthesizer() { if (tts == null) { Console.WriteLine("\nSpeech Processor: creating Speech Synthesizer"); tts = new SpeechSynthesizer(); tts.SetOutputToDefaultAudioDevice(); tts.SpeakCompleted += new EventHandler<SpeakCompletedEventArgs>(tts_SpeakCompleted); } voiceInfo = null; speaking = false; Console.WriteLine("\nThe following Voices are available:"); foreach (InstalledVoice voice in tts.GetInstalledVoices()) { // Prepare a listview row to add Console.Write(" "+voice.VoiceInfo.Name); Console.WriteLine(voice.VoiceInfo.Culture.ToString()); if (voice.VoiceInfo.Culture.Name.Equals(strCulture)) { voiceInfo = voice.VoiceInfo; } } if (voiceInfo != null) { Console.WriteLine("\nUsing voice " + voiceInfo.Name + " for culture " + strCulture); tts.SpeakAsyncCancelAll(); tts.SelectVoice(voiceInfo.Name); Speak("Okay."); return (true); } Console.WriteLine("\nSpeech Processor: could not find a voice synthesizer for culture ..." + strCulture); return (false); }
} // Dummy constructor internal EncoderShort(VoiceInfo i, ILogger logger) { } // 0x0000000180F1C740-0x0000000180F1C7E0
static void Main(string[] args) { LinkedList <VoiceInfo> lst = new LinkedList <VoiceInfo>(); VoiceInfo selectedVoice = null; SpeechSynthesizer synth = new SpeechSynthesizer(); //using (SpeechSynthesizer synth = new SpeechSynthesizer()) { // Output information about all of the installed voices. Console.WriteLine("Installed voices -"); foreach (InstalledVoice voice in synth.GetInstalledVoices(/*new CultureInfo("zh-HK")*/)) { lst.AddLast(voice.VoiceInfo); VoiceInfo info = voice.VoiceInfo; string AudioFormats = ""; foreach (SpeechAudioFormatInfo fmt in info.SupportedAudioFormats) { AudioFormats += String.Format("{0}\n", fmt.EncodingFormat.ToString()); } if (string.Compare(info.Culture.Name, "zh-HK", true) == 0) { if (info.Name.ToLower().StartsWith("microsoft tracy")) { selectedVoice = info; } } Console.WriteLine(" Name: " + info.Name); Console.WriteLine(" Culture: " + info.Culture); Console.WriteLine(" Age: " + info.Age); Console.WriteLine(" Gender: " + info.Gender); Console.WriteLine(" Description: " + info.Description); Console.WriteLine(" ID: " + info.Id); Console.WriteLine(" Enabled: " + voice.Enabled); if (info.SupportedAudioFormats.Count != 0) { Console.WriteLine(" Audio formats: " + AudioFormats); } else { Console.WriteLine(" No supported audio formats found"); } string AdditionalInfo = ""; foreach (string key in info.AdditionalInfo.Keys) { AdditionalInfo += String.Format(" {0}: {1}\n", key, info.AdditionalInfo[key]); } Console.WriteLine(" Additional Info - " + AdditionalInfo); Console.WriteLine(); } } if (selectedVoice == null) { Console.Beep(); Console.WriteLine("没有检索到粤语语音库 Microsoft Tracy,按任意键退出 ..."); Console.ReadKey(); return; } //PromptBuilder sayAs = new PromptBuilder(); MsTTSBuilder sayAs = new MsTTSBuilder(); sayAs.StartVoice(selectedVoice); TimeSpan delay = new TimeSpan(0, 0, 1); sayAs.Add_As_DateTime_Text(/*ref sayAs, */ "2021-4-14 23:21"); sayAs.AppendBreak(delay); sayAs.Add_As_Date_Text(/*ref sayAs, */ "2021-4-1"); sayAs.AppendBreak(delay); sayAs.Add_As_Time_Text(/*ref sayAs, */ "23:15"); sayAs.AppendBreak(delay); sayAs.Add_As_Fast_Text(/*ref sayAs, */ "这串文字很快啊"); sayAs.AppendBreak(delay); sayAs.Add_As_Slow_Text(/*ref sayAs, */ "这串文字很慢啊"); sayAs.AppendBreak(delay); sayAs.Add_As_Normal_Text(/*ref sayAs, */ "这里加入了普通文字"); sayAs.AppendBreak(delay); sayAs.Add_As_Number_Text(/*ref sayAs, */ "12345"); sayAs.AppendBreak(delay); sayAs.Add_As_Number_Text(/*ref sayAs, */ "123.45"); sayAs.AppendBreak(delay); sayAs.Add_As_SoundSoft_Text(/*ref sayAs, */ "这里声音很低"); sayAs.AppendBreak(delay); sayAs.Add_As_SoundMedium_Text(/*ref sayAs, */ "这里声音中等"); sayAs.AppendBreak(delay); sayAs.Add_As_SoundLoud_Text(/*ref sayAs, */ "这里声音很大"); sayAs.AppendBreak(delay); sayAs.Add_As_SpellOut_Text(/*ref sayAs, */ "这里 拼读 12345.123 clock is a fox"); sayAs.AppendBreak(delay); sayAs.Add_As_Telephone_Text(/*ref sayAs, */ "(0759) 2134-567"); sayAs.AppendBreak(delay); sayAs.Add_As_Time12_Text(/*ref sayAs, */ "3:45pm"); sayAs.AppendBreak(delay); sayAs.Add_As_Time12_Text(/*ref sayAs, */ "11:10am"); sayAs.AppendBreak(delay); sayAs.Add_As_Time24_Text(/*ref sayAs, */ "13:20"); sayAs.AppendBreak(delay); sayAs.Add_As_Time24_Text(/*ref sayAs, */ "1:10"); sayAs.AppendBreak(delay); sayAs.Add_As_Time24_Text(/*ref sayAs, */ "12:00"); sayAs.AppendBreak(delay); sayAs.EndVoice(); bool saved = false; synth.SpeakProgress += new EventHandler <SpeakProgressEventArgs>(synth_SpeakProgress); try_talk_again: synth.SetOutputToDefaultAudioDevice(); synth.Speak(sayAs); show_menu_again: Console.Beep(); Console.WriteLine("空格键-再读一遍\ns-保存为文件\np-播放保存的文件\n其他按键,退出程序."); ConsoleKeyInfo kinfo = Console.ReadKey(); if (kinfo.KeyChar == 0x20) { goto try_talk_again; } else if (kinfo.KeyChar == 's' || kinfo.KeyChar == 'S') { synth.SetOutputToWaveFile(@"D:\\temp\\a.wav"); synth.Speak(sayAs); synth.SetOutputToDefaultAudioDevice(); saved = true; goto show_menu_again; } else if ((kinfo.KeyChar == 'p' || kinfo.KeyChar == 'P') && saved) { System.Media.SoundPlayer m_SoundPlayer = new System.Media.SoundPlayer(@"D:\\temp\\a.wav"); m_SoundPlayer.PlaySync(); goto show_menu_again; } sayAs.ClearContent(); // 释放资源 synth.Dispose(); }
/* * Text to Speech */ public Tts() { Console.WriteLine("TTS constructor called"); //create sound player //player = new SoundPlayer(); //create speech synthesizer tts = new SpeechSynthesizer(); // show voices // Initialize a new instance of the SpeechSynthesizer. using (SpeechSynthesizer synth = new SpeechSynthesizer()) { // Output information about all of the installed voices. Console.WriteLine("Installed voices -"); foreach (InstalledVoice voice in synth.GetInstalledVoices()) { VoiceInfo info = voice.VoiceInfo; string AudioFormats = ""; foreach (SpeechAudioFormatInfo fmt in info.SupportedAudioFormats) { AudioFormats += String.Format("{0}\n", fmt.EncodingFormat.ToString()); } Console.WriteLine(" Name: " + info.Name); Console.WriteLine(" Culture: " + info.Culture); Console.WriteLine(" Age: " + info.Age); Console.WriteLine(" Gender: " + info.Gender); Console.WriteLine(" Description: " + info.Description); Console.WriteLine(" ID: " + info.Id); Console.WriteLine(" Enabled: " + voice.Enabled); if (info.SupportedAudioFormats.Count != 0) { Console.WriteLine(" Audio formats: " + AudioFormats); } else { Console.WriteLine(" No supported audio formats found"); } string AdditionalInfo = ""; foreach (string key in info.AdditionalInfo.Keys) { AdditionalInfo += String.Format(" {0}: {1}\n", key, info.AdditionalInfo[key]); } Console.WriteLine(" Additional Info - " + AdditionalInfo); Console.WriteLine(); } } //Console.WriteLine("Press any key to exit..."); //Console.ReadKey(); //set voice tts.SelectVoiceByHints(VoiceGender.Male, VoiceAge.NotSet, 0, new System.Globalization.CultureInfo("pt-PT")); //tts.SelectVoice("...") //set function to play audio after synthesis is complete tts.SpeakCompleted += new EventHandler <SpeakCompletedEventArgs>(tts_SpeakCompleted); }
private void UpdateSpeechData(VoiceInfo voice, string text, double rate, int pitch) { _builder.ClearContent(); _builder.StartVoice(voice); var prosody = $"<prosody rate=\"{rate}\" pitch=\"{pitch}st\">"; _builder.AppendSsmlMarkup(prosody); _builder.AppendText(text); _builder.AppendSsmlMarkup("</prosody>"); _builder.EndVoice(); }