I want to compare the speech recognition string input to the preset text string and if it matches correctly, then I want to send a a character, say 'A' over the bluetoothclient. Any suggestions?
--
first do the tutorials http://appinventor.mit.edu/explore/ai2/tutorials.html to learn the basics of App Inventor, then try something and follow the
--
first do the tutorials http://appinventor.mit.edu/explore/ai2/tutorials.html to learn the basics of App Inventor, then try something and follow the
--
thanks for the links. but, i have already gone through them earlier and did the bluetooth part, i Only need help in the string comparison from user input via speech recognition. The string is being detected by the app, only the comparison to that of previously set string.
--
What have you tried. You have not shown any blocks for users to comment on and provide advice.
Where is the recognition text being displayed? In a label? In a TextBox? Where is the comparison text?
The way you compare is using the IF..then blocks...
if label1.text = label2 text
then do something
else
do something else
This example will work in some situations:
Your comparison could be in a Notifier or in a label (I would use a label because both SpeechRecognizer and Notifier have some lag to them and not using a Notifier will help avoid collisions.
SpeechRecognizer is described for AI2 blocks here http://ai2.appinventor. mit.edu/reference/components/ media.html#SpeechRecognizer There are few options when using the Android feature with AI2. Eclipse and Android Studio developers can do many things with SR that App Inventor cannot.
The downcase block (same as the upcase block but use the carrot to change the block) is in the code because AI discriminates between this is the text and This is the text; the statements are not equivalent because AI2 and Android are case sensitive. If you need to discriminate between the two, then you need to write more code. See http://www.appinventor.org/bookChapters/chapter18.pdf and http://www.appinventor.org/bookChapters/chapter20.pdf for possible ways of doing that.
How about trying some blocks. Be aware, Android's SpeechRecognizer is fussy and it does not always return what you expect.
--
Thanks steve, the result from the sppech recognizer is being displayed in a label. And, what I'm trying to do is this :
--
If user input i.e. speechrecognizer.text = "hello"...send character 'A' over bluetooth (as A is command for led on in my arduino code) & if speechrecognizer.text = "bye"....send character 'B' over bluetooth (as B is command for led off in my arduino code).
I'm not really worried about the upper and down cases. All i require is the string input from user and then the app to send a particular character in response of correct match.
--
It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.
--
hello, I am done with the speech recognition comparison of input part. Thanks to the blocks you provided.
The new issue is this : The Commands that I send for a particular speech input, can that command be send for a range of the accelerometer sensor reading?
I have done this but the output is always labeltext2 only. What to fix...?
--
I am through with the SR part. And yeah, you are right, Android's SR is very fussy...so can you suggest any other SR input from the user that works better than this?
And also do check the file I have uploaded, facing a problem with the Setting up of range for the accelerometer ( x axis) reading and if reading is positive, do this...else do that but the problem is it is always 'doing that'....check it out.
--
Google Android has two SR engines, one actually runs on the device, the other runs in the Cloud (you have to be connected to the Internet). There are other third party SR engines : https://www.google.com/search?q=android+speech+recognition&oq=android+speech+recognition&aqs=chrome..69i57.7183j0j7&sourceid=chrome&es_sm=93&ie=UTF-8 . If you load a third-party SR and change the SR engine in the Android Settings (I think one can do this but do not know), you might be able to control the third party engine with AI2. Realize, AI2 can only adjust a few things in the SR; if you want the full capabilities of Google;s SR, you will have to use Eclipse or Android Studio and use Java to program.
You should be able to do what you want to do regarding the acceleraometer... I have no time at the moment to debug... sri .... the issue might be a timing issue. You may have to use a Clock component and do some creative things... I can tell you now, the block random integer from 1.56.... is wrong. the values have to be integers. You can modify that out side the block by converting values.
--
I suppose the cloud SR is for online google search..:/....hmm...i added another TTS and SR engine to my device but google services are way better.
And, yeah I did used the integer at first but that did not solve the issue. A particular integer or number is doing the job but given the accelerometer sensor is very sensitive, so getting a partticular reading and staying at it would be difficult...or impossible. Its better to set up a range for the reading...which is not working.
--
The Cloud SR is not just for online searching; it can be used in your app.
I suspect you should be evaluating Xaccel using a structure like If Xaccel > a value and Xacell< a second value THEN do something else do something else.
Try some blocks. Also the Shaking block is probably continually cycling the Vibrate ... a problem might be that it triggers a new vibration cycle before the existing vibration period ends giving your app a sort of 'heat attack' perhaps?
Also, SR might be interfering with the accelarator messages. Consider, AI2 does NOT process multiple threads. Each command and process must finish before the next starts (really a little more complicated than that but a good simplification ... one thing has to finish before the next thing executes.)
Try some blocks. Only you know how you want this to perform.
--
i got the comparing of accelerometer readings in the range and the labels display correct text and they do keep updating as per the readings. however the call TTS part isn;t working and due to this other speech recognizer block and shaking block too get disturbed so I disconnected all other blocks still the Call TTS part isn't working properly. what might be the error...?
--
hu
답글삭제