Solved

How to cancel/abort Text to Speech

Posted on 2013-10-25
10
542 Views
Last Modified: 2013-11-27
When executing the code sometimes with long text I need to cancel the text to speech. How can I make this happen. I have included what I have so far.
Dim objVo As Object
Dim SpeakUpdate As String
Dim strPhrase As String
Dim intPitch As Integer

SpeakUpdate = Me.caseupdate
intPitch = 2

Set objVo = CreateObject("SAPI.SpVoice")
objVo.Speak "<pitch middle = '" & intPitch & "'/>" + SpeakUpdate

Open in new window

0
Comment
Question by:seanlhall
  • 5
  • 3
10 Comments
 
LVL 15

Expert Comment

by:unknown_routine
ID: 39600390
objVo.Speak "", SVSFPurgeBeforeSpeak
0
 

Author Comment

by:seanlhall
ID: 39600446
That looks like what I am looking for.  I am not sure what to do with it though.
0
 

Author Comment

by:seanlhall
ID: 39600998
When the speech is going I can not click on anything until it is done.
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 40

Expert Comment

by:Vadim Rapp
ID: 39607455
Initiate method "speak" with asynchronous flag (SVSFlagsAsync); to interrupt, call Pause method.
0
 

Author Comment

by:seanlhall
ID: 39608416
When it starts to speak, I am unable to click anything until it is done. How would I call Pause?
0
 
LVL 40

Expert Comment

by:Vadim Rapp
ID: 39608440
Do you call it with SVSFlagsAsync ?
0
 

Author Comment

by:seanlhall
ID: 39608539
Here is what I have now. When it starts talking I can not click anything until it is done talking.

Private Sub Talk_Click()
Dim objVo As Object
Dim SpeakUpdate As String
Dim strPhrase As String
Dim intPitch As Integer

SpeakUpdate = Me.caseupdate
intPitch = 2

Set objVo = CreateObject("SAPI.SpVoice")
objVo.Speak "<pitch middle = '" & intPitch & "'/>" + SpeakUpdate, SVSFlagsAsync

End Sub

Private Sub Stop_Click()
objVo.Speak "", SVSFPurgeBeforeSpeak
End Sub

Open in new window

0
 
LVL 40

Accepted Solution

by:
Vadim Rapp earned 500 total points
ID: 39608704
Unless you have added the reference to the voice library to the project, you have to define SVSFlagsAsync. Also, if you use objVo from another sub, it has to be declared on module level. We have verified that the following code works as you want, i.e. you can click the button "stop" during the playback, and that stops it.

Dim objVo As Object

Private Sub Talk_Click()
    Set objVo = CreateObject("SAPI.SpVoice")
    Const SVSFlagsAsync As Integer = 1
    objVo.Speak "some long text", SVSFlagsAsync
End Sub

Private Sub Stop_Click()
    objVo.Pause
End Sub

Open in new window

0
 

Author Closing Comment

by:seanlhall
ID: 39608762
Thanks I understand now.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question