4
$\begingroup$

I need to vary the speed, pause, reverse and in general control aspects of the playback of Speak[] is this possible?

$\endgroup$
1
  • $\begingroup$ You could build up a front end based on SpokenString[Range[15], Options[Speak], "PostProcess" -> False] $\endgroup$ Mar 10, 2015 at 15:18

1 Answer 1

5
$\begingroup$
"<volume level=\"100\">  <emph> Update 2 ! </emph> 
 <volume level=\"50\">
 Some examples of text-to-speech <spell> xml </spell> 
 tags that you can inject into the string input for Speak 
 from <spell> XML TTS </spell> Tutorial. 
For example the following <spell> url </spell> is spelled out 
     <spell> https://msdn.microsoft.com/en-us/library/ms717077(v=vs \
.85).aspx. 
     </spell> 
 and the following text is read backwards at 
 <rate absspeed=\"-5\"> lower speed 
 <voice required=\"Gender=Female\">
    by a female
      <silence msec=\"500\"/> 
        esrever ni nekops eb dluohs txet sihT
      </rate>
 </voice>
 and  <rate absspeed=\"5\"> higher speed <silence msec=\"500\"/>
        esrever ni nekops eb dluohs txet sihT
      </rate>
   </rate>
   </volume> " // Speak

See: XML TTS Tutorial (SAPI 5.3)

"<rate absspeed=\"5\">
    This text should be spoken at rate five.
    <rate absspeed=\"-5\">
       This text should be spoken at rate negative five.
    </rate>
 </rate>
 <rate absspeed=\"10\"/>" // Speak

"<volume level=\"50\">
 This text should be spoken at volume level fifty.
    <volume level=\"100\">
     This text should be spoken at volume level one hundred.
    </volume>
 </volume>" // Speak

"<rate absspeed=\"5\">
     Next text should be spoken in reverse.
     <rate absspeed=\"-5\">
        esrever ni nekops eb dluohs txet sihT
     </rate>
  </rate>
  <rate absspeed=\"10\"/>" // Speak

Update: You can insert XML tags into to string input to Speak to control voice gender, speed, volume, pitch etc.

Using few examples from sapisynth

"<voice required=\"Gender=Male\"/> <rate absspeed=\"-10\"/> the list  \
<silence msec=\"100\"/> 1 <volume level=\"200\"/> comma  <silence \
msec=\"100\"/> 2 <pitch middle=\"15\"/>  <silence msec=\"100\"/> 3 \
comma  <silence msec=\"100\"/> <volume level=\"20\"/> 4  <rate speed=\
\"10\"/> <voice required=\"Gender=Female\"/> 5 6 7 8 9 10 11 12  " //Speak

Original post:

To play with the speed, you can process the string expression output of SpokenString to change the length of silence elements.

SpokenString[Range[10], Options[Speak], "PostProcess" -> False]

enter image description here

For example:

StringReplace[SpokenString[Range[10], Options[Speak], "PostProcess" -> False], 
   {"100" -> "0", "comma" -> ""}] // Speak
$\endgroup$
3
  • 1
    $\begingroup$ The commands are not the same for OSX as Mathematica sends the text to the system specific speech engine. Here is the corresponding documentation for OSX. For example try :Speak["[[volm 0.3]] You can do [[rate 400]] [[volm 1.5]] many many many many [[rate 50]] things.[[rset 0.]] And [[slnc 1000]] others."] $\endgroup$
    – SquareOne
    Mar 10, 2015 at 18:07
  • $\begingroup$ @SquareOne, interesting. I am looking forward to seeing your post. $\endgroup$
    – kglr
    Mar 10, 2015 at 18:14
  • 1
    $\begingroup$ I am afraid I don't have anything more interesting to say. I just found these informations concerning OS X and Windows (and SAPI that you already gave) for this post. Actually I was exactly looking for the same info yesterday for this post of mine. I missed then the PostProcess option revealing that control command can be inserted in the text to fine tune the speech. However I noticed that the speech was sent to a local speech engine. $\endgroup$
    – SquareOne
    Mar 10, 2015 at 18:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.