public async Task <bool> TryInitializeAsync(IQiConnectionServiceProxy conn) { if (IsStarted || IsDisposed) { return(false); } if (IsInitialized) { return(true); } var session = conn.CurrentSession; if (session?.IsConnected != true) { return(false); } return(await Task.Run(() => { //仮想ロボットとかだとALAudioDeviceが無いことに注意 var audioDevice = session.GetService("ALAudioDevice"); if (audioDevice.Name != ALAudioDeviceServiceName) { return false; } _session = session; _audioDevice = audioDevice; IsInitialized = true; return true; })); }
private void OnCurrentSessionChanged(object sender, PropertyChangedEventArgs e) { if (!(sender is IQiConnectionServiceProxy)) { return; } if (e.PropertyName != nameof(_connectionService.CurrentSession)) { return; } if (_currentSession == _connectionService.CurrentSession) { return; } if (_currentSession != null) { UnsubscribeDialogIO(_currentSession); } _currentSession = _connectionService.CurrentSession; if (_currentSession != null) { SubscribeDialogIO(_currentSession); } }
private void UnsubscribeDialogIO(IQiSessionProxy session) { if (_humanSignals.ContainsKey(session.Url)) { _humanSignals[session.Url].DisconnectSignal(OnHumanSpeechDetected); _humanSignals.Remove(session.Url); } if (_robotSignals.ContainsKey(session.Url)) { _robotSignals[session.Url].DisconnectSignal(OnRobotSpeechDetected); _robotSignals.Remove(session.Url); } }
private void SubscribeDialogIO(IQiSessionProxy session) { var mem = session.GetService("ALMemory"); //人の会話検出 var signalHuman = mem.CallObject("subscriber", new QiString("Dialog/LastInput")); signalHuman.ConnectSignal("signal", OnHumanSpeechDetected); _humanSignals[session.Url] = signalHuman; //ロボット側 var signalRobot = mem.CallObject("subscriber", new QiString("ALTextToSpeech/CurrentSentence")); signalRobot.ConnectSignal("signal", OnRobotSpeechDetected); _robotSignals[session.Url] = signalRobot; }
internal QiSessionChangedEventArgs(IQiSessionProxy currentSession, IQiSessionProxy previousSession) { Current = currentSession; Previous = previousSession; }
internal QiSessionEventArgs(IQiSessionProxy session) { Session = session; }