called the Regex engine from the evaluated regex

Forum for TextAloud version 3

Moderator: Jim Bretti

Post Reply
dbundy
Posts: 6
Joined: Sun Dec 30, 2012 11:44 am
Contact:

called the Regex engine from the evaluated regex

Post by dbundy »

Hello,

I have the impression that it's not possible for the regex engine to detect a pattern in a pattern and apply a rule in a embedded way.

I would like that every text between parenthesis to be pronounced : "between parenthesis read text end parenthesis"
For example the text

Code: Select all

(sorry for this)
should be read as "between parenthesis sorry for this end parenthesis"
With a regex, we can detected the pattern like that :

Code: Select all

\((.*)\)
The respell could be :
- between parenthesis

Code: Select all

 {{Pause=0.3}}  $1{{Pause=0.3}} end parenthesis{{Pause=0.2}}
My problem is that I would like apply again the regex engine on $1 to apply any rules if any rules is detected like valid in $1.
For example, if I have another rule which replaces 'Mr' by 'Mister', this rule will never be applied.
The spelling for the text

Code: Select all

 (Mr David) 
will be 'between parenthesis mr David end parenthesis' while i would like 'between parenthesis Mister David end parenthesis'.

I looked in the forum and I didn't found a response.
Is there a means to do what i want with TextAloud ?
A possible solution would be to trigger another time the analysis function on $1 but I don't know if it is possible.

Cheers
David
PHenry1026
Posts: 231
Joined: Thu Jan 11, 2007 12:10 pm
Contact:

Re: called the Regex engine from the evaluated regex

Post by PHenry1026 »

Greetings David,


You can solve your problem with the following two regexes:


(?#start_[)(?m)(?:^|\s|['"‘“(]|\p{Pi}|\p{Ps}|\p{Pd})\(\K(?=[^)\r\n(]+\)[’”\p{Po}\p{Pe}\p{Pf}]{0,2}(?:\s|$))


between parenthesis, <s>



(?#end_])(?m)(?:^|\s|['"‘“(]|\p{Pi}|\p{Ps}|\p{Pd})\([^)\r\n(]+\K(?=\)[’”\p{Po}\p{Pe}\p{Pf}]{0,2}(?:\s|$))


,<s> end parenthesis



While testing you should place these regexes at the top of your dictionary for them to work properly and in the order above.




P.S., I only tested them using AT&T Natural Voice Mike.
Last edited by PHenry1026 on Sun May 12, 2013 5:47 am, edited 1 time in total.
dbundy
Posts: 6
Joined: Sun Dec 30, 2012 11:44 am
Contact:

Re: called the Regex engine from the evaluated regex

Post by dbundy »

PHenry1026,

Thanks a lot for your successful solution!
It works perfectly with Bruno Acapella French voice.
What an expression !
How did you discover such a trick ?? I see no relation with the classic regex synthax I use.
Anyway, awesome !

David
Post Reply