Text to Phonemes / C to PB converter

Just starting out? Need help? Post your questions and find answers here.
wmorton
User
User
Posts: 81
Joined: Fri Jul 25, 2003 5:39 pm

Text to Phonemes / C to PB converter

Post by wmorton »

Hi, is there any source for a text to phoneme converter in PB? Failing this, is there a C to PB converter? I found something but it's in C (and I don't know the first thing about C) http://www.speech.cs.cmu.edu/comp.speec ... eme.3.html

Thanks!
User avatar
Tomi
Enthusiast
Enthusiast
Posts: 270
Joined: Wed Sep 03, 2008 9:29 am

Post by Tomi »

maybe "Demo_Sapi.pb" sample in COMate 4.30 by srod in http://www.nxsoftware.com/ :)
wmorton
User
User
Posts: 81
Joined: Fri Jul 25, 2003 5:39 pm

Post by wmorton »

Ah yes, I've just had a look at this, it sends text to a SAPI voice.

What I am looking for though, is something like the program in my first post, where it converts text to phonemes, not text to speech. So, if I type in "My Generation." the program outputs "~mAY _J2EHnAXr1EYSIXn." (or similar)

Thanks!
Last edited by wmorton on Tue May 05, 2009 5:16 pm, edited 1 time in total.
dagcrack
Addict
Addict
Posts: 1868
Joined: Sun Mar 07, 2004 8:47 am
Location: Argentina
Contact:

Post by dagcrack »

If you decide to port the code, do try and don't give up. You'll soon realize the syntax of C isn't that hard and you'll probably even have an epiphany sooner or later.

Just to get you started the first 3 functions of phoneme.c

Code: Select all

Procedure.i isupper( chr.c )
	ProcedureReturn ( chr => 'A' And chr <= 'Z' )
EndProcedure

Procedure.i isvowel( chr.c )
	ProcedureReturn ( chr = 'A' Or chr = 'E' Or chr = 'I' Or chr = 'O' Or chr = 'U' )
EndProcedure

Procedure.i isconsonant( chr.c )
	ProcedureReturn ( isupper(chr) And Not isvowel(chr) )
EndProcedure
One of the biggest problems will probably be the arrays due to syntax constraints in PB but you could easily load the contents from a txt which will ultimately be a better option if you require flexibility, although the data appears to be constant in this case.

Some functions are not required to be ported because in PB you already have quite a few string manipulation helpers. Unless that is you want to perform a literal port of the code.

In such case you'll need this as well:

Code: Select all

Procedure.i isalpha( chr.c )
	ProcedureReturn (chr => 'A' And chr <= 'Z') Or (chr => 'a' And chr <= 'z')
EndProcedure

Procedure.i isdigit( chr.c )
	ProcedureReturn (chr => '0' And chr <= '9')
EndProcedure

Procedure.i islower( chr.c )
	ProcedureReturn (chr => 'a' And chr <= 'z')
EndProcedure
some testing code...

Code: Select all

Debug isupper( 'a' )
Debug isupper( 'A' )

Debug isvowel( 'F' )
Debug isvowel( 'E' )

Debug isconsonant( 'A' )
Debug isconsonant( 'D' )


Debug isalpha('0')
Debug isalpha('A')

Debug isdigit( 'D' )
Debug isdigit( '4' )

Debug islower( 'A' )
Debug islower( 'a' )

Cheers.
! Black holes are where God divided by zero !
My little blog!
(Not for the faint hearted!)
Post Reply