Hello there everybody, We have always supported QBASIC programming language and done most amusing things to take it to the next level. If you are the newbie to this language then please read this article: An Introduction To QBASIC Programming Language. . So far we have already known that QBASIC is one of the popular programming language but is one of the least used real world programming language. It is one of the easiest programming language and we can program only application level programs here. This is the programming language to start if you are the newbie to the programming world because the keywords are easy and the syntax is also not difficult to understand.
This programming language is so simple that you can never think of building some of the fabulous programs using it and here we are talking about the text to speech converter which seems so unbelievable, doesn't it? But the fact is that I've already created a Text To speech converter using Qbasic. You can download that program here: Text2Speech. (Just click on the link and you are done). Actually, we have used two programming language in this program. We have coded in QBASIC but actually programmed a VisualBasic program. You can find the code below:
This program is made up of just 15 lines but the out put of this code is pity amazing, isn't it? Before the explanation, I am assuming that you are quite familiar to the QBASIC programming language but doesn't matter weather you are familiar to VisualBasic or not. If you are not quite familiar to this programming language then you will find some difficulties in understanding this program. So, Let us start the line by line explanation of this code.
In the first line, we are just initializing the DO....LOOP which doesn't has any end by itself so we can say that this is a infinite loop. This helps in execution of the program several times. This program ever ends because of the do..loop.
This line is just so simple, there is only one keyword 'CLS' you know this helps in clearing the screen. If this wasn't placed then, we could find the history of the typed words and the same lines of text would be printed after every time of execution.
These lines uses same statement that is PRINT. And I've used to credit my company. The only statements with no strings after it are just used for blank lines.
In seventh line, there is the input and the data is saved in the string "speak$"
Here the main work starts. There is the use of OPEN statement with the supporting keyword OUTPUT and the file number is given as #1. The file named 'sound' is created with the extention '.vbs'. The '.vbs' extension refers to the VisualBasic file and which is the main program to be run. The output mode is used in creating a file and adding data to it.
In these lines, We can find the use of several keywords, all with the starting keyword 'PRINT #1'. This keyword is used to add the certain data in the file created in line 8. In the tenth line, we can find the use of CHR$() function. Actually, it is one of the Library function in QBASIC programming language that converts ASCII code into the string character. There is the use of this function as we cannot directly print the double-cot in QBASIC as it's character code is 34, CHR$(34) is used where we need the double-cot. Similarly, in the eleventh line, we are using the string variable "speak$" which was created in Line 7. This variable consists of the value that is to be sent to the visual basic program and is spoken by the computer.
In this line, there is the use of CLOSE # statement. CLOSE #1 is written because the file number is 1. This is closed because the file must be closed once it is opened. Here we could have used just CLOSE statement but the CLOSE #1 becomes more specific.
The SHELL statement is used in this line. What actually the shell statement does is that it links the program with the command prompt and we can also execute the command prompt. The only use of SHELL could have opened the console window but adding the string after that executes the command automatically. The use of the file name opens that file name in the command prompt console window and the same happens in the program. The visual basic program we'd created in line 8, 9, 10, 11, and 12.
The KILL statement by the name, we can guess it's work. It is used for deleting an existing file. And we've deleted the file that was created because it hasn't any use afterwards.
This is the end of the loop and the program as well.
We've used a simple logic and programmed a text to speech program using the beginner's and simple language. If you have any suggestion for this program then please give us feedback and help us improve our articles and programs as well.
This programming language is so simple that you can never think of building some of the fabulous programs using it and here we are talking about the text to speech converter which seems so unbelievable, doesn't it? But the fact is that I've already created a Text To speech converter using Qbasic. You can download that program here: Text2Speech. (Just click on the link and you are done). Actually, we have used two programming language in this program. We have coded in QBASIC but actually programmed a VisualBasic program. You can find the code below:
This program is made up of just 15 lines but the out put of this code is pity amazing, isn't it? Before the explanation, I am assuming that you are quite familiar to the QBASIC programming language but doesn't matter weather you are familiar to VisualBasic or not. If you are not quite familiar to this programming language then you will find some difficulties in understanding this program. So, Let us start the line by line explanation of this code.
Line 1:
In the first line, we are just initializing the DO....LOOP which doesn't has any end by itself so we can say that this is a infinite loop. This helps in execution of the program several times. This program ever ends because of the do..loop.
line 2:
This line is just so simple, there is only one keyword 'CLS' you know this helps in clearing the screen. If this wasn't placed then, we could find the history of the typed words and the same lines of text would be printed after every time of execution.
Line 3, 4, 5, 6:
These lines uses same statement that is PRINT. And I've used to credit my company. The only statements with no strings after it are just used for blank lines.
Line 7:
In seventh line, there is the input and the data is saved in the string "speak$"
Line 8:
Here the main work starts. There is the use of OPEN statement with the supporting keyword OUTPUT and the file number is given as #1. The file named 'sound' is created with the extention '.vbs'. The '.vbs' extension refers to the VisualBasic file and which is the main program to be run. The output mode is used in creating a file and adding data to it.
Line 9, 10, 11:
In these lines, We can find the use of several keywords, all with the starting keyword 'PRINT #1'. This keyword is used to add the certain data in the file created in line 8. In the tenth line, we can find the use of CHR$() function. Actually, it is one of the Library function in QBASIC programming language that converts ASCII code into the string character. There is the use of this function as we cannot directly print the double-cot in QBASIC as it's character code is 34, CHR$(34) is used where we need the double-cot. Similarly, in the eleventh line, we are using the string variable "speak$" which was created in Line 7. This variable consists of the value that is to be sent to the visual basic program and is spoken by the computer.
Line 12:
In this line, there is the use of CLOSE # statement. CLOSE #1 is written because the file number is 1. This is closed because the file must be closed once it is opened. Here we could have used just CLOSE statement but the CLOSE #1 becomes more specific.
Line 13:
The SHELL statement is used in this line. What actually the shell statement does is that it links the program with the command prompt and we can also execute the command prompt. The only use of SHELL could have opened the console window but adding the string after that executes the command automatically. The use of the file name opens that file name in the command prompt console window and the same happens in the program. The visual basic program we'd created in line 8, 9, 10, 11, and 12.
Line 14:
The KILL statement by the name, we can guess it's work. It is used for deleting an existing file. And we've deleted the file that was created because it hasn't any use afterwards.
Line 15:
This is the end of the loop and the program as well.
We've used a simple logic and programmed a text to speech program using the beginner's and simple language. If you have any suggestion for this program then please give us feedback and help us improve our articles and programs as well.
Comments