Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by ragsr · Dec 31, 2018 at 05:54 PM · script.keyboardvoice

"Keyword already used" error message by voice recognizer script

The script below is one that I've attached to the small sphere in the image below. It is a modified clone of a working script that I have attached to the large sphere in the image below. The working script will move the large sphere forward and back, up and down, using voice commands. I want to use voice commands to change the color of the small sphere to yellow, blue, green, or red. I have a third script that is working and which allows me to change the color of the plane using keyboard inputs, e.g. typing Y changes the plane to yellow.

To create script for the small sphere, I'm trying to use the known good color rendering code of the script for the plane and the known good voice movement code of the script for the large sphere. Unfortunately, I'm running to a "keyword already used" type of error when I do this. The error message is "Argument Exception: At least one keyword must be specified. Parameter name: keywords".

NOTE: In the working voice script the statement "actions.Add("forward", Forward);" was fine and produce no error message so, in the clone script, I used "actions.Add('yellow", Yellow);" but that produced an error that "yellow was already used as a keyword". When I commented out that statement, I got the error message that "...At least one keyword must be specified". So I'm kind of in a Catch 22 situation.

QUESTION: What can be done to fix this? Thanks in advance for you help. It is greatly appreciated. I'm new to Unity. Cheers, Bob G

IMAGE: alt text

SCRIPT: using System; using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine; using UnityEngine.Windows.Speech;

public class VoiceInput05 : MonoBehaviour { private KeywordRecognizer keywordRecognizer; private Dictionary actions = new Dictionary (); public Color altColor = Color.blue; public Renderer rend;

 //public Action White { get; private set; }

 void Start()
 {
     //Got warning from Unity that, for VoiceInput05, the terms "Forward, Back, Up, and Down were a problem ("forward" is already a keyword used by Keyword Recognizer)
     //so I commented their actions out but then got a warning that "at least one keyword was required".  So replaced the Forward with Yellow etc.  But then I got a warning 
     //that red, yellow, blue, and green were already defined as keywords so I commmented them out as well.  Now I get the warning "...At least one keyword must be specified".
     //actions.Add("forward", Forward);
     //actions.Add("back", Back);
     //actions.Add("up", Up);
     //actions.Add("down", Down);
     //actions.Add("yellow", Yellow);
     //actions.Add("blue", Blue);
     //actions.Add("green", Green);
     //actions.Add("red", Red);


     keywordRecognizer = new KeywordRecognizer(actions.Keys.ToArray());
     keywordRecognizer.OnPhraseRecognized += RecognizedSpeech;
     keywordRecognizer.Start();

     rend = GetComponent<Renderer>();
 }
 private void RecognizedSpeech(PhraseRecognizedEventArgs speech)
 {
     //Debug.Log(speech.text);
     actions[speech.text].Invoke();

 }
 private void Red()
 {
     rend.material.color = Color.red;
 }
 private void Yellow()
 {
     rend.material.color = Color.yellow;
 }
 private void Blue()
 {
     rend.material.color = Color.blue;
 }
 private void Green()
 {
     rend.material.color = Color.green;
 }

}

test-project-02-screen-shot-01.jpg (301.5 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by ragsr · Dec 31, 2018 at 06:16 PM

UPDATE FOR MY POST: I just retested the behavior of the script for the small sphere after reinstating the "actions.Add("yellow", Yellow);" like statements for the four colors and it WORKED!

QUESTION: Is it ok to ignore the error messages?

Error message form: Error: there already is a keyword recognizer with "yellow" as one of its keywords. UnityEngine.Windows.Speech.KeywordRecognizer:.ctor(String[])

Cheers, Bob G.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

107 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

health script do not work when collision detected 1 Answer

Keyboard detector 0 Answers

Need help installing plugin: Razer Chroma SDK Plugin Colore 1 Answer

How do i change controller from keyboard to mouse?? 1 Answer

Add Mobile Android and iOS Emojis 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges