Example Code for Arduino-Speech Synthesis via I2C

Last revision 2025/12/03

The module repeatedly reads out the synthesised speech (Dial the switch to I2C).

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 I2C.

Sample Code

/*!
 * @file i2c.ino
 * @brief Control speech synthesis sensor via I2C, 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"
DFRobot_SpeechSynthesis_I2C ss;
void setup() {
  //Init speech synthesis sensor
  ss.begin();
  //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