ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Playing a sequence of WAV files (https://www.excelbanter.com/excel-programming/390167-playing-sequence-wav-files.html)

robotman

Playing a sequence of WAV files
 
I'm creating a text-to-speach algorhythm in Excel which strings
together WAV files to form sentences. The concept works great, but I'm
needing to insert a delay between every word to let the system finish
saying the word before moving to the next one.

Using the code at the bottom of this post (plus a WAIT subroutine), I
need to do something like this:

PlaySound "this"
wait 0.5
PlaySound "is"
wait 0.3
PlaySound "a"
wait 0.3
PlaySound "test"
wait 0.5

** Is there any way to make the system wait until it is done playing a
WAV file before playing the next one so I don't need to figure out and
specify all the delays?

** What does "Alias" mean in the declaration?
** Can someone explain the parameters in "PlaySoundA" (i.e. lpszName,
hModule, dwFlags)?

Thanks!

John


___

Public Declare Function PlayWav Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As Long, ByVal dwFlags As Long) As Long
Public Const SND_ASYNC = &H1
Public Const SND_FILENAME = &H20000

___

Public Sub PlaySound(Optional SoundName As String =
"confirm_blip.wav")

On Error GoTo Skip_Sound

#If Win32 Then
Call PlayWav(ThisWorkbook.Path & "\SM Sounds\" & SoundName, 0&,
SND_FILENAME Or SND_ASYNC)
#End If
' Only can play sounds on PC

Skip_Sound:

End Sub


Ben McBen

Playing a sequence of WAV files
 
Do you not like the built in appliocation.speech stuff?

A very goo reference for Win32 calls in general is here (explains all about
the parameters etc:

http://www.awprofessional.com/articl...?p=366892&rl=1

"robotman" wrote:

I'm creating a text-to-speach algorhythm in Excel which strings
together WAV files to form sentences. The concept works great, but I'm
needing to insert a delay between every word to let the system finish
saying the word before moving to the next one.

Using the code at the bottom of this post (plus a WAIT subroutine), I
need to do something like this:

PlaySound "this"
wait 0.5
PlaySound "is"
wait 0.3
PlaySound "a"
wait 0.3
PlaySound "test"
wait 0.5

** Is there any way to make the system wait until it is done playing a
WAV file before playing the next one so I don't need to figure out and
specify all the delays?

** What does "Alias" mean in the declaration?
** Can someone explain the parameters in "PlaySoundA" (i.e. lpszName,
hModule, dwFlags)?

Thanks!

John


___

Public Declare Function PlayWav Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As Long, ByVal dwFlags As Long) As Long
Public Const SND_ASYNC = &H1
Public Const SND_FILENAME = &H20000

___

Public Sub PlaySound(Optional SoundName As String =
"confirm_blip.wav")

On Error GoTo Skip_Sound

#If Win32 Then
Call PlayWav(ThisWorkbook.Path & "\SM Sounds\" & SoundName, 0&,
SND_FILENAME Or SND_ASYNC)
#End If
' Only can play sounds on PC

Skip_Sound:

End Sub



robotman

Playing a sequence of WAV files
 
What built-in application.speech stuff are you referring to?

I'm a newbie with API calls (don't even know what they are)... I used
the code that Chip Pearson has posted in many other threads.

The website is much more than I'm looking for and I couldn't even find
a specific reference to WAV file playing.

1. Can you point me to exactly where the WAV playing functions are
discussed in the website?
2. Explain how I could change the parameters to play WAVs
sequentially?

Thanks.

John



Ben McBen

Playing a sequence of WAV files
 
What built-in application.speech stuff are you referring to?

There are built in speach synthisis function in excel. In your macro try:

Application.Speech.Speak "hello dave, I'm afriad I cant do that"




I'm a newbie with API calls (don't even know what they are)... I used
the code that Chip Pearson has posted in many other threads.

The website is much more than I'm looking for and I couldn't even find
a specific reference to WAV file playing.


What you are using (PlaySound) is an API call, there are a lot of them...



1. Can you point me to exactly where the WAV playing functions are
discussed in the website?


Try googling for "wav vba" (Chips site come pretty close to the top)

2. Explain how I could change the parameters to play WAVs
sequentially?


Sorry - I dont have specific expertise with playing wavs, I was just trying
to point out some resources to you (but I reckon application.speech is much
easier, if a little, OK, a lot synthetic sounding)


Thanks.

John




Tom Ogilvy

Playing a sequence of WAV files
 
Using the built in speech capabilities is certainly the way to do speech.

this article gives explains how to use the argument to tell the API to
operate synchronously.

http://support.microsoft.com/default...kb;en-us;86281
HOWTO: Play a Waveform (.WAV) Sound File in Visual Basic
[Contains the Constants for the Arguments]

--
Regards,
Tom Ogilvy


"robotman" wrote:

What built-in application.speech stuff are you referring to?

I'm a newbie with API calls (don't even know what they are)... I used
the code that Chip Pearson has posted in many other threads.

The website is much more than I'm looking for and I couldn't even find
a specific reference to WAV file playing.

1. Can you point me to exactly where the WAV playing functions are
discussed in the website?
2. Explain how I could change the parameters to play WAVs
sequentially?

Thanks.

John




robotman

Playing a sequence of WAV files
 
I never new about the built-in TTS. Cool!

I still need to go the .WAV file route because I need clearly spoken
words to instruct people in a noisy environment.

Thanks for the MS link, I set the variable for synchronous play and
that solved my problem. Phew... I wasn't looking forward to timing
500 files!


- Is there any way to do TTS or play .WAV files on a Mac? This macro
is going to be cross-platform, but I've told people they can't have
speech on the Mac side.


John


Tom Ogilvy

Playing a sequence of WAV files
 
I am sure there is, but it wouldn't utilize the "Windows" API. Probably
something with Applescript. Perhaps ask in a mac group related to Office.

--
Regards,
Tom Ogilvy


"robotman" wrote in message
oups.com...
I never new about the built-in TTS. Cool!

I still need to go the .WAV file route because I need clearly spoken
words to instruct people in a noisy environment.

Thanks for the MS link, I set the variable for synchronous play and
that solved my problem. Phew... I wasn't looking forward to timing
500 files!


- Is there any way to do TTS or play .WAV files on a Mac? This macro
is going to be cross-platform, but I've told people they can't have
speech on the Mac side.


John





All times are GMT +1. The time now is 05:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com