private Speach speach; //this holds the Rhubarb output public async System.Threading.Tasks.Task SpeakAsync(string dialog) //The method is async to wait for the signal { string audioFile = $"res://Speach/{dialog}.wav"; string speachFile = $"res://Speach/{dialog}.json"; //Read the Json file File file = new File(); file.Open(speachFile, File.ModeFlags.Read); var jsonString = file.GetAsText(); file.Close(); speach = Newtonsoft.Json.JsonConvert.DeserializeObject <Speach>(jsonString); //Read the audio file var stream = GD.Load <AudioStreamSample>(audioFile); stream.LoopMode = AudioStreamSample.LoopModeEnum.Disabled; speachPlayer.Stream = stream; speachPlayer.Play(); //Create a tween to call UpdateSpeak, we will pass a delta calculated from zero to speach.Metadata.Duration var tween = new Tween(); AddChild(tween); tween.InterpolateMethod(this, nameof(UpdateSpeak), 0.0f, speach.Metadata.Duration, speach.Metadata.Duration, Tween.TransitionType.Linear, Tween.EaseType.InOut); tween.Start(); //Wait for the tween_completed signal await ToSignal(tween, "tween_completed"); tween.QueueFree(); isSpeaking = false; }
public static Speach instance() { if (_Instance == null) { _Instance = new Speach(); } return(_Instance); }
public async Task <IHttpActionResult> Speak([FromBody] Speach speach) { //Connect the the SignalR hub IHubContext context = GlobalHost.ConnectionManager.GetHubContext <TalkToMeHub>(); //Invoke the method on the hub. await context.Clients.All.Speak(speach.TextToRead); //Return HTTP statuscode 202/Accepted. return(StatusCode(HttpStatusCode.Accepted)); }
public void Click() { Execute(() => { if (GingerAutomator.Highlight) { HighlightAdorner highlightAdorner = new HighlightAdorner(mButton); DoEvents(); SleepWithDoEvents(100); Speach.Say("Click Button " + mButton.Content.ToString()); Thread.Sleep(500); } mButton.RaiseEvent(new System.Windows.RoutedEventArgs(Button.ClickEvent)); }); }
/// <summary> /// セリフの追加 /// </summary> /// <param name="speach"></param> /// <returns></returns> public bool AddSpeach(Speach speach) { if (null == m_SpeachList) { return(MyUtil.ErrorLog("null値の変数です。")); } if (null == speach) { return(MyUtil.ErrorLog("null値の変数です。")); } // セリフリストにセリフを追加する m_SpeachList.Add(speach); return(true); }
public void Awake() { //base.Start (); //target = GameObject.Find ("cactus").transform; nmagent = GetComponent <NavMeshAgent> (); nmagent.destination = pickrndpos(); dialog = new List <string> (); dialog.Add("test speak"); dialog.Add("test speak 2"); dialog.Add("test speak 3"); rng = GetComponent <Rng> (); player = GameObject.FindGameObjectWithTag("Player").transform; // job = new Quest (this); Dialog dbox = GameObject.Find("dialog").GetComponent <Dialog> (); dbox.speaker = this; speach = new Speach(dbox); speach.lines = dialog; speach.quest = true; speach.queststatement = dialog.Count - 1; }
public static Result <Speach> ParseSpeache(HtmlAgilityPack.HtmlNode speackerCell, int sectionId, Section sections, DateTime dateTime, string baseUrl) { //Check Empty var emptyClass = "program__message"; var isEmpty = speackerCell.Descendants("div").FirstOrDefault(x => x.Attributes["class"] != null && x.Attributes["class"].Value.Contains(emptyClass) && string.IsNullOrEmpty(x.InnerText)) != null; if (isEmpty) { return(new Result <Speach>(new Speach { AreaName = sections.AreaName, AreaType = sections.Name, SpeachTesis = "Нет спикера", SpeachStartTime = dateTime })); } var mayBeOpening = speackerCell.Descendants("div").FirstOrDefault(x => x.Attributes["class"] != null && x.Attributes["class"].Value.Contains(emptyClass) && !string.IsNullOrEmpty(x.InnerText)); var isOpening = mayBeOpening != null; if (isOpening) { return(new Result <Speach>(new Speach { AreaName = sections.AreaName, AreaType = sections.Name, SpeachTesis = mayBeOpening.InnerText, SpeachStartTime = dateTime })); } var speach = new Speach(); //speach url var lectionRef = speackerCell.Descendants("a").FirstOrDefault(x => x.Attributes["href"] != null); speach.SpeachUrl = baseUrl + lectionRef.Attributes["href"].Value; //speakers var speakers = speackerCell.Descendants("div").Where(x => x.Attributes["class"] != null && x.Attributes["class"].Value == "program__speaker"); //every speaker var speakersArray = new Speaker[speakers.Count()]; try { for (int i = 0; i < speakers.Count(); i++) { speakersArray[i] = new Speaker(); //name var nameNode = speakers.ElementAt(i).Descendants("div").FirstOrDefault(x => x.Attributes["class"] != null && x.Attributes["class"].Value.Contains("program__speaker-name")); speakersArray[i].Name = nameNode.InnerText.Replace("\n ", ""); //icon var iconNode = speakers.ElementAt(i).Descendants("div").FirstOrDefault(x => x.Attributes["class"] != null && x.Attributes["class"].Value.Contains("program__speaker-image")); var icon = iconNode.Attributes["style"].Value; icon = icon.Replace("background-image: url('", ""); speakersArray[i].FaceImageSource = baseUrl + icon.Replace("')", ""); //company var companyNode = speakers.ElementAt(i).Descendants("div").FirstOrDefault(x => x.Attributes["class"] != null && x.Attributes["class"].Value.Contains("program__speaker-company")); speakersArray[i].Company = companyNode.InnerText.Replace("\n ", ""); } //tesis var tesisNode = speackerCell.Descendants("div").FirstOrDefault(x => x.Attributes["class"] != null && x.Attributes["class"].Value.Contains("program__topic")); speach.SpeachTesis = tesisNode.InnerText.Replace("\n ", ""); speach.Speakers = speakersArray; speach.AreaName = sections.AreaName; speach.AreaType = sections.Name; speach.SpeachStartTime = dateTime; } catch (Exception ex) { return(new Result <Speach>(null, true, ex.Message)); } return(new Result <Speach>(speach)); }
/// <summary> /// セリフ発生の更新処理 /// </summary> private void Speaking() { if (null == m_SpeachList) { MyUtil.ErrorLog("null値の変数です。"); return; } if (0 > m_iCurrentSpeachIndex || m_SpeachList.Count <= m_iCurrentSpeachIndex) { return; } Speach currentSpeach = m_SpeachList[m_iCurrentSpeachIndex]; if (null == currentSpeach) { MyUtil.ErrorLog("null値の変数です。"); return; } // ポーズ中なら処理しない if (PauseScreen.IsPause()) { return; } // セリフのトリガーON currentSpeach.TriggerOn(); // セリフのトリガーOFF currentSpeach.TriggerOff(); // イベントをスキップするキーが押された場合 if (Input.GetKeyDown(KeyCode.Tab)) { GameObject commentObj = currentSpeach.Comment; if (!commentObj) { MyUtil.ErrorLog("null値の変数です。"); return; } Comment comment = commentObj.GetComponent <Comment>(); if (!comment) { MyUtil.ErrorLog("null値の変数です。"); return; } // 現在のコメントを破棄 comment.DestroyComment(); // イベントスキップフラグを立てる m_bSkipIventFlg = true; } // 現在のセリフが終了したら次のセリフに切り替える if (currentSpeach.IsFinished) { // イベントスキップフラグが立っていれば // 現在のセリフのインデックスをリストの要素数以上にして // イベントが終了する数値にする if (m_bSkipIventFlg) { m_iCurrentSpeachIndex = m_SpeachList.Count; } // 現在のセリフのインデックスがセリフリストの要素数以上ならポーズ解除 if (m_SpeachList.Count <= ++m_iCurrentSpeachIndex) { Pauser.Resume(); } } }