Arduino Due: S1V30120 text to speech

Making your Arduino talk? It can be done, using a true text-to-speech implementation using the Epson S1V30120 IC, here on a text-to-speech click board from MikroElektronika. This particular implementation uses SPI communication, plus several control pins. This includes a reset pin, a mute pin that silences the output amplifier, as well as a data ready pin used by the S1V30120 to signal that it has data to send to the host.

It might look simple, but in fact it’s quite complicated, as the S1V30120 uses a proprietary messaging system over SPI. To make matter worse, the S1V30120 must be initialized every time after the reset, including the upload of a large firmware file. The current firmware file is just under 32kb, and this limits the use of the text-to-speech board to Arduino boards that come with enough memory to store this file. Such Arduino boards include the Arduyino Due and the Arduino M0.

In this post I used one Flip & click board, which is a derivative of the Arduino Due, with four mikroBUS sockets, matching the click board format. The text-to-speech click is placed in socket #1.

For the given moment there isn’t any code library for the S1V230120 that works with Arduino, so I had to start everything from scratch. All I had is the code example provided by MikroElektronika, but porting that code from MikroC to Arduino proved to be a real pain in the well-you-know. In the end I went for my own implementation, using the S1V30120 Message Protocol Specification.

The result is a just a code example implementing basic text-to-speech functionality. There’s no ADPCM implementation, and there’s a partial implementation of the messaging protocol. Even with this limitations, it can speak. Only the male voice in English is used, but one can alter the code easily for other voices. Also the tempo of the voice is fixed, a function to change this will be provided in a future version of the code. I also plan to transform this code into a library, but there’s a lot to work to do before this will happen…

S1V30120: boot mode

Once the S1V30120 is reset, it enters boot mode. A limited command set is available in this mode, and one must upload the firmware file before proceeding. So, the workflow in this mode is as follows:

  • The host issues ISC_VERSION_REQ message
  • The S1V30120 responds with ISC_VERSION_RESP
  • Firmware file is loaded by sending chunks of data, each chunk being of maximum 2048 bytes in lengh, including the header. Each chunk is sent via an ISC_BOOT_LOAD_REQ message.
  • After receiving each chunk of data the S1V30120 responds with an ISC_BOOT_LOAD_RESP message
  • After the whole firmware file is loaded the host sends the ISC_BOOT_RUN_REQ message
  • S1V30120 responds with ISC_BOOT_RUN_RESP
  • If no error codes are received, we wait for about 150ms for the firmware file to execute
  • Now we can send again the ISC_VERSION_REQ message


Each message requires a special padding to flush the receive and the send channels. The normal padding requires the sending of 16 padding bytes, while the ISC_BOOT_RUN_RESP command requires only 8 padding bytes. The S1V30120 runs in full-duplex mode, so it can send data to the host while still receiving padding bytes. Considering that most messages issued by the S1V30120 are 6 bytes in length and they have to be followed by another 16 bytes padding, I made a simplifying assumption and I send the padding only for the received messages.

Each message consists on a message command (sending 0xAA over the SPI bus), followed by a four bytes header and the message payload. The first two bytes of the header are for the message length, and the last two bytes of the header are for the message code.

Main mode

Once the boot image is run, we go to the main mode. S1V30120 initialization must be performed before we are able to get any speech:

  • The S1V30120 must be registered with the host. To do this the host sends ISC_TEST_REQ message, and the S1V30120 responds with ISC_TEST_RESP.
  • Once again we send ISC_VERSION_REQ message
  • The S1V30120 responds with ISC_VERSION_RESP and we shall get the current firmware version and firmware features
  • Audio output settings are configured via an ISC_AUDIO_CONFIG_REQ message. The response is ISC_AUDIO_CONFIG_RESP
  • Audio volume is configured using ISC_AUDIO_VOLUME_REQ, the response being ISC_AUDIO_VOLUME_RESP
  • Text-To-Speech parameters are set via ISC_TTS_CONFIG_REQ, with the response being ISC_TTS_CONFIG_RESP


We also unmute the audio amplifier by setting the S1V30120_MUTE line low (in the Flip & Click this is pin 54).

Now we are ready to do some speaking. To speak we must send the text as a string, ending it with a null character. The command to speak some text is ISC_TTS_SPEAK_REQ, which gets an ISC_TTS_SPEAK_RESP mesage as response. Besides this acknowledging message, the text-to-speech click sends also some indication messages while it’s speaking. In particular the code is waiting for an indication of ISC_TTS_FINISHED_IND, which means that the text-to-speech has finished and it’s ready to receive a new text. In my code implementation this waiting loop is a blocking routine.
Text to speech Arduino code

And now we come to the code listings (the firmware image file is the one provided in MikroElektronika example):


Name

Air quality,2,Arduino code library,2,Arduino projects,23,Buggy,1,Casual stuff,1,ESP8266,2,MikroElektronika,3,PIC projects,7,Review,26,Robots,1,Tutorial,20,
ltr
item
Electronza: Arduino Due: S1V30120 text to speech
Arduino Due: S1V30120 text to speech
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3Y7Ihy_k-X5zJv21LJzhyxVFiBAQFwjEXZl9GhZIRk42DFicPqgdwbBmd9xlBk7sfFzEpUuyuVQBLziUZWWLyAXZk59TGYx-ZcEzou-8z8CT-snBuBedQAJkXf-zDivK8FgCxhgM1dBozrIdPl9j8xL-f-_IfFChs3KKu44JwPVKz0lVflTadY6DA/w640-h306/text-to-speech-due.jpg
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3Y7Ihy_k-X5zJv21LJzhyxVFiBAQFwjEXZl9GhZIRk42DFicPqgdwbBmd9xlBk7sfFzEpUuyuVQBLziUZWWLyAXZk59TGYx-ZcEzou-8z8CT-snBuBedQAJkXf-zDivK8FgCxhgM1dBozrIdPl9j8xL-f-_IfFChs3KKu44JwPVKz0lVflTadY6DA/s72-w640-c-h306/text-to-speech-due.jpg
Electronza
https://www.electronza.com/2016/07/arduino-due-s1v30120-text-to-speech.html
https://www.electronza.com/
https://www.electronza.com/
https://www.electronza.com/2016/07/arduino-due-s1v30120-text-to-speech.html
true
4275662725798500575
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content