Error in programming

245 views Asked by At
Imports SpeechLib

Public Class Form1
    Public vox = CreateObject("sapi.spvoice")
    Private Sub cmdSpeak_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSpeak.Click
        Dim t As String = "Hello , This is a Text"
        Say(t)
    End Sub

    Public Sub Say(ByVal text As String)
        vox.Speak(text,SpeechVoiceSpeakFlags.SVSFlagsAsync)
    End Sub

    Private Sub cmdPause_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdPause.Click
        vox.pause()
    End Sub

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        vox.AlertBoundary = SVEPhoneme
    End Sub
End Class

I am getting an error

Name 'SVEPhoneme' is not declared.

How and where do I declare it ?

2

There are 2 answers

0
Hans Passant On BEST ANSWER

It is SpeechVoiceEvents.SVEPhoneme

This is all a lot easier if you make this code early bound:

Public vox as New SpVoice

Or better yet, use the .NET wrapper for the sapi, System.Speech assembly.

Imports System.Speech.Synthesis

Public Class Form1
    Public vox As New SpeechSynthesizer

    Public Sub Say(ByVal text As String)
        vox.SpeakAsync(text)
    End Sub
End Class
1
Nick On

SVEPhoneme represents the Phoneme event, which occurs when the engine completes a phoneme while speaking.

Try setting SVEPhoneme to be the integer 64.

http://msdn.microsoft.com/en-us/library/ms720886(v=vs.85).asp