Creating a DLL

  • (2 Pages)
  • +
  • 1
  • 2

28 Replies - 1065 Views - Last Post: 01 December 2018 - 08:55 AM Rate Topic: -----

#1 PiratePete   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 03-February 16

Creating a DLL

Posted 27 November 2018 - 12:53 PM

Hi,
I "constructed" a DLL as in the article (in DIC) "Making your computer talk" which worked!
When I tried to use the DLL in another program it wouldn't accept the "Imports TestDLLs"

Imports SpeechLib
Public Class TestDLLs
 Private Sub btnDoIt_Click() Handles btnDoIt.Click
  Dim Talk as string = InputBox.text 
  TextSpeak(Talk)
 End Sub

 Public Sub TextSpeak(Chat as string)
  Dim ad as new SPVoice
  ad.Speak(Chat)
 End Sub
End Class



The form has a button and a TextBox.
So, am I wrong in inserting Imports TestDLLs at the top
of the program who require the use of this DLL?
The Sub btnDoIt is just a convenience for debugging!

Is This A Good Question/Topic? 0
  • +

Replies To: Creating a DLL

#2 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14581
  • View blog
  • Posts: 58,445
  • Joined: 12-June 08

Re: Creating a DLL

Posted 27 November 2018 - 01:08 PM

Did you add a reference to the DLL in your project?
Was This Post Helpful? 1
  • +
  • -

#3 Sheepings   User is offline

  • Senior Programmer
  • member icon

Reputation: 155
  • View blog
  • Posts: 972
  • Joined: 05-December 13

Re: Creating a DLL

Posted 27 November 2018 - 02:30 PM

Imports MyNamespace only allows you to avail of type names such as classes instead of qualifying the namespace as well as the code of the class, methods also.

If you have an app with the name :: TestVBApp, NameSpace :: foo
Imports TestVBApp.foo
Namespace foo
    Public Class bar
        Public Shared Sub method()
            'stuff
        End Sub

    End Class
End Namespace

This allows us to shorten the qualifying name of the namespace in our other classes. Like so. Imagine TestVBApp.foo is your DLL.
Public Class Form1
    Sub callme()
        bar.method()
    End Sub
End Class
Thus allowing us to call bar class directly from our other class. So in your case, calling your DLL :: SpeechLib directly will still allow you to reference members of the DLL providing you added a reference to your project for the DLL?

To add a reference, on your project, you will see References, right click it and click add reference, browse to the path of your DLL, and it will be ready to go. Like so ::

Attached Image

If you don't add a reference, you will likely end up with red squiggles underneath where you are trying to reference said DLL ::

Attached Image

Microsoft has an article on Imports, explaining it in detail, found here. You mentioned an article you learned how to construct the DLL from, can you provide a link to that article. It will help, as we might be able to identify possible mistakes. Also, keep in mind, if you don't reference the DLL as I screenshotted, you won't be able to use imports for that DLL.

Hope this helps. Lets know if you get it working
Was This Post Helpful? 1
  • +
  • -

#4 PiratePete   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 03-February 16

Re: Creating a DLL

Posted 27 November 2018 - 03:10 PM

View PostSheepings, on 27 November 2018 - 02:30 PM, said:

Imports MyNamespace only allows you to avail of type names such as classes instead of qualifying the namespace as well as the code of the class, methods also.

If you have an app with the name :: TestVBApp, NameSpace :: foo
Imports TestVBApp.foo
Namespace foo
    Public Class bar
        Public Shared Sub method()
            'stuff
        End Sub

    End Class
End Namespace

This allows us to shorten the qualifying name of the namespace in our other classes. Like so. Imagine TestVBApp.foo is your DLL.
Public Class Form1
    Sub callme()
        bar.method()
    End Sub
End Class
Thus allowing us to call bar class directly from our other class. So in your case, calling your DLL :: SpeechLib directly will still allow you to reference members of the DLL providing you added a reference to your project for the DLL?

To add a reference, on your project, you will see References, right click it and click add reference, browse to the path of your DLL, and it will be ready to go. Like so ::

Screenshot_33.png

If you don't add a reference, you will likely end up with red squiggles underneath where you are trying to reference said DLL ::

Screenshot_77.png

Microsoft has an article on Imports, explaining it in detail, found here. You mentioned an article you learned how to construct the DLL from, can you provide a link to that article. It will help, as we might be able to identify possible mistakes. Also, keep in mind, if you don't reference the DLL as I screenshotted, you won't be able to use imports for that DLL.

Hope this helps. Lets know if you get it working

Was This Post Helpful? 0
  • +
  • -

#5 PiratePete   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 03-February 16

Re: Creating a DLL

Posted 27 November 2018 - 03:22 PM

Hi,
Thanks for your reply.
I must admit that I'm totally confused!!
I'm 83 and my brain has lost it's sharpness (It did have once!)

When I selected Microsoft Speech ... there were 2 entries in the list
with the same name.

Could you please show me what I need to change in the code above?
I'm not even sure if the sub is a DLL file or just a "program"!
All I want to do is add some of my Maths Subs/Functions to the library.
Was This Post Helpful? 0
  • +
  • -

#6 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14581
  • View blog
  • Posts: 58,445
  • Joined: 12-June 08

Re: Creating a DLL

Posted 27 November 2018 - 03:38 PM

DLL is more of a project type.

MS outlines it here:
https://docs.microso...h-visual-studio
Was This Post Helpful? 1
  • +
  • -

#7 Sheepings   User is offline

  • Senior Programmer
  • member icon

Reputation: 155
  • View blog
  • Posts: 972
  • Joined: 05-December 13

Re: Creating a DLL

Posted 27 November 2018 - 03:51 PM

In the tutorial, it should work as you have it. Your code looks as described in the topic.

Did you add the reference to your project for the speech dll as I outlined above?
Was This Post Helpful? 1
  • +
  • -

#8 Sheepings   User is offline

  • Senior Programmer
  • member icon

Reputation: 155
  • View blog
  • Posts: 972
  • Joined: 05-December 13

Re: Creating a DLL

Posted 27 November 2018 - 04:09 PM

I think I know why you are confused. But don't worry, I'm half your age and equally confused. lol I assumed you were adding a reference to the DLL you downloaded? In which case, you would right click on references / add / browse / select the dll / and then type imports SpeechLib in your code file of you form.

But the instructions says to select the DLL from the com objects. Like so ::

Attached Image

They are different DLL's, see when i hover over them?

Attached Image

The one you need to download is the first screenshot, which is the second item in the list.

Works fine here for me. I can access the library after adding the correct reference.

Attached Image

Hope it helps

This post has been edited by Sheepings: 27 November 2018 - 04:09 PM

Was This Post Helpful? 2
  • +
  • -

#9 IronRazer   User is offline

  • Custom Control Freak
  • member icon

Reputation: 1526
  • View blog
  • Posts: 3,850
  • Joined: 01-February 13

Re: Creating a DLL

Posted 27 November 2018 - 04:10 PM

I am not absolutely positive but, I believe that if you have windows 7 or above, a newer version of the speech sdk will already be included and does not need to be installed. For example, I have windows 7 and I have the 5.4 version on mine.

You can open your project in Visual Studio and on the main menu go to (Project -> Add Reference...). That will open the Reference Manager window. You can select the COM tab in the reference manager window and find (Microsoft Speech Object Library) as shown in the image below. Check the checkbox next to it and then click the OK button to add the reference.

Attached Image

Now you can add the import at the top of your code to import the SpeechLib namespace...
Imports SpeechLib

Public Class Form1

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim ad As New SpVoice
        ad.Speak("Hello, this is your computer talking to you.")
    End Sub

End Class


Was This Post Helpful? 2
  • +
  • -

#10 Sheepings   User is offline

  • Senior Programmer
  • member icon

Reputation: 155
  • View blog
  • Posts: 972
  • Joined: 05-December 13

Re: Creating a DLL

Posted 27 November 2018 - 04:14 PM

Guess he's running windows ten Iron, same as me. I've had two options for two separate DLL.

Sapi.dll is the one OP needs, as this one done the trick for me. :)
Was This Post Helpful? 1
  • +
  • -

#11 IronRazer   User is offline

  • Custom Control Freak
  • member icon

Reputation: 1526
  • View blog
  • Posts: 3,850
  • Joined: 01-February 13

Re: Creating a DLL

Posted 27 November 2018 - 04:30 PM

@ Sheepings,

Just curios, do you have System.Speech in the Assemblies tab on windows 10. That is another way to "Make your computer talk". For example...
'Add reference to System.Speech in the Assemblies tab of the Reference Manager
Imports System.Speech.Synthesis

Public Class Form1

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Using synth As New SpeechSynthesizer()
            synth.Speak("This is your computer talking to you.")
        End Using
    End Sub

End Class


Was This Post Helpful? 2
  • +
  • -

#12 Sheepings   User is offline

  • Senior Programmer
  • member icon

Reputation: 155
  • View blog
  • Posts: 972
  • Joined: 05-December 13

Re: Creating a DLL

Posted 27 November 2018 - 05:07 PM

I do yes. Actually @IronRazer, I've been working on a sophisticated AI application in C# for the last few years, and its has the ability to have a full blown conversation with me at this stage. lol

In C#, you can see using is used instead of imports

Attached Image

The Speech.synthesis is great, and once you familiarize yourself with the ins and outs of it, and learn the guts of how it works, learns grammar, and so on, you can make AI algorithms to be quite engaging when you teach it how to learn and create its own rules.

Attached Image

What I'm doing kinda reminds me of that owl monkey called Bonzi buddy, sadly he became full of malware in the end. Have you done much in the way of AI programming or Voice recognition/System speech?
Was This Post Helpful? 2
  • +
  • -

#13 IronRazer   User is offline

  • Custom Control Freak
  • member icon

Reputation: 1526
  • View blog
  • Posts: 3,850
  • Joined: 01-February 13

Re: Creating a DLL

Posted 27 November 2018 - 06:02 PM

I dabbled with the speech and speech recognition stuff enough to know how to do what I needed/wanted at the time. Not putting it down or anything like that but, I just never really got into the whole ai thing. 8)
Was This Post Helpful? 2
  • +
  • -

#14 Sheepings   User is offline

  • Senior Programmer
  • member icon

Reputation: 155
  • View blog
  • Posts: 972
  • Joined: 05-December 13

Re: Creating a DLL

Posted 27 November 2018 - 08:55 PM

What I found really fascinating, is how something that began with no knowledge-base could learn simple interactions and based on those interactions, it would learn what a question was and how to ask questions, based on a set of rules, rules in-which it would develop itself completely independently and with relevance to what i say.

Initially I got the idea from the SpeechRecognizedEventArgs e.Result.Confidence; to create some simple pattern expressions based on the same logic that's used to examine the authenticity of word phrases and if they match the spoken word.

I will email you a video of it over the next few weeks to show you how advanced I managed to make it, as I'm clode to finishing it. None the less, as I'm rambling on about it, you can see I've developed a keen interest in pure pattern logic. In fact, writing this application some 3, 4 years ago, has helped me a great deal to write more logical code in general. Sure is a fun project to play with though, even more fun when you get into the SDK :)

        private void SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            float vConfidence = e.Result.Confidence;
            Console.WriteLine("\nRecognized :: " + recTxt); if (vConfidence < 0.75) return;
            nQuestion.DetermineSpoken(recTxt);
        }

Oh, woops look at the time, another late night. Off to bed now, chat you later @IronRazer ;)
Was This Post Helpful? 1
  • +
  • -

#15 PiratePete   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 03-February 16

Re: Creating a DLL

Posted 28 November 2018 - 09:32 AM

View PostSheepings, on 27 November 2018 - 02:30 PM, said:

Imports MyNamespace only allows you to avail of type names such as classes instead of qualifying the namespace as well as the code of the class, methods also.

If you have an app with the name :: TestVBApp, NameSpace :: foo
Imports TestVBApp.foo
Namespace foo
    Public Class bar
        Public Shared Sub method()
            'stuff
        End Sub

    End Class
End Namespace

This allows us to shorten the qualifying name of the namespace in our other classes. Like so. Imagine TestVBApp.foo is your DLL.
Public Class Form1
    Sub callme()
        bar.method()
    End Sub
End Class
Thus allowing us to call bar class directly from our other class. So in your case, calling your DLL :: SpeechLib directly will still allow you to reference members of the DLL providing you added a reference to your project for the DLL?

To add a reference, on your project, you will see References, right click it and click add reference, browse to the path of your DLL, and it will be ready to go. Like so ::

Screenshot_33.png

If you don't add a reference, you will likely end up with red squiggles underneath where you are trying to reference said DLL ::

Screenshot_77.png

Microsoft has an article on Imports, explaining it in detail, found here. You mentioned an article you learned how to construct the DLL from, can you provide a link to that article. It will help, as we might be able to identify possible mistakes. Also, keep in mind, if you don't reference the DLL as I screenshotted, you won't be able to use imports for that DLL.

Hope this helps. Lets know if you get it working

Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2