예제 #1
0
 public static void Initialize(
     IConsole console,
     ISurface surface,
     IStyle style,
     IDrawings drawing,
     IShapes shapes,
     IImages images,
     IControls controls,
     ISounds sounds,
     IKeyboard keyboard,
     IMouse mouse,
     ITimer timer,
     IFlickr flickr,
     ISpeech speech,
     CancellationToken token)
 {
     TextWindow.Init(console);
     Desktop.Init(surface);
     GraphicsWindow.Init(style, surface, drawing, keyboard, mouse);
     Shapes.Init(shapes);
     ImageList.Init(images);
     Turtle.Init(surface, drawing, shapes);
     Controls.Init(controls);
     Sound.Init(sounds);
     Timer.Init(timer);
     Stack.Init();
     Flickr.Init(flickr);
     Speech.Init(speech);
     Program.Init(token);
 }
예제 #2
0
파일: _Library.cs 프로젝트: mrange/funbasic
 public static void Initialize(         
  IConsole console,
  ISurface surface,
  IStyle style,
  IDrawings drawing,
  IShapes shapes,
  IImages images,
  IControls controls,
  ISounds sounds,         
  IKeyboard keyboard,
  IMouse mouse,
  ITimer timer,
  IFlickr flickr,
  ISpeech speech,
  CancellationToken token)
 {
     TextWindow.Init(console);
      Desktop.Init(surface);
      GraphicsWindow.Init(style, surface, drawing, keyboard, mouse);
      Shapes.Init(shapes);
      ImageList.Init(images);
      Turtle.Init(surface, drawing, shapes);
      Controls.Init(controls);
      Sound.Init(sounds);
      Timer.Init(timer);
      Stack.Init();
      Flickr.Init(flickr);
      Speech.Init(speech);
      Program.Init(token);
 }
예제 #3
0
 public void Show(ISpeech speech)
 {
     Elements.DialoguePanel.SetActive(true);
     Elements.ApplySpeechSettings(speech.SpeechSettings);
     Elements.SpeakerText = speech.SpeakerName;
     Elements.SpeechText  = (speech.AdditiveSpeech ? previousSpeechText : string.Empty) + speech.SpeechText;
 }
예제 #4
0
        public static void Start(ISpeech speech)
        {
            if (run == false)
            {
                MainLoop();
            }

            _speech = speech;
        }
예제 #5
0
        internal static ISpeech GetMockSpeech(string speechText, ISpeechSettings speechSettings)
        {
            ISpeech speech = Substitute.For <ISpeech>();

            speech.AdditiveSpeech.Returns(true);
            speech.SpeechText.Returns(speechText);
            speech.SpeakerName.Returns("Main Character");
            speech.SpeechSettings.Returns(speechSettings);
            return(speech);
        }
예제 #6
0
        // Main entry point for our application
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Create the speech object to use for speech recognition
            speech = new Speech(10);

            this.context = this;

            // Initialize the command matcher and application matcher to use to parse the user's input
            commandMatcher = new CommandStringMatcher(this.Assets.Open("dictionary.txt"));

            // Initialize suggestion manager with default commands
            suggestionManager = new SuggestionManager(this, commandMatcher.Dictionary);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // get the resources from the layout
            recordBtn         = FindViewById <Button>(Resource.Id.recordBtn);
            textBox           = FindViewById <EditText>(Resource.Id.outputTxt);
            enterBtn          = FindViewById <Button>(Resource.Id.enterBtn);
            commandHeaderText = FindViewById <TextView>(Resource.Id.cmdPrompt);
            commandList       = FindViewById <ListView>(Resource.Id.cmdList);

            // Create a button click event for the recordBtn : Nathan
            recordBtn.Click += delegate
            {
                // create the intent and start the activity
                var voiceIntent = speech.setUpIntent(new Intent());
                StartActivityForResult(voiceIntent, 10);
            };

            // coded by Julien
            enterBtn.Click += delegate
            {
                textCommand = textBox.Text;
                string arguments = commandMatcher.process(textCommand);

                if (!commandMatcher.KeyWord.Equals(""))
                {
                    IAction action = Implementations.Action.createAction(context, commandMatcher.KeyWord);
                    action.setArguments(arguments);
                    action.run();
                }
                else
                {
                    this.ErrorMessage("No commands recognised.");
                    var commands = suggestionManager.pullSpecificCommands(textCommand);
                    this.CommandList(commands);
                }

                commandMatcher.KeyWord = "";
            };
        }
예제 #7
0
        public static void Start(ISpeech speech)
        {
            if (run == false)
            {
                thisthread              = new Thread(MainLoop);
                thisthread.Name         = "Warning Engine";
                thisthread.IsBackground = true;
                thisthread.Start();
            }

            _speech = speech;
        }
예제 #8
0
    //-------------------------------------------------------------------------
    public void initSpeech(string app_id, _eSpeechLanguage speech_language)
    {
#if UNITY_ANDROID
        mISpeech = new AndroidSpeech(app_id, speech_language);
        Debug.Log("AndroidSpeech::");
#elif UNITY_IOS
        mISpeech = new IOSSpeech(app_id, speech_language);
        Debug.Log("IOSSpeech::");
#else
        Debug.LogError("Do not supported on this platform. ");
#endif
    }
예제 #9
0
 public RealSenseCamera()
 {
     Session = PXCMSession.CreateInstance();
     _manager = Session.CreateSenseManager();
     ConfigurePoses();
     ConfigureGestures();
     _speech = new Speech();
     _eyesThresholds = new Dictionary<Direction, double> {
         { Direction.Up, 10},
         { Direction.Down, 10},
         { Direction.Left, 10},
         { Direction.Right, 10}
     };
     Debug.WriteLine("SDK Version {0}.{1}", Session.QueryVersion().major, Session.QueryVersion().minor);
 }
예제 #10
0
 public RealSenseCamera()
 {
     Session  = PXCMSession.CreateInstance();
     _manager = Session.CreateSenseManager();
     ConfigurePoses();
     ConfigureGestures();
     _speech         = new Speech();
     _eyesThresholds = new Dictionary <Direction, double> {
         { Direction.Up, 10 },
         { Direction.Down, 10 },
         { Direction.Left, 10 },
         { Direction.Right, 10 }
     };
     Debug.WriteLine("SDK Version {0}.{1}", Session.QueryVersion().major, Session.QueryVersion().minor);
 }
        private async void GetSpeechData()
        {
            IPeopleRepository repository = PeopleRepository.Instance;

            try {
                speech = await repository.GetPoselSpeech(id);

                textView.TextFormatted = Html.FromHtml(speech.Tresc);

                if (viewSwitcher.CurrentView != contentLayout)
                {
                    viewSwitcher.ShowPrevious();
                }
            } catch (ApiRequestException ex) {
                (Activity as BaseActivity).ShowErrorDialog(ex.Message);
            }
        }
        public IEnumerator Say_ShouldWriteAllSpeechTextOnElementSpeechText_WhenPresentingEnds()
        {
            // ARRANGE
            string             targetText        = "Hello World";
            ICoroutineAccessor coroutineAccessor = DialogueTestHelpers.GetMockCoroutineAccessor();
            ISpeech            mockSpeech        = DialogueTestHelpers.GetMockSpeech(
                targetText,
                DialogueTestHelpers.GetMockSpeechSettings()
                );

            ITextPresenter mockTextPresenter = new MockTextPresenter(coroutineAccessor);

            TextMeshProUGUI txtSpeakerName = DialogueTestHelpers.CreateMonoBehaviourObject <TextMeshProUGUI>();
            TextMeshProUGUI txtSpeechText  = DialogueTestHelpers.CreateMonoBehaviourObject <TextMeshProUGUI>();
            GameObject      gameObject     = new GameObject();

            string speakerName = string.Empty;
            string speechText  = string.Empty;
            IDialogueSystemElements mockDialogueSystemElements = Substitute.For <IDialogueSystemElements>();

            mockDialogueSystemElements.DialoguePanel.Returns(gameObject);
            mockDialogueSystemElements.SpeakerNameDisplay.Returns(txtSpeakerName);
            mockDialogueSystemElements.SpeakerNameDisplay.Returns(txtSpeakerName);
            mockDialogueSystemElements.SpeechTextDisplay.Returns(txtSpeechText);
            mockDialogueSystemElements.SpeakerText.Returns(speakerName);
            mockDialogueSystemElements.SpeechText.Returns(speechText);

            IDialogueSystem dialogueSystem = new DialogueSystem(
                mockTextPresenter,
                coroutineAccessor,
                mockDialogueSystemElements
                );

            // ACT
            dialogueSystem.Say(mockSpeech);

            while (dialogueSystem.IsSpeaking())
            {
                yield return(new WaitForFixedUpdate());
            }

            // ASSERT
            Assert.AreEqual(targetText, mockDialogueSystemElements.SpeechText);
        }
예제 #13
0
        Boolean Init()
        {
            if (_speech != null)
            {
                return(true);
            }

            _speech = ObjectContainer.Current.Resolve <ISpeech>();
            if (_speech != null)
            {
                return(true);
            }

            try
            {
                Assembly.Load("System.Speech, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");

                var code = Assembly.GetExecutingAssembly().GetFileResource("MySpeech.cs").ToStr();
                var sc   = ScriptEngine.Create(code, false);
                sc.Compile();

                _speech = sc.Type.CreateInstance() as ISpeech;
                if (_speech == null)
                {
                    return(false);
                }

                if (!_speech.Init())
                {
                    return(false);
                }

                _speech.SpeechRecognized += _rg_SpeechRecognized;

                return(true);
            }
            catch (Exception ex)
            {
                XTrace.WriteException(ex);
                _speech.TryDispose();
                return(false);
            }
        }
        public void Show_ShouldDisplayAllTextInstantly()
        {
            // ARRANGE
            string targetText = "Hello World";

            ITextPresenter textPresenter = Substitute.For <ITextPresenter>();

            textPresenter.CurrentText.Returns(targetText);

            TextMeshProUGUI txtSpeakerName = DialogueTestHelpers.CreateMonoBehaviourObject <TextMeshProUGUI>();
            TextMeshProUGUI txtSpeechText  = DialogueTestHelpers.CreateMonoBehaviourObject <TextMeshProUGUI>();
            GameObject      gameObject     = new GameObject();

            string speakerName = string.Empty;
            string speechText  = string.Empty;
            IDialogueSystemElements dialogueSystemElements = Substitute.For <IDialogueSystemElements>();

            dialogueSystemElements.DialoguePanel.Returns(gameObject);
            dialogueSystemElements.SpeakerNameDisplay.Returns(txtSpeakerName);
            dialogueSystemElements.SpeakerNameDisplay.Returns(txtSpeakerName);
            dialogueSystemElements.SpeechTextDisplay.Returns(txtSpeechText);
            dialogueSystemElements.SpeakerText.Returns(speakerName);
            dialogueSystemElements.SpeechText.Returns(speechText);

            ISpeech speech = DialogueTestHelpers.GetMockSpeech(
                targetText,
                DialogueTestHelpers.GetMockSpeechSettings()
                );

            IDialogueSystem dialogueSystem = new DialogueSystem(
                textPresenter,
                DialogueTestHelpers.GetMockCoroutineAccessor(),
                dialogueSystemElements
                );

            // ACT
            dialogueSystem.Show(speech);

            // ASSERT
            Assert.AreEqual(speech.SpeechText, dialogueSystemElements.SpeechText);
        }
예제 #15
0
        public void SetSpeaker(string speaker)
        {
            MakeConnection();
            iSpeech = null;

            foreach (var v in languageSpeech.Keys)
            {
                if (v == speaker)
                {
                    iSpeech = languageSpeech[v];
                    break;
                }
            }

            if (iSpeech == null)
            {
                return;
            }

            iSpeech.SetLanguage(speaker);
            iSpeech.SetSpeaker(speaker);
        }
예제 #16
0
        public SpeechManager(string languageSpeechPair)
        {
            microsoftSpeech = new MicrosoftSpeech();
            microsoftSpeech.SpeechStarted += OnSpeechStarted;
            microsoftSpeech.SpeechEnded   += OnSpeechEnded;
            microsoftSpeech.VisemeUpdated += OnVisemeUpdated;

            iSpeech = microsoftSpeech;

            if (languageSpeechPair.ToLower().IndexOf("acapela") >= 0)
            {
                acapelaSpeech = new AcapelaSpeech();
                acapelaSpeech.SpeechOpened  += OnSpeechOpened;
                acapelaSpeech.SpeechStarted += OnSpeechStarted;
                acapelaSpeech.SpeechEnded   += OnSpeechEnded;
                acapelaSpeech.VisemeUpdated += OnVisemeUpdated;
            }

            var langPair = languageSpeechPair.Split(',');

            for (var i = 0; i < langPair.Length; i += 2)
            {
                switch (langPair[i + 1].ToLower())
                {
                case "diotek":
                    diotekSpeech = new DiotekSpeech(langPair[i]);
                    diotekSpeech.SpeechStarted += OnSpeechStarted;
                    diotekSpeech.SpeechEnded   += OnSpeechEnded;
                    diotekSpeech.VisemeUpdated += OnVisemeUpdated;
                    languageSpeech.Add(langPair[i], diotekSpeech);
                    break;

                case "acapela": languageSpeech.Add(langPair[i], acapelaSpeech); break;

                case "microsoft":
                default: languageSpeech.Add(langPair[i], microsoftSpeech); break;
                }
            }
        }
예제 #17
0
        IEnumerator Speaking(ISpeech speech)
        {
            Elements.DialoguePanel.SetActive(true);
            Elements.ApplySpeechSettings(speech.SpeechSettings);
            Elements.SpeakerText = speech.SpeakerName;
            previousSpeechText   = Elements.SpeechText;

            textPresenter.Initialize(speech, speech.AdditiveSpeech ? previousSpeechText : string.Empty);

            textPresenter.Present();
            while (textPresenter.IsPresenting)
            {
                if (skip)
                {
                    textPresenter.Skip();
                    skip = false;
                }
                Elements.SpeechText = textPresenter.CurrentText;
                yield return(new WaitForSeconds(0.025f));
            }
            Elements.SpeechText = textPresenter.CurrentText;

            StopSpeaking();
        }
 public void Initialize(ISpeech speech, string preppendText)
 {
     this.speech       = speech;
     this.preppendText = preppendText;
 }
예제 #19
0
 public AudioWriter(ISpeech speech, string source) : base(speech)
 {
     _source = source;
 }
예제 #20
0
 internal static void Init(ISpeech speech)
 {
     _speech = speech;
 }
예제 #21
0
 public TakeNotesCommand(ISpeech speech, string input)
 {
     this.speech = speech;
     this.input  = input;
 }
예제 #22
0
 public SayAsNumberWriter(ISpeech speech, int value)
 {
     _speech = speech;
     _value  = value;
 }
예제 #23
0
 public PauseWriter(ISpeech speech) : base(speech)
 {
 }
예제 #24
0
 public TakeNotesCommand(ISpeech speech)
 {
     this.speech = speech;
 }
예제 #25
0
 public SayWriter(ISpeech speech, string value) : base(speech)
 {
     _value  = value;
     _writer = new PlainTextWriter(value);
 }
예제 #26
0
        public override void ParseJObject(Object obj)
        {
            ISpeech wystapienie = obj as ISpeech;

            wystapienie.Tresc = (JsonObject as JValue).Value as string;
        }
예제 #27
0
    void Update()
    {
        //on left mouse click
        if (Input.GetMouseButtonDown(0) && !EventSystem.current.IsPointerOverGameObject())
        {
            RaycastHit hitInfo  = new RaycastHit();
            Ray        mouseRay = Camera.main.ScreenPointToRay(Input.mousePosition);

            bool traceHit = Physics.Raycast(mouseRay, out hitInfo);

            if (Inventory.myInv.CurrentSelectedItem == -1 && traceHit)
            {
                selectedObject = hitInfo.collider.gameObject;
                IClickAbleInterface canClick = selectedObject.GetComponent <IClickAbleInterface> ();
                ISpeech             canTalk  = selectedObject.GetComponent <ISpeech> ();

                if (canClick != null)
                {
                    canClick.OnClick();
                }

                if (canTalk != null)
                {
                    movementScript.TrySetTalkToObject(selectedObject);
                }

                //check if we are holding over ha UI elemetn
                else if (!EventSystem.current.IsPointerOverGameObject())
                {
                    if (hitInfo.collider.gameObject.CompareTag("Actor") == false && hitInfo.collider.gameObject.CompareTag("Player") == false)
                    {
                        movementScript.TrySetMoveToLocationState(hitInfo.point);
                    }
                }
            }

            mouseClicked           = true;
            mouseLocationPrevFrame = Input.mousePosition;
        }
        //for dragging
        else if (Input.GetMouseButton(0) && mouseClicked)
        {
            RaycastHit hitInfo  = new RaycastHit();
            Ray        mouseRay = Camera.main.ScreenPointToRay(Input.mousePosition);

            if (Inventory.myInv.CurrentSelectedItem == -1 && Physics.Raycast(mouseRay, out hitInfo))
            {
                GameObject          hitObject = hitInfo.collider.gameObject;
                IClickAbleInterface canClick  = hitObject.GetComponent <IClickAbleInterface> ();

                if (canClick != null)
                {
                    Vector3 mouseLocation      = Input.mousePosition;
                    Vector3 deltaMouseLocation = mouseLocation - mouseLocationPrevFrame;

                    canClick.OnDragOver(deltaMouseLocation);
                }
            }

            mouseClicked           = true;
            mouseLocationPrevFrame = Input.mousePosition;
        }

        //when releasing mouse
        else if (Input.GetMouseButtonUp(0))
        {
            if (Inventory.myInv.CurrentSelectedItem == -1 && selectedObject != null)
            {
                IClickAbleInterface canClick = selectedObject.GetComponentInChildren <IClickAbleInterface> ();

                if (canClick != null)
                {
                    canClick.OnClickRelease();
                }

                selectedObject = null;
            }

            else if (Inventory.myInv.CurrentSelectedItem != -1)
            {
                RaycastHit hitInfo  = new RaycastHit();
                Ray        mouseRay = Camera.main.ScreenPointToRay(Input.mousePosition);

                if (Physics.Raycast(mouseRay, out hitInfo))
                {
                    GameObject hitActor = hitInfo.collider.gameObject;

                    IUseItem canUseItem = hitActor.GetComponent <IUseItem> ();

                    if (canUseItem != null)
                    {
                        movementScript.TrySetUseItemOnObject(Inventory.myInv.CurrentSelectedItem, hitActor);
                    }
                }

                Inventory.myInv.DeselectItem();
            }

            mouseClicked = false;
        }
    }
예제 #28
0
 protected BaseSpeach(ISpeech speech)
 {
     _speech = speech;
 }
예제 #29
0
 public MainViewModel(IDialer dialer, IPhonewordTranslator phonewordTranslator, ISpeech speech)
 {
     this.Dialer = dialer;
     this.PhonewordTranslator = phonewordTranslator;
     this.Speech = speech;
 }
예제 #30
0
 public void Say(ISpeech speech)
 {
     StopSpeaking();
     speaking = coroutineAccessor.StartCoroutine(Speaking(speech));
 }
예제 #31
0
 internal static void Init(ISpeech speech)
 {
     _speech = speech;
 }
예제 #32
0
 public SayAsDateWriter(ISpeech speech, DateTime date)
     : base(speech)
 {
     _date = date;
 }
예제 #33
0
    void Update()
    {
        //Debug.Log (agent.remainingDistance);
        float distanceToActor = 0.0f;

        switch (currentPlayerState)
        {
        case EPlayerState.Idle:

            break;

        case EPlayerState.WalkToLocation:
            agent.SetDestination(locationToReach);
            break;

        case EPlayerState.UseItemOnObject:
            agent.SetDestination(objectToUseItemOn.transform.position);

            distanceToActor = (objectToUseItemOn.transform.position - transform.position).magnitude;

            if (distanceToActor <= distanceItemCanBeUsed)
            {
                Inventory.myInv.TryUseItemOnActor(objectToUseItemOn, indexOfItem);
                agent.ResetPath();
                TrySetIdleState();
            }
            break;

        case EPlayerState.TalkToObject:
            agent.SetDestination(objectToTalkTo.transform.position);

            distanceToActor = (objectToTalkTo.transform.position - transform.position).magnitude;

            if (distanceToActor <= distanceItenCanBeTalkedTo)
            {
                ISpeech canTalk = objectToTalkTo.GetComponent <ISpeech> ();

                if (canTalk != null)
                {
                    canTalk.OnTalkTo();
                }
                agent.ResetPath();
                TrySetIdleState();
            }
            break;


        default:
            break;
        }


        /*if (Inventory.myInv.CurrentSelectedItem == -1) {
         *      if (wayPoint != null) {
         *              agent.SetDestination (wayPoint.transform.position);
         *
         *      }
         *
         *      if (Input.GetMouseButtonDown (0)) {
         *              if (!EventSystem.current.IsPointerOverGameObject ()) {
         *                      locatePositionDown ();
         *              }
         *      }
         */
    }