Page 1 of 2

Voices

PostPosted: Sun Jun 09, 2013 8:43 pm
by Antonio Linares
Listing available voices:

Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oVoice := TOleAuto():New( "Sapi.SPVoice" )
   local voice

   for each voice in oVoice:GetVoices()
      MsgInfo( voice:GetDescription )
   next  

return  nil
 

Re: Voices

PostPosted: Sun Jun 09, 2013 8:47 pm
by Antonio Linares
Earing the descriptions

Code: Select all  Expand view
// Listing voices

#include "FiveWin.ch"

function Main()

   local oVoice := TOleAuto():New( "Sapi.SPVoice" )
   local voice

   for each voice in oVoice:GetVoices()
      oVoice:Speak( voice:GetDescription )
   next  

return nil

Re: Voices

PostPosted: Sun Jun 09, 2013 10:01 pm
by Antonio Linares
SAPI.SpVoice Properties:

'.Pause = pause speaking
'.resume = resume after pause
'.Rate = speed at which voice speaks
'.Voice = you can use set and a voice value to change the voice (if multiple exist on machine)
'.Volume = volume of voice (not system volume, just voice)
'.WaitUntilDone = wait until done

Re: Voices

PostPosted: Sun Jun 09, 2013 11:50 pm
by Antonio Linares

Re: Voices

PostPosted: Mon Jun 10, 2013 7:28 am
by Antonio Linares
To make it read an external file:

Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oVoice := TOleAuto():New( "Sapi.SPVoice" )

   oVoice:Speak( "c:\texto.txt", 4 ) // 4 means it is an external file

return nil
 

Re: Voices

PostPosted: Mon Jun 10, 2013 7:39 am
by Antonio Linares
Here you have new voices for different languages that work really fine:

http://www.freedomscientific.com/downloads/RealSpeak-Solo-Direct-Voices/RealSpeak-Solo-Direct-Downloads.asp

They work fine on a Windows 8 32 bits. On a Windows 8 64 bits I have not been able to install them. If you are able to install them and use them, please share it :-)

Re: Voices

PostPosted: Mon Jun 10, 2013 7:40 am
by Antonio Linares
With this FiveWin app (full source provided) you can make your app "talk" the text of a PDF:

viewtopic.php?f=6&t=26511&p=146422#p146422

Re: Voices

PostPosted: Mon Jun 10, 2013 8:00 am
by Antonio Linares
If you want the computer to listen to what the user says, you can easily use the google voice recognition controls:

http://blogs.sitepointstatic.com/examples/tech/speech-input/index.html

html:
Code: Select all  Expand view
<input type="text" x-webkit-speech />

Re: Voices

PostPosted: Mon Jun 10, 2013 8:23 am
by Antonio Linares
Convert a text or a file into wav file:

Code: Select all  Expand view
#include "FiveWin.ch"

#define SSFMCreateForWrite 3

function Main()

   local oVoice := TOleAuto():New( "Sapi.SPVoice" )
   local oFile := TOleAuto():New( "SAPI.SpFileStream.1" )

   oFile:Open( "c:\reading.wav", SSFMCreateForWrite, .F. )
   oVoice:AudioOutputStream = oFile
   oVoice:Speak( "c:\text.txt", 4 )
   oFile:Close()
   
return nil

Re: Voices

PostPosted: Mon Jun 10, 2013 10:38 am
by Antonio Linares
In order to install new voices, you have to install the Speech SDK 51 first:

http://www.microsoft.com/en-us/download/details.aspx?id=10121

Re: Voices

PostPosted: Thu Jun 13, 2013 11:27 pm
by reinaldocrespo
Antonio;

How about dictation? I mean, recording the user's voice dictating some text and saving that to some file. Then be able to play back the recording with rewind, ff, and pauses. Any recommendations?

Thank you,


Reinaldo.

Re: Voices

PostPosted: Fri Jun 14, 2013 6:29 am
by Antonio Linares

Re: Voices

PostPosted: Fri Jun 14, 2013 1:50 pm
by TimStone
I am just starting to play with this. It could be interesting. I would suggest we create a function in our code that we pass the text to so we don't leave the control open. For example, if you use voice in the Main( ) procedure, then the resource is open no matter what you are doing until you actually close the program. If you wish to just have a greeting, this can be problematic.

Also, on some older operating systems, calling the voice will lock up the computer. I have more research to do on this, but within the function we could make sure we have a current OS that will support the call before trying to use it.

Tim

Re: Voices

PostPosted: Fri Jun 14, 2013 4:46 pm
by Antonio Linares
Tim,

The idea is that if you are going to enable your app to talk to the user, then it will do it from many different places, thats why is clever to only use a oVoice object for all the app, intead of creating it and releasing it many times. I think it may work faster (I have not compared the speeds, its just my guess)

Re: Voices

PostPosted: Fri Jun 14, 2013 4:47 pm
by Antonio Linares
Tim,

You could use TRY ... CATCH ... END to control if voice is supported on a computer