Tasker Task: Function: Say

Since I’ve been working on a personal assistant I want to have a single place to control all my Say actions. This way when I wanted to change the voice I only had to do it in a single place. However this created another problem as I started messing with multiple voices, if I wanted Tasker to say something in a voice other than the one used by this universal say task I’d still have to use separate Says. This resulted in my creating this function for switching between voices and using a “default” voice in the absence of any settings modifiers.

Originally the setup was a profile looking for a variable to be set to trigger the whole thing. This had its own issues where if the profile was triggered again before it fully exited then it would get stuck on. This resulted in my adapting it so it can be used as a function that would allow a task to call on it using the Perform Task action.

This particular version is set up with support for Cereproc Voices and their ability to have “emotions” but the extra task goes to show how easy it is to add additional settings if you want or need them.


How to use Function: Say

The way this is used is by using Perform Task

%par1 will pass whatever text you want said.

%par2 will pass settings in the following format voice•pitch•speed•emotion

For settings you need at least one • for it to parse correctly. So if you only want to change the voice then it needs to be voice•


Human Readable Version of Function: Say

Function: Say (59)
A1: Variable Set [ Name:%say To:%par1 Do Maths:Off Append:Off ]
A2: Variable Set [ Name:%flash To:%par1 Do Maths:Off Append:Off ]
A3: Flash [ Text:%flash Long:On ]
<Settings Control>
A4: If [ %settings ~ %settings ]
A5: Variable Set [ Name:%settings To:%par2 Do Maths:Off Append:Off ] If [ %par2 Is Set ]
A6: Variable Split [ Name:%settings Splitter:• Delete Base:Off ] If [ %settings ~R • ]
A7: Variable Set [ Name:%voice To:%settings1 Do Maths:Off Append:Off ] If [ %settings1 Is Set ]
A8: Variable Set [ Name:%pitch To:%settings2 Do Maths:Off Append:Off ] If [ %settings2 > 0 ]
A9: Variable Set [ Name:%speed To:%settings3 Do Maths:Off Append:Off ] If [ %settings3 > 0 ]
A10: Variable Set [ Name:%pitch To:5 Do Maths:Off Append:Off ] If [ %settings2 = 0 ]
A11: Variable Set [ Name:%speed To:5 Do Maths:Off Append:Off ] If [ %settings3 = 0 ]
A12: End If
<Cereproc Emotions>
A13: Variable Set [ Name:%say To:%par1</voice> Do Maths:Off Append:Off ] If [ %settings4 ~R cross|happy|calm|sad ]
<Voice Chooser - Voice 1>
A14: If [ %voice ~ caitlin ]
A15: Variable Set [ Name:%voice To:com.cereproc.Caitlin:en-ie-Caitlin.voice Do Maths:Off Append:Off ]
<Voice 2>
A16: Else If [ %voice ~ heather ]
A17: Variable Set [ Name:%voice To:com.cereproc.Heather:en-gb-Heather.voice Do Maths:Off Append:Off ]
<Voice 3>
A18: Else If [ %voice ~ william ]
A19: Variable Set [ Name:%voice To:com.cereproc.William:en-gb-William.voice Do Maths:Off Append:Off ]
<Default Voice>
A20: Else
A21: Variable Set [ Name:%voice To:com.google.android.tts:eng-usa Do Maths:Off Append:Off ]
A22: End If
A23: Say [ Text:%say Engine:Voice:%voice Stream:3 Pitch:%pitch Speed:%speed Respect Audio Focus:Off Continue Task Immediately:Off ]

Download Zipped XML File: Function__Say.tsk