# Speech Synthesis --interactive option

**URL:** <https://forum.xojo.com/t/speech-synthesis-interactive-option/66073>\
**Category:** macOS\
**Created:** [October 12, 2021, 11:30pm UTC](https://forum.xojo.com/t/speech-synthesis-interactive-option/66073 "2021-10-12T23:30:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eric\_R](https://forum.xojo.com/user_avatar/forum.xojo.com/eric_r/32/2371_2.png) [@Eric\_R](https://forum.xojo.com/u/Eric_R)\
**Post date:** [October 12, 2021, 11:30pm UTC](https://forum.xojo.com/t/speech-synthesis-interactive-option/66073/1 "2021-10-12T23:30:21Z")

</div>

Hi,

“man say” in the terminal has the option of --interactive. I tired it out in the terminal and pretty cool.  
" Print the text line by line during synthesis, highlighting words as they are spoken"

In my app I open text file and display the text and have an option to speak the text by passing the text or the selected text to s.Execute("say " + sometext) How can I have my app highlight the text in the textarea as its being spoken like with the --interactive option?

This one puzzles me a bit.

Thanks.

---

<div class="post-metadata">

**Author:** ![Matthew\_Dinmore1](https://forum.xojo.com/letter_avatar_proxy/v4/letter/m/ecae2f/32.png) [@Matthew\_Dinmore1](https://forum.xojo.com/u/Matthew_Dinmore1)\
**Post date:** [October 13, 2021, 3:03am UTC](https://forum.xojo.com/t/speech-synthesis-interactive-option/66073/2 "2021-10-13T03:03:15Z")

</div>

Break the source text into words (e.g. split on spaces), then pass each piece to say at the same time you highlight it in the textarea.

---

<div class="post-metadata">

**Author:** ![Antonio\_Rinaldi](https://forum.xojo.com/user_avatar/forum.xojo.com/antonio_rinaldi/32/331_2.png) [@Antonio\_Rinaldi](https://forum.xojo.com/u/Antonio_Rinaldi)\
**Post date:** [October 13, 2021, 7:34am UTC](https://forum.xojo.com/t/speech-synthesis-interactive-option/66073/3 "2021-10-13T07:34:16Z")

</div>

Use an interactive shell,  
in the dataAvaliable event you will have your string with some control codes  
find the position of the start hi light IE [7m and the position of the ending one IE (B  
considering the offset: the string has a [M extra and if you have more lines you will have to shift for the current line of text since say replies are relative to the current line (endofline)  
Hilight as you wish the text in your textArea

---

<div class="post-metadata">

**Author:** ![Christian\_Schmitz](https://forum.xojo.com/user_avatar/forum.xojo.com/christian_schmitz/32/158_2.png) [@Christian\_Schmitz](https://forum.xojo.com/u/Christian_Schmitz)\
**Post date:** [October 13, 2021, 7:34am UTC](https://forum.xojo.com/t/speech-synthesis-interactive-option/66073/4 "2021-10-13T07:34:47Z")

</div>

Well, for that we have willSpeakWord event in [NSSpeechSynthesizerMBS](https://www.monkeybreadsoftware.net/class-nsspeechsynthesizermbs.shtml) class in [MBS Xojo Plugins](https://www.monkeybreadsoftware.de/xojo/).

And the sample project [NSSpeechSynthesizer Progress](https://www.monkeybreadsoftware.net/example-maccocoa-nsspeechsynthesizerprogress.shtml) does show the word highlighting.

---

<div class="post-metadata">

**Author:** ![Eric\_R](https://forum.xojo.com/user_avatar/forum.xojo.com/eric_r/32/2371_2.png) [@Eric\_R](https://forum.xojo.com/u/Eric_R)\
**Post date:** [October 13, 2021, 7:39pm UTC](https://forum.xojo.com/t/speech-synthesis-interactive-option/66073/5 "2021-10-13T19:39:13Z")

</div>

I see. Testing out some ideas. Cool thanks! 🕶
