Ejemplo n.º 1
0
    private async void Dialog()
    {
        speechIn.StartListening(); //startup native speech
        await Task.Delay(1000);

        await speechOut.Speak("Welcome to the DualPanto Corona Diagnosis App");

        await speechOut.Speak("Time to greet me");

        //Debug.Log("Hello!"); // system says hello
        await speechIn.Listen(new string[] { "hello", "hi", "hey" }); //wait for greet

        //await Task.Delay(2000); // wait 2s
        await speechOut.Speak("How are you?!");

        string health = await speechIn.Listen(new string[] { "I'm fine", "so-so", "I'm sick" }); //wait for response

        switch (health)
        { // switch response
        case "I'm fine":
            Debug.Log("super!");
            break;

        default:
            Debug.Log("alright, take care.");
            await speechOut.Speak("crazylaugh");

            await speechOut.Speak("you really thought I would diagnose you?!");

            break;
        }
        speechIn.StopListening(); //terminates voice recognition
    }
    public async void play(SpeechIn speechIn, SpeechOut speechOut, bool silent = false)
    {
        asr = speechIn;
        tts = speechOut;
        if (!silent & sentences != "")
        {
            await tts.Speak(sentences);
        }
        if (soundSource && soundSource.clip)
        {
            await playSound();
        }
        if (action != null)
        {
            await action.Invoke(actionarg);
        }
        string recognized;

        switch (options.Count)
        {
        case 0:     //no options, endNode
            return;

        case 1:                                //single option, listen without return
            DialogOption singleOption = options.ToArray()[0];
            if (singleOption.commands == null) //option has no commands, move on to next node
            {
                singleOption.next.play(asr, tts);
                return;
            }
            recognized = await asr.Listen(singleOption.commands.ToArray());

            if (checkMetaCommands(recognized) == false)
            {
                singleOption.next.play(asr, tts);
            }
            break;

        default:     // various options
            recognized = await asr.Listen(generateCommandArray());

            foreach (DialogOption option in options)
            {
                if (option.commands.Contains(recognized))
                {
                    option.next.play(asr, tts);
                }
            }
            checkMetaCommands(recognized);
            return;
        }
    }
Ejemplo n.º 3
0
    async Task IntroduceLevel()
    {
        await _speechOut.Speak("There are two obstacles.");

        _lowerHandle.Free(); // we free this here, so that level can introduce "objects of interest"
        Level level = GetComponent <Level>();
        await level.PlayIntroduction();

        _upperHandle.Free();
        await _speechOut.Speak("Feel for yourself. Say yes or done when you're ready.");

        await _speechIn.Listen(new Dictionary <string, KeyCode>() { { "yes", KeyCode.Y }, { "done", KeyCode.D } });
    }
    async Task IntroduceLevel()
    {
        await _speechOut.Speak("There are two obstacles.");

        Level level = GetComponent <Level>();
        await level.PlayIntroduction();

        // TODO: 2. Explain enemy and player with weapons by wiggling and playing shooting sound

        await _speechOut.Speak("Feel for yourself. Say yes or done when you're ready.");

        //string response = await speechIn.Listen(commands);
        await _speechIn.Listen(new Dictionary <string, KeyCode>() { { "yes", KeyCode.Y }, { "done", KeyCode.D } });

        //if (response == "yes")
        //{
        //    await RoomExploration();
        //}
    }
Ejemplo n.º 5
0
 async void Dialog()
 {
     await speechIn.Listen(commands);
 }