Results 1 to 4 of 4

Thread: [RESOLVED] Help with a Speech Object

  1. #1

    Thread Starter
    Lively Member Brian M.'s Avatar
    Join Date
    Nov 2006
    Location
    Moberly MO
    Posts
    94

    Resolved [RESOLVED] Help with a Speech Object

    Below is some Just Basic Compiler code that will pass a string to a vb object and create speech. I've used it with Vista and it still works. Could someone help me write a reusable speech class or module for 2008 express version that will accept strings and return speech? I am sure there is someway to convert this code to a vb class or module, but I am still new to classes and objects, but this will be a good way to start my class library. Then I could just add a reference to a project and have talking programs. I've tried using the speech sdk, but it won't work right with vista. But running this .vbs through the JB compiler works fine with Vista. There is a system.voice reference in the vb ui, but I can't find any info on it in the compiler index. Any help would be appreciated.

    Code:
    nomainwin
    
    open "speak.vbs" for output as #1
    print #1, "Set MyVoice = CreateObject("; chr$(34); "Sapi.SpVoice"; chr$(34); ")"
    print #1, "Set fso = CreateObject("; chr$(34); "Scripting.FileSystemObject"; chr$(34); ")"
    print #1, "Set f = fso.OpenTextFile(WScript.Arguments.Item(0),1,true)"
    print #1, "Do While f.AtEndOfStream <> True"
    print #1, "MyVoice.Speak f.ReadLine"
    print #1, "Loop"
    print #1, "f.close"
    close #1
    
    open "speak.txt" for output as #2
    print #2, "The cow jumped over the moon."
    print #2, "Hello, World. I'm a speech object."
    close #2
    
    a$ = "speak.txt"
    b$ = "cscript.exe speak.vbs "; a$
    
    run b$, hide
    Last edited by Brian M.; Jul 17th, 2008 at 11:48 AM.

  2. #2

    Thread Starter
    Lively Member Brian M.'s Avatar
    Join Date
    Nov 2006
    Location
    Moberly MO
    Posts
    94

    Re: Help with a Speech Class

    Ah you know what. I found what I needed.

    Make a new project then:
    project tab--->add reference--->com tab--->Microsoft Speech Object Library

    To use the voice object is simple now.
    Code:
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim voice As New SpeechLib.SpVoice
            voice.Speak("Hello World. Speech with visual basic is easy as pi.")
        End Sub
    Thanks, anyway. Enjoy your speech object.

  3. #3
    Fanatic Member Clanguage's Avatar
    Join Date
    Jan 2008
    Location
    North Carolina
    Posts
    659

    Re: [RESOLVED] Help with a Speech Object

    It sounds like the MS Agent but instead of Voice it uses Merlin or Peedee.
    vb Code:
    1. Merlin.Speak("Hello world")
    I wonder if it is the same speech code.
    CLanguage;
    IF Post = HelpFull Then
    RateMe
    Else
    Say("Shut UP")
    End If
    DotNet rocks
    VB 6, VB.Net 2003, 2005, 2008, 2010, SQL 2005, WM 5.0,ahem ?OpenRoad?

  4. #4

    Thread Starter
    Lively Member Brian M.'s Avatar
    Join Date
    Nov 2006
    Location
    Moberly MO
    Posts
    94

    Re: [RESOLVED] Help with a Speech Object

    I think you need another reference to use those agents in a program. But I haven't found that one yet.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width