Espeak
May 20, 2018 19:59:39 GMT 1
Post by alexfish on May 20, 2018 19:59:39 GMT 1
Hi All
Not Sure if this lib conversion has been done before
Here mainly talking RPI , since I was getting a lot of Problems with Configs & Espeak was failing to exit
esp with VOICE commands things like m3 f3 , but default m1 & f1 work
Ended up doing a simple BaconSpeak .
on Raspberry PI , one will get Alsa/Pulse/pcm and other warnings on INIT but it does work
Required 'libespeak-dev'
BR Alex
The Code
Not Sure if this lib conversion has been done before
Here mainly talking RPI , since I was getting a lot of Problems with Configs & Espeak was failing to exit
esp with VOICE commands things like m3 f3 , but default m1 & f1 work
Ended up doing a simple BaconSpeak .
on Raspberry PI , one will get Alsa/Pulse/pcm and other warnings on INIT but it does work
Required 'libespeak-dev'
BR Alex
The Code
' INCLUDES
OPTION PARSE FALSE
PRAGMA INCLUDE <espeak/speak_lib.h>
PRAGMA LDFLAGS -lespeak
REM don't delete this callback function.==================================
FUNCTION SynthCallback(short *wav, int numsamples, espeak_EVENT *events) TYPE int
RETURN FALSE
END FUNCTION
' ******************************************************************************
FUNCTION SpeakInit()
IF (espeak_Initialize(AUDIO_OUTPUT_SYNCH_PLAYBACK,0,NULL,espeakINITIALIZE_PHONEME_EVENTS) < 0) THEN
PRINT "could not initialize espeak\n"
END
ELSE
espeak_SetSynthCallback(SynthCallback)
RETURN 1
END IF
END FUNCTION
FUNCTION Speak(STRING textBuff) TYPE int
espeak_Synth(textBuff, strlen(textBuff), 0,(espeak_POSITION_TYPE)0,0,espeakPHONEMES|espeakSSML|espeakENDPAUSE,NULL,NULL)
RETURN TRUE
END FUNCTION
' OPTIONS *********************************************************************
/* Sets the value of the specified parameter.
espeak_SetParameter(option,relative)
relative=0 Sets the absolute value of the parameter.
relative=1 Sets a relative value of the parameter.
Return: EE_OK: operation achieved
EE_BUFFER_FULL: the command can not be buffered;
you may try after a while to call the function again.
EE_INTERNAL_ERROR.
*/
SUB SpeakRate(int speed)
' espeakRATE: speaking speed in word per minute. Values 80 to 450.
espeak_SetParameter(espeakRATE, speed, 0)
END SUB
SUB SpeakVolume(int volume)
/*
espeakVOLUME: volume in range 0-200 or more.
0=silence, 100=normal full volume, greater values may produce
amplitude compression or distortion
*/
espeak_SetParameter(espeakVOLUME, volume, 0)
END SUB
SUB SpeakPitch(int pitch)
' espeakPITCH: base pitch, range 0-100. 50=normal
espeak_SetParameter(espeakPITCH, pitch, 0)
END SUB
SUB SpeakRange(int range)
' espeakRANGE: pitch range, range 0-100. 0-monotone, 50=normal
espeak_SetParameter(espeakRANGE, range, 0)
END SUB
SUB SpeakPunctuation(int punc)
/*
espeakPUNCTUATION: which punctuation characters to announce:
value in espeak_PUNCT_TYPE (none, all, some),
see espeak_GetParameter() to specify which characters are announced.
*/
espeak_SetParameter(espeakPUNCTUATION, punc, 0)
END SUB
SUB SpeakCapitals(int caps)
/*
espeakCAPITALS: announce capital letters by:
0=none,
1=sound icon,
2=spelling,
3 or higher, by raising pitch. This values gives the amount in Hz by which the pitch
of a word raised to indicate it has a capital letter.
*/
espeak_SetParameter(espeakCAPITALS, caps, 0)
END SUB
SUB SpeakGap(int gap)
' espeakWORDGAP: pause between words, units of 10mS (at the default speed)
espeak_SetParameter(espeakWORDGAP, gap, 0)
END SUB
' END OPTIONS
' ******************************************************************************
SUB SpeakVoice(STRING Voice)
espeak_SetVoiceByName(Voice)
END SUB
' ******************************************************************************
SUB SpeakMale(STRING txt)
SpeakVoice("m1")
Speak(txt)
END SUB
SUB SpeakFemale(STRING txt)
SpeakVoice("f1")
Speak(txt)
END SUB
' Main *************************************************************************
SpeakInit()
SpeakVolume(100)
SpeakFemale("Hello World . OK")
SpeakVolume(50)
SpeakMale("Hello World . OK . OK")
SpeakVolume(100)
SpeakFemale(" . OK")
Speak("<s xml:lang=\"en\"><voice gender=\"female\">Dit wordt gesproken door een vrouw.</voice></s>")
Speak("[[D,Is Iz sVm f@n'EtIk t'Ekst 'InpUt]]")
espeak_Cancel()
espeak_Terminate()