PB.Ex Speech (Windows)

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: PB.Ex Speech (Windows)

Post by RSBasic »

I tested in a VM with Windows XP with .NET 4 installed. Works here.
I tested in a VM with Windows XP without .NET 4. Here the variable PBEx_Speech has the value > 0.
The application crashes when the first function is executed, but the DLL file could be loaded.
BarryG wrote:I just noticed that the return value of the PBEx_Speech variable is 0 on XP
Do you use the right version (32 or 64 bit)? Can the DLL file be found?
Image
Image
BarryG
Addict
Addict
Posts: 3292
Joined: Thu Apr 18, 2019 8:17 am

Re: PB.Ex Speech (Windows)

Post by BarryG »

Hi RSBasic, yes, I used the right DLL. Here's a picture to explain it all: https://i.imgur.com/UYubizc.png

Other things I tried: renaming the DLL (in case the dot in "PB.Ex" made it look like not a DLL file), turned off my virus-scanner (Avast), changed #PB_Any to 1 (hard-coded library number). Still returns 0 when trying to load the DLL, despite all of these changes.
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: PB.Ex Speech (Windows)

Post by RSBasic »

You tried everything. I have no other idea. I don't know why that is. :?

\\Edit:
Maybe: https://thewindowsclub-thewindowsclubco ... nblock.jpg
Image
Image
BarryG
Addict
Addict
Posts: 3292
Joined: Thu Apr 18, 2019 8:17 am

Re: PB.Ex Speech (Windows)

Post by BarryG »

RSBasic wrote:You tried everything.
I even tried after booting XP in Safe Mode, but still no luck.

XP doesn't have an option to unblock a file from the Properties dialog.

XP is dead anyway, so don't worry about it. Just thought it may be something you overlooked.
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: PB.Ex Speech (Windows)

Post by RSBasic »

PB.Ex Speech 1.0.3.0 has been released.

Changelog:
  • Bugfix: TextToAudioFile(): After the creation the audio file was still opened by the program.
Image
Image
User avatar
minimy
Enthusiast
Enthusiast
Posts: 344
Joined: Mon Jul 08, 2013 8:43 pm

Re: PB.Ex Speech (Windows)

Post by minimy »

Hello, thanks for this incredible dll. Really usefull!
I have a little problem. Whe try to use other voices, in spanish (from Spain) may be Pablo (es-ES-Pablo) or Laura..
System return no match.

I use some thing like this: TextToSpeaker("¡Hola amigos de PureBasic!", "ES-es-Pablo", 0, 100, 0, @ErrorOutput$)

What is the right syntax used by tts?. I try lot of combinations but no work. (es-Pablo, ES-es-Pablo, ..)

Can you help me?. Thanks you very much and congratulations for another great job!
If translation=Error: reply="Sorry, Im Spanish": Endif
loulou2522
Enthusiast
Enthusiast
Posts: 495
Joined: Tue Oct 14, 2014 12:09 pm

Re: PB.Ex Speech (Windows)

Post by loulou2522 »

Hi RSBASIC,
Where can i find the name of all voice as invoke in text speech ?
Thanks
User avatar
ar-s
Enthusiast
Enthusiast
Posts: 340
Joined: Sat Oct 06, 2007 11:20 pm
Location: France

Re: PB.Ex Speech (Windows)

Post by ar-s »

@loulou2522
Voice list here :

Code: Select all

Global NewList Voices.s()

Import "ole32.lib"
   CoInitialize(reserved.l = #Null)
   CoUninitialize()
   CLSIDFromProgID(ProgID.p-bstr, *clsid.CLSID)
   CLSIDFromString(String.p-bstr, *clsid.CLSID)
EndImport

#CLSCTX_INPROC_SERVER = 1

Enumeration 0 ; SpeechVoiceSpeakFlags
   #SVSFDefault          = 0
   #SVSFlagsAsync        = 1
   #SVSFPurgeBeforeSpeak = 2
   #SVSFIsFilename       = 4
   #SVSFIsXML            = 8
   #SVSFIsNotXML         = 16
   #SVSFPersistXML       = 32
   #SVSFNLPSpeakPunc     = 64
   #SVSFNLPMask          = 64
   #SVSFVoiceMask        = 127
   #SVSFUnusedFlags      = -128
EndEnumeration


Interface ISpeechVoice Extends IDispatch
   get_Status(*ISpeechVoiceStatus.l)
   get_Voice(*ISpeechObjectToken.l)
   put_Voice(*ISpeechObjectToken.l)
   get_AudioOutput(*ISpeechObjectToken.l)
   put_AudioOutput(*ISpeechObjectToken.l)
   get_AudioOutputStream(*ISpeechBaseStream.l)
   put_AudioOutputStream(*ISpeechBaseStream.l)
   get_Rate(long.l)
   put_Rate(long.l)
   get_Volume(long.l)
   put_Volume(long.l)
   put_AllowAudioOutputFormatChangesOnNextSet(VARIANT_BOOL.l)
   get_AllowAudioOutputFormatChangesOnNextSet(VARIANT_BOOL.l)
   get_EventInterests(SpeechVoiceEvents.l)
   put_EventInterests(SpeechVoiceEvents.l)
   put_Priority(SpeechVoicePriority.l)
   get_Priority(SpeechVoicePriority.l)
   put_AlertBoundary(SpeechVoiceEvents.l)
   get_AlertBoundary(SpeechVoiceEvents.l)
   put_SynchronousSpeakTimeout(long.l)
   SynchronousSpeakTimeout(long.l)
   Speak(Text.p-bstr, SpeechVoiceSpeakFlags.l, long.l)
   SpeakStream(*ISpeechBaseStream, SpeechVoiceSpeakFlags.l, long.l)
   Pause()
   Resume()
   Skip(*Type, NumItems.l, long.l)
   GetVoices(*RequiredAttributes.l, *OptionalAttributes, *ISpeechObjectTokens.l)
   GetAudioOutputs(*RequiredAttributes, *OptionalAttributes, *ISpeechObjectTokens.l)
   WaitUntilDone(msTimeout.l, VARIANT_BOOL.l)
   SpeakCompleteEvent(long.l)
   IsUISupported(*TypeOfUI, *ExtraData.VARIANT, VARIANT_BOOL.l)
   DisplayUI(hWndParent.l, *Title, *TypeOfUI, *ExtraData.VARIANT)
EndInterface
Interface ISpeechObjectToken Extends IDispatch
   get_Id(ObjectId)
   get_DataKey(ISpeechDataKey.l)
   get_Category(ISpeechObjectTokenCategory.l)
   GetDescription(Locale.l, Description)
   SetId(id, CategoryID, CreateIfNotExist)
   GetAttribute(AttributeName.p-bstr, *AttributeValue)
   CreateInstance(pUnkOuter, SpeechTokenContext, Object)
   Remove(ObjectStorageCLSID)
   GetStorageFileName(ObjectStorageCLSID, KeyName, FileName, SpeechTokenShellFolder, *FilePath)
   RemoveStorageFileName(ObjectStorageCLSID, KeyName, DeleteFile)
   IsUISupported(TypeOfUI, *ExtraData, *Object, *Supported)
   DisplayUI(hwnd, Title, TypeOfUI, *ExtraData, *Object)
   MatchesAttributes(Attributes, *Matches)
EndInterface
Interface ISpeechObjectTokens Extends IDispatch
   get_Count(a.l)
   Item(Index.l, Token.ISpeechObjectToken)
   get__NewEnum(ppEnumVARIANT.IUnknown )
EndInterface


Procedure.l Speak(*SpeechVoice.ISpeechVoice, *SpeechObjectTokens.ISpeechObjectTokens, Text.s, Rate.l = 0, Voice.l = 0,Volume=100)
   Protected flag.l = #SVSFDefault, Token.ISpeechObjectToken
   If *SpeechObjectTokens\Item(Voice, @Token) = #S_OK
*SpeechVoice\put_Volume(volume)
      *SpeechVoice\put_Voice(Token)
      *SpeechVoice\put_Rate(Rate)
      *SpeechVoice\Speak(Text, 0, @flag)
   EndIf
EndProcedure



;
Procedure  ListVoices( )
   If CLSIDFromProgID("SAPI.SpVoice", @clsid.CLSID) = #S_OK
      If CLSIDFromString("{269316D8-57BD-11D2-9EEE-00C04F797396}", @Refiid.CLSID) = #S_OK
         CoInitialize()
         If  CoCreateInstance_(clsid, #Null, #CLSCTX_INPROC_SERVER, Refiid, @SpeechVoice.ISpeechVoice) = #S_OK       
            SpeechVoice\GetVoices(0, 0, @SpeechObjectTokens.ISpeechObjectTokens)
            SpeechObjectTokens\get_Count(@Count)
            VoiceList.s = ""
            VoiceList =Str(count)+","
            For i = 0 To Count - 1
               SpeechObjectTokens\Item(i, @Token.ISpeechObjectToken)
               Token\GetDescription(0, @Description)
               Token\GetAttribute("Language", @AttributeValue)
               VoiceList+ PeekS(Description, -1, #PB_Unicode) + ","
               AddElement (Voices())
               Voices() = PeekS(Description, -1, #PB_Unicode)
               Token\Release()
            Next i
            SpeechObjectTokens\Release()
            SpeechVoice\Release()
         EndIf
         CoUninitialize()
      EndIf
   EndIf
   ProcedureReturn ListSize(Voices())
EndProcedure


;- Test it ---

If ListVoices( ) > 0
  ForEach Voices( ) 
    Debug Voices()
  Next 
Else
  Debug "My Computer is mute :)"
EndIf

~Ar-S~
My Image Hoster for PB users
My webSite (french) with PB apps : LDVMULTIMEDIA
PB - 3.x / 5.7x / 6 - W11 x64 - Ryzen 7 3700x / #Rpi4

Code: Select all

r3p347 : 7ry : un71l d0n3 = 1
morosh
Enthusiast
Enthusiast
Posts: 293
Joined: Wed Aug 03, 2011 4:52 am
Location: Beirut, Lebanon

Re: PB.Ex Speech (Windows)

Post by morosh »

Hello:
How to select a particular voice (not the default one), I need to speak in many languages.

Thanks
PureBasic: Surprisingly simple, diabolically powerful
BarryG
Addict
Addict
Posts: 3292
Joined: Thu Apr 18, 2019 8:17 am

Re: PB.Ex Speech (Windows)

Post by BarryG »

Is there any way to stop a voice from speaking before it's finished? Thanks.
User avatar
Caronte3D
Addict
Addict
Posts: 1025
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: PB.Ex Speech (Windows)

Post by Caronte3D »

I don't use this library, but sometimes...
Try to send an empty string (you may need some flag to play the empty scring without waiting for the previous one to finish).
BarryG
Addict
Addict
Posts: 3292
Joined: Thu Apr 18, 2019 8:17 am

Re: PB.Ex Speech (Windows)

Post by BarryG »

Tried an empty string but it doesn't work.
TassyJim
Enthusiast
Enthusiast
Posts: 151
Joined: Sun Jun 16, 2013 6:27 am
Location: Tasmania (Australia)

Re: PB.Ex Speech (Windows)

Post by TassyJim »

I haven't used that library but I can confirm that this code on the French forum works.
https://www.purebasic.fr/french/viewtop ... ese+vocale

I used the code in a project a few years ago and just tested it on Windows 11.
It runs well including the pause and stop functions.

The only problem I have is, I can't compile as 64 bit. 32 bit C backend is fine.
There will be a variable somewhere that is long instead of integer but I don't know my way around the code well enough to find it.

Jim
dige
Addict
Addict
Posts: 1247
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: PB.Ex Speech (Windows)

Post by dige »

Download not possible: http://www.rsbasic.de/downloads/downloa ... Speech.zip
Is there a new download link? Thx.
"Daddy, I'll run faster, then it is not so far..."
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: PB.Ex Speech (Windows)

Post by RSBasic »

The problem is with the http address. With https it works: https://www.rsbasic.de/downloads/downlo ... Speech.zip
Image
Image
Post Reply