Sweetpawn1's Posts
Nairaland Forum › Sweetpawn1's Profile › Sweetpawn1's Posts
1 2 3 4 5 6 7 8 9 10 (of 13 pages)
Dim SpeechGrammer As String word1 = "I" word2 = "Am" word3 = "Very" word4 = "Happy" SpeechGrammer = "[Grammar]" & vbCrLf & _ "langid = 1033" & vbCrLf & _ "type=cfg" & vbCrLf & _ "[<Start>]" & vbCrLf & _ "<start>=" & word1 & vbCrLf & _ "<start>=" & word2 & vbCrLf & _ "<start>=" & word3 & vbCrLf & _ "<start>=" & word4 DirectSR1.GrammarFromString SpeechGrammer DirectSR1.Activate |
DirectSR1.Activate Good, this one is pretty straight forward now! Here we see another method of the "Ear" object called DirectSR1 being used. This one is called Activate and what does it do? Yes, it actually makes the computer to start "Listening" believe it or not, for sound-any sound- from the microphone connected to your computer! Yes and with that we end have the completed set of codes to make the computer listen for the words, "I, am, very, happy" when spoken to a microphone attached to the computer system. So the full code is given below: |
GrammarFromString, ladies and gentlemen is the function that allows our "Ear" tool to "Read" a set of words stored in a "Grammer" from any given String! So the code: DirectSR1.GrammarFromString SpeechGrammer Is saying: "Hey, Ear with the fake coke bottle cover ear-ring, read the words contained in the grammar that I put inside the string called SpeechGrammer, quick no waste my time!" Good, now let's move on. . . |
DirectSR1.GrammarFromString SpeechGrammer Right let's analyze! DirectSR1 is the name of the "Ear" object that we inserted on the form. (The name is automatically given to it once it is added to the form) Now DirectSR1 represents an object and as every good student of OOP knows, objects have methods(Java) or properties(VB) and GrammarFromString is a method/property of the object DirectSR1-If you have no idea of what I am saying, again, its not your fault Let me speak in English, so that I will be fair to everybody! Our "Ear" object has many characteristics/functions just as for example, a dog can bark and bite. In programming, we say that a dog is an object that has the methods/properties bark and bite. So our "Ear" object called DirectSR1 which represents the Direct Speech Recognition Tool in the VB environment, has a function or method or property called GrammarFromString What does GrammarFromString do? ![]() |
Now, let us continue with the rest of the code! As a recap, we started with: Dim SpeechGrammer As String Then we went over to: word1 = "I" word2 = "Am" word3 = "Very" word4 = "Happy" And then did the ugly bit: SpeechGrammer = "[Grammar]" & vbCrLf & _ "langid = 1033" & vbCrLf & _ "type=cfg" & vbCrLf & _ "[<Start>]" & vbCrLf & _ "<start>=" & word1 & vbCrLf & _ "<start>=" & word2 & vbCrLf & _ "<start>=" & word3 & vbCrLf & _ "<start>=" & word4 Moving forward. . . |
Because when I want to change the words in my grammar from "I,am,very,happy" to "I,am,now,hungry", I do not have to touch that ugly-looking piece of code again, I will just change: word1 = "I" word2 = "Am" word3 = "Very" word4 = "Happy" to this: word1 = "I" word2 = "Am" word3 = "Now" word4 = "Hungry" without touching this: SpeechGrammer = "[Grammar]" & vbCrLf & _ "langid = 1033" & vbCrLf & _ "type=cfg" & vbCrLf & _ "[<Start>]" & vbCrLf & _ "<start>=" & word1 & vbCrLf & _ "<start>=" & word2 & vbCrLf & _ "<start>=" & word3 & vbCrLf & _ "<start>=" & word4 |
The difference is that the first one makes use of the variables word1,word2,word3 and word4 to store the grammar words while the other two put the words in the code straight! Why did I use the first piece of code then and not any of the other two? ![]() |
A SMALL NOTE: I could have written this: SpeechGrammer = "[Grammar]" & vbCrLf & _ "langid = 1033" & vbCrLf & _ "type=cfg" & vbCrLf & _ "[<Start>]" & vbCrLf & _ "<start>=" & word1 & vbCrLf & _ "<start>=" & word2 & vbCrLf & _ "<start>=" & word3 & vbCrLf & _ "<start>=" & word4 as this: SpeechGrammer = "[Grammar]" & vbCrLf & _ "langid = 1033" & vbCrLf & _ "type=cfg" & vbCrLf & _ "[<Start>]" & vbCrLf & _ "<start>=" & "I" & vbCrLf & _ "<start>=" & "Am" & vbCrLf & _ "<start>=" & "Very" & vbCrLf & _ "<start>=" & "Happy" or even this: SpeechGrammer = "[Grammar]" & vbCrLf & _ "langid = 1033" & vbCrLf & _ "type=cfg" & vbCrLf & _ "[<Start>]" & vbCrLf & _ "<start>=I" & vbCrLf & _ "<start>=Am" & vbCrLf & _ "<start>=Very" & vbCrLf & _ "<start>=Happy" They are all doing the same thing, but what is the difference? ![]() |
So after given honor to whom honor is due, what next? Next we see how we can write our dictionary in the VB language. . .that's where that ugly piece of code came in! But now, I believe with the given explanations, it wont be so hard for us to understand the code. SpeechGrammer = "[Grammar]" & vbCrLf & _ We are assigning the dictionary we created above into the string called SpeechGrammer, however we have to write the dictionary in a way that VB will understand so that there wont be any syntax error from the programming language. Because each line of the dictionary is seperated by the ENTER key, we have to add & vbCrLf & _ at the end of each statement from the dictionary. (What & vbCrLf & _ do is your take home assignment with google and not part of our topic for today! )So the dictionary written in the VB syntax looks like this: SpeechGrammer = "[Grammar]" & vbCrLf & _ "langid = 1033" & vbCrLf & _ "type=cfg" & vbCrLf & _ "[<Start>]" & vbCrLf & _ "<start>=" & word1 & vbCrLf & _ "<start>=" & word2 & vbCrLf & _ "<start>=" & word3 & vbCrLf & _ "<start>=" & word4 |
Okay, what next? We hail a Legend. I though he would Fail in his come back, but I was put to shame by my words when he did not Fail. . . So to a Great man. . . I salute. . .The one and only. . . [center][size=58pt]IGWE[/size][/center] [size=5pt]By the way I am not an arsenal fan-no offense to them, I only admire great players![/size]
|
Good, let's see how to write a dictionary for the computer! First, we look at the format for writing a computer dictionary. . . We first start by writing: [Grammar] This means that we want to add words to the dictionary that will form the computer's grammar set. After this we insert "enter" key.(This is very important as it tells the computer were a line as ended in the dictionary. . .) *PRESS ENTER* Next comes: langid = 1033 This tells computer that the words are from the English language. *PRESS ENTER* Next comes: type=cfg This tells the computer the type of English (In this case American English-So when you talk, you have to speak fene !)*PRESS ENTER* Next we have: [<Start>] This Start indicates that we will start adding the words to the dictionary here. . . *PRESS ENTER* Next comes: <start>=typethewordhere Now this is where we will actually start adding our words to the dictionary for example, to add our first word, "I", we type this: <start>=I and then we *PRESS ENTER* Then we add the other words that will form our grammar in the same way. When we come to the last word of our grammar, we close the dictionary like this: <start>=typelastwordhere . . .without putting enter! So to create a dictionary for our 4 words, this is how we will type it. . . [Grammar] langid = 1033 type=cfg [<Start>] <start>=I <start>=Am <start>=Very <start>=Happy See, it's beginning to make sense now! ![]() |
I dey see as dem dey do am for TV ati Radio so make me too follow do, afterall, na my Show be this! [center][size=18pt] A MESSAGE FROM OUR SPONSORS! [/size] [/center]Oya, Final Year Engineering/Computer Engineering Students interested in creating PC controlling devices like the PC Switch Box in the images below can send a mail to info@code4me.tk or visit www.code4me.tk for any other project topic you may be interested in. [center][size=18pt] THE END [/size] https://code4me.eu5.org/ad.JPG
|
Right, before the computer can "understand" what you say, it has to given a set of words which will form its language set or vocabulary or grammar , much in the same way a child will have to be taught a set of words first before it can learn how to speak. So you will have to create a kind of dictionary, where all the words that will make up the computer's grammar will be stored. That was why we created the SpeechGrammer string variable. It is the variable that will contain the computer's grammar. We have decided, for the sake of this lesson, to populate the grammar of the PC with 4 words: I,am,very,happy. These words we have stored in the variables[b] word1[/b],word2,word3 and word4. Okay, so the next thing is: How do we create the dictionary and add the words to it? Just as there is a format for writing a human dictionary, it follows logically that there should be a special format for writing a computer's dictionary-remember, we are programmers, we talk to the computer in a language it understands-so we should write a dictionary, the way that the computer will understand! Next we shall look at the format for writing the dictionary for the computer. . . |
I don see wetin I go chop tonite! Enough of business, let's continue with pleasure. . . Now the first line of code: Dim SpeechGrammer As String We are declaring a String variable called SpeechGrammer, later we will discuss what it will hold. . . word1 = "I" Now the word that we are going to say for the PC to type is going to be stored in this string variable called word1. Are you asking why do we need to store the words we have to say in a variable? If you are asking, you are a good student for asking that question and I will explain shortly, if you did not ask, well, its not your fault. What we have done in the code above is to assign to the the variable called word1 the string value, "I", which is one of the words we are going to tell the PC to type. The code for the other words are given below. . . word2 = "Am" word3 = "Very" word4 = "Happy" There! we are going to have four words: I,Am,Very,Happy Now here comes the ugly bit! SpeechGrammer = "[Grammar]" & vbCrLf & _ "langid = 1033" & vbCrLf & _ "type=cfg" & vbCrLf & _ "[<Start>]" & vbCrLf & _ "<start>=" & word1 & vbCrLf & _ "<start>=" & word2 & vbCrLf & _ "<start>=" & word3 & vbCrLf & _ "<start>=" & word4 Okay, do not be afraid. The piece of code you see above comes in peace! Now let me answer the question of why we need to store the words we have to say in a variable. But that will be in the next post-this one is getting long! |
By the way, as I was typing this chic came around, check her out! Na fine chic O! ![]()
|
Now double click on the command button, you will be show the Command1_Click() event procedure (or the onClick Event handler for Java folks). Now allow me to show you what code you will type with explanations. . .
|
First, add the Microsoft Direct Speech Tool (The "Ear" to the form.Then add a Text box Then Add a command button Then add pepper, maggi and salt. Oops, I done it again! Ignore that last part!Now, you should have something like the picture below. . .
|
Do for dodo a hot red dodo Re some thing in front of email Mi A name of a TV presenter that died some 5 years ago Fa for Fa-fa-fa-foul! So, so what in heavens name am I doing!?! ![]() Sorry folks, slip of brain matter! Happens to the best of us. ![]() Sorry about that mis-typing , er let's get back to the main topic which was. . . *checks list* Oh, er, yes! Er-em, The above post showed how we add the Microsoft Direct Speech Tool to our VB project. Now let us see how we can make a sample application that will type when we say some thing i.e speech to text. . . |
Now press CTRL + T to bring up the Add Components Dialogue Box. Scroll till you see the Microsoft Direct Speech Recognition option and select it as shown in the image below. Select Okay when you are done. You will see an Ear in the tool bar by the left, that is the Active X Control (or according to Java folks, the Class Interface) that represents the Microsoft Direct Speech Tool that we just installed. The above shows how we add the Microsoft Direct Speech Tool to our VB project. Next we look at how to sing a song. . .
|
Your screen should look like this. . .
|
Okay, let's move on. . . Next launch VB and select a new Standard Exe project. . .
|
Writing A Project Proposal ------------------------------- When writing a project proposal the following sections should be contained in it: Introduction Statement of the Problem Aims and Objective Significance for the Study Research Methodology Scope of the Study Definition of Terms Now in the next posts, we shall take a look at each of these sections and for each section, give an example of a how to write the contents of the section using the topic: The Post Office Vacancy Notification System, as our project. Need Good Project Topics? Click Here |
You're welcome Mike! |
*Sits down on chair and looks and the dark space around him* *Notices that all is dead quite around him* *Feels one wave of QUALITY fresh air blowing on him from the window* *Eyes become heavy, sweet sleep beckons* *Goes over to the bed, lays his body down, feels the soft blanket enveloping him, nice and wooly* *Goes to sleep!* *Starts to snore* *Nepa brings light! **Hisses and covers himself with the blanket* Sorry folks-too late!Sleep wins! See ya tomorrow! ![]() |
Oh, NEPA has taken light! Damn! Sorry folks, its not my fault, its the economy's-will be back when the light is back! |
Okay, now you will first. . . |
Oh good! Thank you Bakenda! Now I know I have followers despite the fact that I do not have a twitter account! Right, let's continue. . . So as I was saying, after installing the Microsoft Direct Speech Development Tool, and you go to Program Files to look for the installed program, will you see it? No you wont! Why? Cos its a Development Tool, meant for developing applications with programming languages like VB, not for regular PC users to play with (MS recorder and Windows media player already do that!) Now I am going to show you how I will use our programming language of choice (VB6) to interact with the Microsoft Direct Speech Development Tool. . . |
Oh I get your problem now! You want the program to show the grades i think. Well it seems that your tutor has not taught you the conditional decision making structures in java yet that's why you are getting the result that you do not want! Google up "Java If statement" and study that! Then you will see where to apply the structure in your code. . . As an expo, you could look for java examples by searching for "Java score grading code sample", there you will see many ways to solve your problem. |
abatstee: |
Dear abatstee, Behold your site below
|

)
!)
Ignore that last part!
*