Voice Recognition MIT app inventor - app-inventor

I am creating a voice recognition app with MIT AppInventor that can match the voice I recorded that will activate the alarm. Problem is that I don't know how to match the voice I recorded to my voice recognition app to be able for the phone to activate the alarm.

All you need to do is add a series of codes that save your recorded audio/speech recognizer input to a TinyDB. To do this, you create a button or something to trigger the block "call speech recognizer.get text". After that is done you place down the "After SpeechRecognizer.get text" block and inside it place the "call DB1.store value", and set the value to the variable "result" provided by "After speechrecognizer.get text". I made an example with a few other things that make it seem larger than it actually is, mainly other means of security. The screenshot is outdated, I added a few things after but they're just minor preference tweaks that have no effect on the functionality of the program. Please enjoy!
https://docs.google.com/document/d/14PunjHwjBxdyJcaKtoNydpz7U5w2FgQwPXUrRjGNqpk/edit?usp=sharing.

Related

How can I acquire text from text filed

I am new to programming and am trying to design a Fortune Teller game according to a book "Applescript studio programming for the absolute beginner".
When the player types the question in the Text Field and then clicks the "Ask" button, the program will randomly give the answer "Yes" "No" "Maybe".
I did as the book instructed. But when I press build and go in Xcode, it returns "2018-04-08 22:22:01.189 Fortune Teller[14813:245050] *** -[AppDelegate clicked:]: Can’t get every text of TextField of class "NSObject". (error -1728)"
Can anyone tell me how to fix that problem? Thank you!
The following is the interface.
The following is the code.
-- This code runs whenever the player clicks on the Ask button
on clicked_(theObject)
-- Assign the text entered by the player clicks on the Ask button
set the question to contents of text field "textbox" of window "main"
-- Display an error message if the player did not enter any text
if question = "" then
display dialogue ¬
"Sorry, but you did not ask a question. Please try again."¬
buttons {"OK"}
return
end if
-- Assign a random number between 1 and 3 to a variable named random
set randomNo to a random number from 1 to 3
if randomNo = 1 then
set answer to "Yes"
end if
if randomNo = 2 then
set answer to "No"
end if
if randomNo = 3 then
set answer to "Maybe"
end if
beep -- Play a beep sound to get player's intention
display display dialog "Question:" & question & "Answer:" & answer & buttons {"OK"}
end clicked_
Ouch. Get a new book.
Mac OS X 10.6 replaced AppleScript Studio with AppleScript-ObjC. Unlike ASS, which gave you AppleScript-style commands and classes for controlling Cocoa, ASOC is just a thin wrapper around Cocoa’s Objective-C APIs, meaning you need to learn those APIs before you can use it.
Shane Stanley used to have an e-book on GUI programming with ASOC, but I think it’s out of print unfortunately. There was an introductory chapter to GUI programming with ASOC at the end of Apress’s Learn AppleScript, 3rd edition (which I co-wrote), and the AppleScript Users mailing list/MacScripter.net forum can no doubt point you to whatever other resources are out there. But all in all, documentation and support is not great. You pretty much have to learn ObjC in order to use ASOC effectively, even if just to read the Cocoa documentation and translate it to AS syntax in your head. And it hasn’t been updated in several years so lacks support for newer ObjC features such as blocks, which means you end up writing ObjC code anyway if you want to use those APIs.
..
Frankly, if your goal is to write your own GUI Apps (rather than automate existing ones), I strongly recommend you bite the bullet and learn Apple’s Swift. While it’s a bloated mess of a language, it’s well-documented, widely-used, and 100% supported by Apple [unlike AppleScript]. With Apple recently announcing a new GUI framework for writing iOS and macOS apps, it’s clear that Swift is the future.
If you need a bit of AppleScript to talk to other apps, it is possible to mix Swift and AS in the same app; but that’s a different question for a separate post.

Autocomplete/suggest functionality in an applescript input box

I am trying to build an applescript dialog that helps me keep track of the things I am working on. To make it really effective I'd like to have it look up items from my todo list and suggest them as I type a la google suggest or other javascript autocomplete functionality.
I was thinking it would be fairly simple if I just captured the input of the # key, which I wanted to use to denote project or the # key for tasks and at that point started matching the input to my list of tasks or projects. For example, lets say I type:
"Worked on feature for #"
At this point the input of the # would start capturing keyboard input and try to suggest one of the projects on my todo list. This is where I am stuck. It seems like I should be able to attach a listener or something to my input box but I can't seem to find any examples or reference to such functionality.
You can't do this with applescript. You need to build your own window in a cocoa application and then hook into the NSTextField's methods to do this. It's not too difficult but it requires a whole different set of skills than applescript.

OSX: detect SPACEBAR down and up events

I need to record several thousand short soundbites of my own speech (I'm training an acoustic model for a speech recognition engine)
So for each one, a line of text presents itself on the screen and I have to speak it, and capture the audio into a .WAV
I found a sample project for recording the audio; now I am trying to figure out how to do keyboard input.
I would like to push the SPACEBAR down to start recording and release it to terminate the recording.
Can anyone get me started? ( an example would be ideal! )
Sorry, this is probably really really basic -- I haven't done any coding in OS X before (though I have done a lot of iOS work so I am no stranger to Xcode and some of the frameworks)
If you create a basic Cocoa application, you can use the following methods of NSResponder, of which NSView is a subclass, to capture your desired key up/down events:
-(void)keyDown:(NSEvent*)event;
-(void)keyUp:(NSEvent*)event;
Use [event keyCode] to get the key pressed.

Is it possible to "trick" PrintScreen, swap out the contents of my form with something else before capture?

I have a bit of a challenge.
In an earlier version of our product, we had an error message window (last resort, unhandled exception) that showed the exception message, type, stack trace + various bits and pieces of information.
This window was printscreen-friendly, in that if the user simply did a printscreen-capture, and emailed us the screenshot, we had almost everything we needed to start diagnosing the problem.
However, the form was deemed too technical and "scary" for normal users, so it was toned down to a more friendly one, still showing the error message, but not the stack trace and some of the more gory details that I'd still like to get. In addition, the form was added the capabilities of emailing us a text file containing everything we had before + lots of other technical details as well, basically everything we need.
However, users still use PrintScreen to capture the contents of the form and email that back to us, which means I now have a less than optimal amount of information to go on.
So I was wondering. Would it be possible for me to pre-render a bitmap the same size as my form, with everything I need on it, detect that PrintScreen was hit and quickly swap out the form contents with my bitmap before capture, and then back again afterwards?
And before you say "just educate the users", yes, that's not going to work. These are not out users, they're users at our customers place, so we really cannot tell them to wisen up all that much.
Or, barring this, is there a way for me to detect PrintScreen, tell Windows to ignore it, and instead react to it, by dumping the aformentioned prerendered bitmap onto the clipboard ready for placing into an email?
The code is C# 3.0 in .NET 3.5, if it matters, but pointers for something to look at/for is good enough.
Our error-reporting window has these capabilities:
Show a screenshot that was taken when the error occured (contains all the open windows of the program at the time, before the error dialog was shown)
Show a text file containing every gory detail we can think of (but no sensitive stuff)
Save the above two files to disk, for latter attaching to an email or whatnot by the user
Sending the above two files to us by email, either by opening a new support case, or entering an existing support case number to add more information to it
Ignore the problem and hope it goes away (return to app)
Exit the application (last resort)
We still get screenshots from some users. Not all, mind you, so my question is basically how I can make the PrintScreen button help us a bit more for those users that still use it.
One option: Put the stack trace and other scary stuff into the error screen using small, low-contrast type -- e.g. dark gray on light gray -- so that the user doesn't really even see it, but the Print Screen captures it.
But if you want to detect the PrintScreen and do your own thing, this looks like an example of what you want.
Wouldn't it be possible to disable the Print Screen button altogether when the error popup is active? Have it display a message along the lines of "Please use the clearly visible button in the middle of your screen to report the error" I agree it breaks expected functionality, but if your users are really that stupid, what can you do...
Alternatively, have it report errors automatically (or store the data locally, to be fetched later, if you can't send without asking for some reason), without asking the user. If you want to be able to connect print screened screenshots with detailed error data, have it send a unique ID with the data that's also displayed in the corner of the popup.
What about offering them a "Print Screen" button that performs these actions as well as performing the print screen? If you're locked into this method of having your customers send error details, this may be an easier route to take.
Lifted from my comment below for easier reference (looks helpful, perhaps):
codeproject.com/KB/cs/PrintScreen.aspx
This is in theory...the best way to deal with it I would think
Intercept a WM_PRINT message or inject one into your process... see this article here
Install a system-wide keyboard hook and intercept the print-screen key and swap it around with your contents prior to the capture. Now, I can point you to several places for this, here on CodeProject, and here also, keyboard spy, and finally, global Mouse and keyboard hook on CodeProject.
Now, once you intercept the print screen, invoke the WM_PRINT message by capturing the contents that you want to capture.
I know this is brief and short, but I hope this should get you going.
The only solution i came up with was to offer big, large, easy to read toolbar buttons that give the user every opportunity to save the contents of the error dialog:
Save
Copy to clipboard
Send using e-mail
Print
And after all that, i use the Windows function SetWindowDisplayAffinity in order to show the user a black box where the form should be:
This function and GetWindowDisplayAffinity are designed to support the window content protection feature that is new to Windows 7. This feature enables applications to protect their own onscreen window content from being captured or copied through a specific set of public operating system features and APIs. However, it works only when the Desktop Window Manager(DWM) is composing the desktop.
It is important to note that unlike a security feature or an implementation of Digital Rights Management (DRM), there is no guarantee that using SetWindowDisplayAffinity and GetWindowDisplayAffinity, and other necessary functions such as DwmIsCompositionEnabled, will strictly protect windowed content, for example where someone takes a photograph of the screen.
If their screenshots show a big black box, hopefully they'll get the hint.
I did add a defeat, if they hold down shift while clicking "show error details", i don't add the protection during form construction:
//Code released into public domain. No attribution required.
if (!IsShiftKeyPressed())
SetWindowDisplayAffinity(this.Handle, WDA_MONITOR); //Please don't screenshot the form, please e-mail me the contents!

Descriptive label names in a desktop application

I have an application that displays a dialog when the user needs to enter information. The reason for this, is to keep the main form readonly, and only when you need to add/edit data will a dialog appear.
The problem I'm wrestling with is what to display for the label names in the dialog. The application is a WPF desktop app and traditionally desktop apps are very short on label names (usually one or two words). I want to make the dialog user friendly and be more descriptive about the information that is required. Web developers seem to be catching on to this and are much more descriptive with their label names, but most of the forms I've looked at are forms that are only filled in once, whereas I will have data that can be edited.
An example: If I had a label that asked a user if an employee smoked, in most a destop apps the label would normally be something like 'Smokes?' with a checkbox, whereas I want something like 'Does the employee smoke?'. My issue with this is, that the first time you come across this dialog and enter the data, then it seems OK, but what about when you are editing data that is already there. Does this label now make any sense. Past tense and present tense seem to be getting in my way and I was interested in what people think or ways they have approached this. The application I'm writing is a WPF app and I feel that traditional label names are a bit old in the tooth now.
Another example would be entering contact details for a person. Do I just have labels that say Phone, Fax, Email or something more descriptive. i.e. a label that appears before the textboxes stating 'Enter the contact details below' and then the single word labels?
Maybe I'm just being pedantic about all this, but I would like to take a step forward so that my application contains more than single word labels that are sometimes unclear to the user about what is required.
Why not make use of the concise labels and use Tool tips for a longer explanation.
The longer explanation is only required when a user is unfamiliar with the application anyway.
Also, you could re-word a label to make it sound more like a question such as "Is a Smoker?"
Since you are using Stack Overflow, take note of their use of tooltips, I think Jeff Attwood has a blog post or comments in a podcast about the use of tooltips in SO. I can't remember where I heard / read it.
Have you thought about creating a "quickstart" flow or wizard for entering data for the first time? This would give you the opportunity to guide the user through the process, using labels with descriptions, so that they learn to associate the description with the label you've chosen (hopefully something succinct but intuitive). Then when they need to edit data, they have learned the application taxonomy.
If you are running into issues with tenses, steer clear of using verbs or only use the present tense. I would try using nouns - "smoker?" instead of "smokes?"
When you're asking for common data like phone numbers, email addresses, you can probably assume that the user will understand what you mean. Just be clear as to whose contact information you are asking for - using a title for the field set that is explicit is a good idea ("Employee Contact Details"), adding a short description above the field set will help too.
Of course, you should always do some level of usability testing on your application before you launch it to uncover any issues with the interface.

Resources