Example Code for Arduino-Speech Synthesis via UART

Last revision 2025/12/03

The module repeatedly reads out the synthesised speech (Dial the switch to UART). It is recommended to use hardware serial port for stable communication.

Hardware Preparation

  • DFRduino UNO R3 (or similar) x 1
  • Gravity: Speech Synthesis module V2.0(Support English and Chinese) x1
  • Jumper wires

Software Preparation

Wiring Diagram

Connection

Other Preparation Work

Dial the switch to UART.

Sample Code

/*!
 * @file uart.ino
 * @brief Control speech synthesis sensor via UART, and synthetise speech
 * @details phenomena£ºthe speaker of the module plays English on a loop
 * @copyright   Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
 * @License     The MIT License (MIT)
 * @author [fengli]([email protected])
 * @version  V1.0
 * @date  2020-11-6
 * @url https://github.com/DFRobot/DFRobot_SpeechSynthesis_V2
 */
#include "DFRobot_SpeechSynthesis_V2.h"
#include <SoftwareSerial.h>
SoftwareSerial ssSerial1(2, 3);  //RX, TX
DFRobot_SpeechSynthesis_UART ss;

void setup() {
  ssSerial1.begin(115200);
  //Init speech synthesis sensor
  ss.begin(ssSerial1);
  
  //Set voice volume to 5
  //ss.setVolume(5);
  //Set playback speed to 5
  //ss.setSpeed(5);
  //Set tone to 5
  //ss.setTone(5);
  //For English, speak word 
  //ss.setEnglishPron(ss.eWord);
}

void loop() {
  ss.speak(F("She sells seashells by the seashore"));
  ss.speak(F("Hello, I'm Speech Synthesis module"));
  ss.speak(F("a b c d e f g"));

  /*Use text control identifier*/
  //Voice volume identifier 
  //ss.speak(F("[v3]Hello [v8]world"));
  //Word Pronounce mode identifier
  //ss.speak(F("[h1]Hello [h2]world"));
}

Result

The speaker of the module plays English on a loop.

Was this article helpful?

TOP