Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to cancel/abort Text to Speech

Posted on 2013-10-25
10
Medium Priority
?
574 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
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 2000 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

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.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Six Sigma Control Plans

721 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