SpVoice Interface (SAPI 5.3)

HMG en Español

Moderator: Rathinagiri

User avatar
danielmaximiliano
Posts: 2612
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Contact:

SpVoice Interface (SAPI 5.3)

Post by danielmaximiliano »

Hola a todos :
con la publicación de Louis con su aplicación "Bingo" usa el objeto "SAPI.SpVoice" al cual podemos modificar el Volumen pero todavia no podemos cambiar el Narrador ("Voice") a pesar que intento de diferente maneras todavia no logre hacerlo..
la descripción es clara en https://learn.microsoft.com/en-us/previ ... dfrom=MSDN donde el ejemplo del metodo GetVoices() https://learn.microsoft.com/en-us/previ ... 1(v=vs.85) nos dice
The GetVoices method returns a selection of voices available to the voice.

Selection criteria may be applied optionally. In the absence of selection criteria, all voices are returned in the selection, ordered alphabetically by the voice name. If no voices match the criteria, GetVoices returns an empty selection, that is, an ISpeechObjectTokens collection with a Count of zero.
Puedo recuperar todas la voces ("Narradores") y sus Items ("Criteria"), toda esa informacion la guardo en un Grid, el ejemplo de microsoft dice que hay que tener un ListBox
creates a voice object and displays the names of all available voices in the list box. Select a voice name in the list box and then click Command1. The Command1 procedure sets the voice object's Voice property to the selected name and causes the voice to speak its new name.

Code: Select all

If List1.ListIndex > -1 Then

        ' Set voice object to voice name selected in
        ' list box (new voice speaks its own name):
        Set V.Voice = V.GetVoices().Item(List1.ListIndex)
        V.Speak V.Voice.GetDescription
    Else
        MsgBox "Please select a voice from the list box."
    End If
este ListBox guarda la descripción del narrador ("Voice") .. hasta ahi llegue según mi comprención pero no puedo encontrar el error ya que todos los ejemplos en diferentes lenguajes son similares (pascal, lazarus, vfp, vbs)
dejo el codigo para resolver este inconveniente
SapiVoice.rar
(10.22 KiB) Downloaded 44 times
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
User avatar
LOUIS
Posts: 210
Joined: Tue Dec 11, 2012 9:05 pm
DBs Used: DBF

Re: SpVoice Interface (SAPI 5.3)

Post by LOUIS »

Hola Daniel

No sé si ayude esto, pero así lo hago en VFP9 ...

Saludos.

Code: Select all

CLEA
***PRUEBAS DE VOZ Y SABER CUANTAS VOCES HAY EN LA COMPU

LOCAL oVoz AS "SAPI.SpVoice"
oVoz = CREATEOBJECT("SAPI.SpVoice")

FOR ln = 0 TO oVoz.GetVoices().COUNT - 1

  ? oVoz.GetVoices().ITEM(ln).GetDescription
  ? oVoz.GetVoices().ITEM(ln).ID

  oVoz.Voice = oVoz.GetVoices().ITEM(ln)

  oVoz.Speak(75)

ENDFOR

RETURN
Cuando ya identifico cuál voz quiero usar, le pongo el número 0 -1 - 2 - 3 etc ... claro que yo lo hago manualmente :oops:

Code: Select all

XMENSAJE = m4
oVoz = Createobject("SAPI.SPVoice")
ln=0
**ln=3		<--- PARA MI LAPTOP
oVoz.Voice = oVoz.GetVoices().ITEM(ln)
oVoz.volume = 100			&& VOLUMEN
oVoz.Speak(XMENSAJE)
RELEASE oVoz
User avatar
danielmaximiliano
Posts: 2612
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Contact:

Re: SpVoice Interface (SAPI 5.3)

Post by danielmaximiliano »

Hola Louis :

Code: Select all

XMENSAJE = m4
oVoz = Createobject("SAPI.SPVoice")
ln=0
**ln=3		<--- PARA MI LAPTOP
oVoz.Voice = oVoz.GetVoices().ITEM(ln)
oVoz.volume = 100			&& VOLUMEN
oVoz.Speak(XMENSAJE)
RELEASE oVoz
en VFP el codigo funciona en HMG/Harbour no!! hay una falla dentro de devolucion del objeto

Code: Select all

            oVoices:volume := Main.Volumen.value
			msgdebug ( Main.List1.value ,;
                       oVoices:GetVoices():Item(Main.List1.value)	
			oVoices:Voice  := oVoices:GetVoices():Item(Main.List1.value)  /*nO FUNCIONA"/
	        oVoices:Voice  := oVoices:GetVoices():Item(2)                 /*nO FUNCIONA"/
			oVoices:Speak ( cDescription , .F. )
Captura de pantalla 2024-01-17 180823.png
Captura de pantalla 2024-01-17 180823.png (33.21 KiB) Viewed 1123 times
SapiVoice.rar
(1.6 KiB) Downloaded 45 times
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
User avatar
danielmaximiliano
Posts: 2612
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Contact:

Re: SpVoice Interface (SAPI 5.3)

Post by danielmaximiliano »

hola a todos:
sigo con el mismo problema y no puedo cambiar la voz del narrador , mire muchos ejemplos e, vba, vfp, pascal, delphi y todos el ejemplo muy parecido.

Code: Select all

oNarrator             := CreateObject( "Sapi.SPVoice", "WithEvents" )  //'voice object
SpObjectTokenCategory := CreateObject( "SAPI.SpObjectTokenCategory")   //'a category of object tokens
//ISpeechObjectTokens := CreateObject( "SAPI.ISpeechObjectTokens")     //'an enumeration of object tokens  //No funciona//
SpObjectToken         := CreateObject( "SAPI.SpObjectToken")           //object token
$CLSID_SpeechLib_SpVoice = Guid$("{96749377-3391-11D2-9EE3-00C04F797396}")
$CLSID_SpeechLib_SpObjectTokenCategory = Guid$("{A910187F-0C7A-45AC-92CC-59EDAFB77B53}")
$CLSID_SpeechLib_SpObjectToken = Guid$("{EF411752-3736-4CB4-9C8C-8EF4CCB58EFE}")
estas variables puede ser creadas como objeto para pode manipularlas y buscando con REGEDIT en el registro de windows existen en mi pc.
Captura de pantalla 2024-01-20 103338.png
Captura de pantalla 2024-01-20 103338.png (19.06 KiB) Viewed 952 times
Captura de pantalla 2024-01-20 103251.png
Captura de pantalla 2024-01-20 103251.png (18.92 KiB) Viewed 952 times
Captura de pantalla 2024-01-20 103209.png
Captura de pantalla 2024-01-20 103209.png (21.84 KiB) Viewed 952 times
sin embargo sl buscar el el registro de windows la existencia de no aparece (aclaro busco la cadena numerica dentro de "{}" ) $IID_SpeechLib_ISpeechObjectTokens = Guid$("{9285B776-2E7B-4BC0-B53E-580EB6FA967F}")

esto es un ejemplo en vba funcional

Code: Select all

Private V As SpeechLib.SpVoice
Private T As SpeechLib.ISpeechObjectToken

Private Sub Command1_Click()
    On Error GoTo EH

    If List1.ListIndex > -1 Then

        ' Set voice object to voice name selected in
        ' list box (new voice speaks its own name):
        Set V.Voice = V.GetVoices().Item(List1.ListIndex)
        V.Speak V.Voice.GetDescription

    Else
        MsgBox "Please select a voice from the list box."
    End If

EH:
    If Err.Number Then ShowErrMsg
End Sub

Private Sub Form_Load()
    On Error GoTo EH

    Dim strVoice As String

    Set V = New SpVoice

    'Get each token in the collection returned by GetVoices
    For Each T In V.GetVoices
        strVoice = T.GetDescription     'The token's name
        List1.AddItem strVoice          'Add to listbox
    Next
necesito la ayuda para trabajar con
tal como indica SAPI VOICE en microsoft https://learn.microsoft.com/en-us/previ ... 0(v=vs.85)
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
User avatar
AUGE_OHR
Posts: 2064
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: SpVoice Interface (SAPI 5.3)

Post by AUGE_OHR »

hi,

i have ask in Fivewin Forum how to change Voice from SpVoice.

Antonio Linares found out that is is a harbour bug and have post CODE to fix harbour/contrib/hbwin/olecore.c
HB_FUNC( WIN_OLEAUTO___ONERROR )
https://forums.fivetechsupport.com/view ... 5&start=10
have fun
Jimmy
User avatar
danielmaximiliano
Posts: 2612
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Contact:

Re: SpVoice Interface (SAPI 5.3)

Post by danielmaximiliano »

AUGE_OHR wrote: Sun Jan 28, 2024 6:43 am hi,

i have ask in Fivewin Forum how to change Voice from SpVoice.

Antonio Linares found out that is is a harbour bug and have post CODE to fix harbour/contrib/hbwin/olecore.c
HB_FUNC( WIN_OLEAUTO___ONERROR )
https://forums.fivetechsupport.com/view ... 5&start=10
ya lo vi,, estaba publicado hace 5 dias, estoy bajando la version nigthly desde https://sourceforge.net/projects/harbour-project/ modificar y recompilar harbour desde su fuentes
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
User avatar
danielmaximiliano
Posts: 2612
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Contact:

Re: SpVoice Interface (SAPI 5.3)

Post by danielmaximiliano »

AUGE_OHR wrote: Sun Jan 28, 2024 6:43 am hi,

i have ask in Fivewin Forum how to change Voice from SpVoice.

Antonio Linares found out that is is a harbour bug and have post CODE to fix harbour/contrib/hbwin/olecore.c
HB_FUNC( WIN_OLEAUTO___ONERROR )
https://forums.fivetechsupport.com/view ... 5&start=10
una pregunta... aqui en donde hay que agregar la modificacion ?
Captura de pantalla 2024-01-29 172700.png
Captura de pantalla 2024-01-29 172700.png (48.14 KiB) Viewed 702 times
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
User avatar
danielmaximiliano
Posts: 2612
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Contact:

Re: SpVoice Interface (SAPI 5.3)

Post by danielmaximiliano »

hola a todos :
mejorando un poco el codigo y esperando que hagan la correción de harbour encontre que a pesar de haber instalado mas "narradores" a windows
SapiVoice solo me muestra 3.. Zira, Helena y Sabina(Mujeres).
buscando el porqué encontré que existe Speech y SpeechOneCore en el registro de windows, busque en google y vi una aplicacion que Unifica esos Narradores el mismo se llama " SAPI-Unifier 1.1" y se puede descargar desde https://nvda.es/2017/10/20/dual-voice/
ahora tengo mas narradores en su version masculina y femenina :D
Captura de pantalla 2024-01-29 224015.png
Captura de pantalla 2024-01-29 224015.png (27.76 KiB) Viewed 676 times
SapiVoice2.rar
(7.4 KiB) Downloaded 41 times
desde ya espero les sirva de ejemplo :geek:
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
User avatar
AUGE_OHR
Posts: 2064
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: SpVoice Interface (SAPI 5.3)

Post by AUGE_OHR »

hi Daniel,

i have not see the CODE of HB_FUNC( WIN_OLEAUTO___ONERROR ) in harbour/contrib/hbwin/olecore.c

i would search for

Code: Select all

DISPATCH_PROPERTYPUT
p.s. "where" do i get "latest" Source CODE of Harbour ?
under https://sourceforge.net/projects/harbour-project/ i just got "old" Binary Files
have fun
Jimmy
User avatar
gfilatov
Posts: 1069
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: SpVoice Interface (SAPI 5.3)

Post by gfilatov »

danielmaximiliano wrote: Tue Jan 30, 2024 2:11 am hola a todos :
...
desde ya espero les sirva de ejemplo :geek:
Hi Daniel,

Thanks a lot :!:

Your example works great here. :)
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
Post Reply