TalkingCalculator is the bare bones code to create a calculator you can speak to. It will make a calculation based on what you tell it to do and provide (speak to you with) the correct answer (usually).
The code has to be run on a real device (it will not run on the emulator) because of the SpeechRecognizer object is not supported on the emulator.
'Train' the SpeechRecognizer to your voice. Take a deep breath and say everything you want to say in a single sentence, keeping a steady cadence. For example, say 98 point 3 times 7 point 2 equals instead of 98.3 times 7.2 equals . If the app has trouble understanding, say something simple...like perhaps 10 plus 5 equals and see what happens.
TalkingCalculator understands only four Math operations at the moment. Add as many additional operations as you want. If you add a lot more realize soon you may be requesting more processing in the afterspeech event handler than App Inventor's asynchronous processing will allow without errors. The Android Speech Recognizer is fairly smart but is not brilliant. It recognizes you are working with numbers IF you start the request (ASK) with a numeral. If you pause too long between numbers and words, it will mess up.
The app itself is presently pretty dumb, all it does is parse the spoken text into a LIST and it assume the user knows how to speak to it; say first number, say the operator, say the second number then say equals or not (saying equals is not totally necessary but it makes it easier to say the instructions. It has limited error control capability...If you do not provide two numbers and an operator, the app will balk.
The app takes two values and provides a mathematical operation on them. It places the first number mentioned in the red text box (TextBox1) and the subsequent number in the blue text box (TextBox2). It looks for a mathematical operator ( +, -, * or / ) . These operators must be spoken as
+ plus
- minus or subtract
* times
/ divide or divided
. point
and equals
Other words can be used however the SR will only know the words you provide. You cannot provide an operator like "divided by" because this is two 'words' and the parsing separates based on spaces. A developer can re-coded the behavior to accept a spoken "divided by" but is not done in this example. Of course, if you are not in North America and other places where the decimal separator is a point or period ( . ) you will need to provide a comma equivalent. You will need the equivalents of plus, minus, divide , minus in your language (or the language your Android understands).
The app runs very well on a Tablet; the SpeechRecognizer on my phone has some issues and it is necessary to occasionally repeat a request. I expect it is because the Tablet has better hardware and cpu. Your experience might be different. The Google Android SR is very fussy and the coding set is limited.
--
Great fun - well done! :)
--
Dear Steve, I'm not sure if this is relevant or if you'll be interested but I found your posts using the keywords "mit app inventor seoul" on Google so thought I'd ask if you're in Seoul and interested to help with MIT App Inventor training for high school kids at Gimpo this coming 24 July from 2-6pm?
I have made a post here: http://ai2inventor.blogspot.kr/2017/07/trainersta-in-seoul-to-help-on-july-24.html as well. Basically "I am Ernie from Code for Asia Society Ltd. (http://codefor.asia) based in Singapore which aims to make coding inclusive. We are looking for Lead Trainer/Co-Trainers who can help on a pro bono basis from 2-6pm on 24 July. It is for a local school that is running a "Global Issues Forum" which is a week of students researching and discussing global issues to come up with their own solutions to it and Code for Asia is working with a local partner - Debate for All - to encourage students to learn and prototype their solutions using MIT App Inventor.
Our goal is to encourage complete beginners to learn to code and use it as a force for good. The audience is 60 high school students, and both CfA and DfA will have on-site facilitators to support you. We will be able to reimburse relevant transport and food costs for helpers. We also have course materials that we can easily share with you (mostly based on online tutorials actually). Do let me know if you'd be keen/available to help support. You can get in touch with me directly at ernie[at]codefor.asia. Cheers. :)"
--
This reminds me of the old Abbott and Costello comedic routine where
Costello is a door to door vacuum cleaner salesman in the
country, and he dumps dust on a housewife's carpet
over her objections, claiming it will
suck up all the dust or he will eat it.
She hands him a spoon and tells him she has no electricity.
You have to find a speech recognition app for your phone
and install it.
--
@Shivendra I do not know what the issue is on your Samsung Galaxy J7 Prime.
Here are some things you might do to get it to run on your device. The app runs fine on most devices so it would be interesting to note what is different about your Samsung.
1) It might not use the 'standard' Google Speech Recognition engine. This Samsung device may have its own speech recognition engine .
When you press the ASK button, do you see
a screen something like this? If not, TalkingCalculator is not finding the Google Speech Recognizer.
2) If you do see that screen, do you speak in English? and is your phone set for English or Hindi? It's gotta be set to English. If you do not see
the Speech icon, then it is probably that the App Inventor 2 SR component is incompatible with that device , especially if you do not see that screen or
the error message appears as soon as TalkingCalculator is installed.
3) It is possible your phone does not have a TextToSpeech app enabled . The app needs a text-to-speech engine (it can be download it from Google Play). The TTS language
and your device language have to be the same. The lack of a TTS could be the reason the error message does indicate
RECOGNIZE_SPEECH, not Speech Recognizer. The presence of the TTS could be the issue. You could delete the TTS component. The TTS is used to have the device speak the math answer.
and delete the two occurrences of this block , rerun the modified code and try again.
Alternatively you could download Google's Text to Speech engine from the Playstore (because it might not be installed on your device).
4)Something else is causing issues. In the aia, the Screen Sizing is set to Fixed ... perhaps change that to Responsive. That should not be an issue but it might
be a contributing factor.
Is any of this helpful? Did you get TalkingCalculator running?
--
I carefully checked your phone and found that my phone is already Google's Text to Speech engine and it is working properly in Google translator.
And one thing I noticed is that no request has been received from all the applications in the application of the camera to do it, microphone use, etc.
But this application has not asked for any permissions.
--
--
You might be qualified to get a free Samsung Galaxy S8.
답글삭제