Gravity: Speech Synthesis Module V2 English/Chinese CSK4002 Wiki - DFRobot

Introduction

Would you like to add voice to your projects? Connect up this Speech Synthesis module, add few couples of lines of code, then here goes, your project starts speaking. Both Chinese and English are "so easy" for this speech synthesis module. It also can broadcast the current time and environment data. Combining with a speech recognition module, you can easily have conversations with your projects! The module uses I2C and UART two communication modes, gravity interface, and is compatible with most main-controllers on the market. Besides, the module already comes with a speaker, so you don't need to buy one.

Note: the addresses of the speech synthesis module and micro: bit motor driver board are the same, so they cannot be used together.

V2.0 Function Updates:

  1. More natural pronunciation
  2. Fewer pronunciation errors for polyphone characters
  3. No option of speakers

Features

Application

Specification

Board Overview

Board Overview

Num Label Description
1 D/T I2C data line/TX
2 C/T I2C clock line/RX
3 GND -
4 VCC +
5 AOP Audio Output Positive
6 AON Audio Output Negative

Tutorial

Requirements

Connection Diagram

Connection

/**
   *  @brief Speech Synthesis function 
   *  @param word Content to be synthesized, it can be Chinese, English, number, etc. 
   */
  void speak(String word);

  /**
   *  @brief Set voice volume 
   *  @param voc, Volume value(0-9)
   */
  void setVolume(uint8_t voc);

  /**
   *  @brief Set playback speed 
   *  @param speed, speed value (0-9)
   */
  void setSpeed(uint8_t speed);

  /**
   *  @brief Set tone 
   *  @param tone, tone value(0-9)
  */
  void setTone(uint8_t tone);

  /**
   *  @brief Set English Pronounce mode 
   *  @param pron(eAlphabet: letter, eWord: word)
   */
  void setEnglishPron(eENpron_t pron);

Sample Code 1- Speech Synthesis via I2C

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

/*!
 * @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](li.feng@dfrobot.com)
 * @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"));
}

Sample Code 2- Speech Synthesis via UART

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

/*!
 * @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](li.feng@dfrobot.com)
 * @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"));
}

This speech synthesis module supports multiple text control identifiers that allow users to set voice speaker, volume, speed, and intonation, etc. Identifiers are only used as control flags to realize function setting, and will not be synthesized into sound output. For instance, "[S1]I talk slowly. [S8] I talk fast", after setting the identifiers, the former sentence will be read very slowly while the latter one will be spoken very fast, but "S1" and "S8" will not be read out.

Note: these identifieres are global control identifiers, which means that they only need to be set for once. When the chip is not reset, or powered off, or using [D] to restore the default setting, all texts sent to the chip will be under their control.

Control Identifiers

FAQ

For any questions, advice or cool ideas to share, please visit the DFRobot Forum.

More Documents