Playing a sequence of WAV files

R

robotman

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
 
R

robotman

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
 
G

Guest

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)
 
R

robotman

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
 
T

Tom Ogilvy

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top