MacOS espeak
MacOS espeak
Hello,
Is it possible to use Espeak within a purebasic windowprogram (not a console application) on the mac platform?
Michel
Is it possible to use Espeak within a purebasic windowprogram (not a console application) on the mac platform?
Michel
Re: MacOS espeak
I don' t see why not and it doesn't matter if you want to use it in a console or windowed app. Espeak has a command line interface, just use RunProgram() and all related stuff to call it and pass any text you like.
Re: MacOS espeak
Hello,
You mentioned it: the related stuff is the problem
Michel
You mentioned it: the related stuff is the problem
Michel
Re: MacOS espeak
https://www.purebasic.com/documentation ... index.html
Code: Select all
#synthesizerPath = "/opt/homebrew/bin/espeak" ; path to your espeak, you can also use /usr/bin/say which is included in macOS by default
Procedure say(text.s)
synthesizer = RunProgram(#synthesizerPath,"",GetEnvironmentVariable("HOME"),#PB_Program_Open|#PB_Program_Write)
If synthesizer
WriteProgramStringN(synthesizer,text)
WriteProgramData(synthesizer,#PB_Program_Eof,0)
CloseProgram(synthesizer)
EndIf
EndProcedure
OpenWindow(0,0,0,400,300,"Voice Synthesizer Test",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
EditorGadget(0,10,10,380,240,#PB_Editor_WordWrap)
ButtonGadget(1,10,260,380,30,"synthesize")
Repeat
ev = WaitWindowEvent()
If ev = #PB_Event_Gadget And EventGadget() = 1
say(GetGadgetText(0))
EndIf
Until ev = #PB_Event_CloseWindow
Re: MacOS espeak
Making the computer's speech sound better
You can make the computer's speech sound more natural using punctuation to add pauses and terms to remove unnecessary emphasis.
Adding pauses:
To add a pause to a spoken line:
– Insert a comma where you want a pause to occur.
For example:
To add a shorter pause before and after a phrase:
– Put single quotation marks around the phrase.
For example:
Adding emphasis:
To add emphasis to a word:
– Insert [[emph +]] before the word.
For example:
Removing unneeded emphasis:
To remove emphasis from a word:
– Insert [[emph -]] before the word.
For example:
Emphasis is automatically removed from common short words such as "to," "and," "were," and "the."

This is Applescript: see viewtopic.php?p=605929#p605929
You can make the computer's speech sound more natural using punctuation to add pauses and terms to remove unnecessary emphasis.
Adding pauses:
To add a pause to a spoken line:
– Insert a comma where you want a pause to occur.
For example:
Code: Select all
say "You have a meeting, next Monday at 3:30, in room 57."
– Put single quotation marks around the phrase.
For example:
Code: Select all
say "The file 'status report' has been printed."
To add emphasis to a word:
– Insert [[emph +]] before the word.
For example:
Code: Select all
say "I [[emph +]] love my Mac."
To remove emphasis from a word:
– Insert [[emph -]] before the word.
For example:
Code: Select all
say "Five [[emph -]] documents were printed, and three were [[emph -]] copied to backup."

This is Applescript: see viewtopic.php?p=605929#p605929
Re: MacOS espeak
Many thanks to your support
Michel
Michel

Re: MacOS espeak
Direct with Siri voice ...
Code: Select all
Global SpeechSynthesizer = CocoaMessage(0, CocoaMessage(0, 0, "NSSpeechSynthesizer alloc"), "initWithVoice:", #nil)
Global voice.s = "com.apple.speech.synthesis.voice.siri"
CocoaMessage(0, SpeechSynthesizer, "setVoice:$", @voice)
CocoaMessage(0, SpeechSynthesizer, "startSpeakingString:$", @"Hello, I like purebasic")
If OpenWindow(0, 0, 0, 200, 30, "Hallo", #PB_Window_SystemMenu)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: MacOS espeak
You should also try out wilbert's two speech synthesizer examples using the Speech Synthesis Manager (just successfully tested with MacOS 11.7.9 'Big Sur'). The speech quality is much better than in mk-soft's Siri example.
Re: MacOS espeak
You are very welcome!
PS: if you want to get fired (while trying to send a colleague to psychiatric hospital) learn how to login to other Macs on the local network, then use the "Whisper" voice…