SYN6288 Speech Synthesis Broadcast Module
The SYN6288E Chinese speech synthesis chip is a mid-to-high-end speech synthesis chip with more natural effects, launched by Beijing Yuantian Technology Co., Ltd. in early 2010, based on the more cost-effective SYN6288 chip with a modified package. The SYN6288E receives text data to be synthesized through an asynchronous serial port (UART) communication method, realizing the conversion of text to speech (or TTS speech).
Module Source
Purchase link: https://item.taobao.com/item.htm?spm=a230r.1.14.41.7bb74e15T8dQgB&id=633248893415&ns=1&abbucket=12
Other links for the same module:
https://detail.tmall.com/item.htm?abbucket=0&id=636100867675&ns=1&spm=a21n57.1.0.0.acc5523cluUkQ0
Materials download: https://pan.baidu.com/s/1Kb8RA9aksd3o8Q-A8WqmNA Extraction code: 1234
Specifications
Input voltage: 2.4V~5.1V Rated current: 2.0uA~280mA Control method: Serial port
View Materials
For voice broadcast control, as long as the serial port is configured, and data is sent according to the command frame format required by the data manual, the broadcast function can be realized.
Note! This module can only perform voice broadcast and does not have voice recognition capabilities! It also cannot record.
Porting Process
Pin Selection
Port to Project
Our goal is to port the example to the ESP32-S3 dev board. Complete driver code has been provided for you. Follow the steps below to complete the porting. For detailed instructions on creating folders and new .c and .h files, refer to section 1.4.2 in the [DHT11 Temperature and Humidity Sensor] chapter; we will not repeat it here. Just note that here we change the file names bsp_dht11.c and bsp_dht11.h to bsp_syn6288.c and bsp_syn6288.h, and the folder name to SYN6288.
Write Code
In the file bsp_syn6288.c, write the following code.
/*
* LCSC-Openkits (LCKFB) software and hardware materials and related expansion board software and hardware materials are all open source on the official website.
* Dev board official website: www.lckfb.com
* Technical support resides on the forum; any technical questions are welcome for exchange and learning at any time.
* LCKFB Forum: club.szlcsc.com
* Follow our Bilibili account: [LCSC-Openkits (LCKFB)] to keep up with our latest updates!
* We do not make money by selling boards; we take cultivating engineers as our mission.
* Change Logs:
* Date Author Notes
* 2024-01-16 LCKFB-lp first version
*/
#include "bsp_syn6288.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#define SYN6288RX_LEN_MAX 255
unsigned char SYN6288RX_BUFF[SYN6288RX_LEN_MAX];
unsigned char SYN6288RX_LEN = 0;
void delay_ms(unsigned int ms)
{
vTaskDelay(ms / portTICK_PERIOD_MS);
}
void delay_us(unsigned int us)
{
ets_delay_us(us);
}
void delay_1ms(unsigned int ms)
{
vTaskDelay(ms / portTICK_PERIOD_MS);
}
void delay_1us(unsigned int us)
{
ets_delay_us(us);
}
/******************************************************************
* Function Name: SYN6288_GPIO_Init
* Function Description: SYN6288 pin initialization
* Function Parameters: band_rate GPS communication baud rate
* Function Return: None
* Author: LC
* Notes: Default baud rate is 9600
******************************************************************/
void SYN6288_GPIO_Init(uint32_t band_rate)
{
//Define the serial port configuration structure, must be assigned initial values, otherwise it cannot be implemented
uart_config_t uart_config={0};
uart_config.baud_rate = band_rate; //Configure baud rate
uart_config.data_bits = UART_DATA_8_BITS; //Configure data bits to 8 bits
uart_config.parity = UART_PARITY_DISABLE; //Configure parity check as not required
uart_config.stop_bits = UART_STOP_BITS_1; //Configure stop bit as one bit
uart_config.flow_ctrl = UART_HW_FLOWCTRL_DISABLE; //Disable hardware flow control
//Load the above parameters
uart_param_config(BSP_SYN6288_USART, &uart_config);
//Bind pins TX RX RTS=not used CTS=not used
uart_set_pin(BSP_SYN6288_USART, BSP_SYN6288_TX_PIN, BSP_SYN6288_RX_PIN, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
//Install serial port driver
uart_driver_install(BSP_SYN6288_USART, SYN6288RX_LEN_MAX-1, SYN6288RX_LEN_MAX-1, 0, NULL, 0);
//Create serial port 2 receive task
xTaskCreate(BSP_SYN6288_Handler, "BSP_SYN6288_Handler", 1024*2, NULL, configMAX_PRIORITIES, NULL);
}
/******************************************************************
* Function Name: SYN6288_Send_Bit
* Function Description: Send a single character to SYN6288
* Function Parameters: ch character to send
* Function Return: None
* Author: LC
* Notes: None
******************************************************************/
void SYN6288_Send_Bit(unsigned char ch)
{
uart_write_bytes(BSP_SYN6288_USART, (const char*)&ch, 1);
}
/******************************************************************
* Function Name: SYN6288_send_String
* Function Description: SYN6288 send string
* Function Parameters: str string to send
* Function Return: None
* Author: LC
* Notes: None
******************************************************************/
void SYN6288_send_String(unsigned char *str)
{
uart_write_bytes(BSP_SYN6288_USART, (const char*)str, strlen( (const char*)str ));
}
//Get the data received by serial port
unsigned char *Get_SYN6288RX_BUFF(void)
{
return SYN6288RX_BUFF;
}
//Clear the data received by serial port
void Clear_SYN6288RX_BUFF(void)
{
//UART ring buffer flush. Discards all data in the UART RX buffer, ready for next reception
uart_flush(BSP_SYN6288_USART);
SYN6288RX_LEN = 0;
}
/************************************************************
* Function Name: SYN6288_Send_Cmd
* Function Description: Send command to SYN6288
* Parameters:
* [CmdType=Command word] Available parameters:
* 0x01 Speech synthesis command
* 0x31 Set baud rate (default 9600)
* 0x02 Stop synthesis command
* 0x03 Pause synthesis command
* 0x04 Resume synthesis command
* 0x21 Chip status query command
* 0x88 Chip enters low power mode
* [CmdPar=Command parameter] Available parameters:
* When the decimal value of the upper 5 bits of the byte is 0, it means no background music is added
* When the decimal value of the upper 5 bits of the byte is 1~15, it represents the number of the selected background music
* When the decimal value of the lower 3 bits of the byte is 0~3, and the command word is speech synthesis command, it respectively represents setting the text to GB2312 format, GBK format, BIG5 format, UNICODE format;
* When the decimal value of the lower 3 bits of the byte is 0~2, and the command word is set baud rate, it respectively represents setting the baud rate to 9600, 19200, 38400;
* [text=Text to broadcast]
* Return value: 0=Send successfully
* Notes:
* When a control command frame is received, the chip will send a 1-byte status return to the host computer, and the host computer can judge the current working status of the chip based on this return
* Initialization successful return 0X4A
* Correct command frame received return 0x41
* Unrecognized command frame received return 0x45
* Chip broadcasting status return 0x4E
* Chip idle status return 0x4F
*************************************************************/
unsigned char SYN6288_Send_Cmd(uint8_t CmdType, uint8_t CmdPar, uint8_t *text)
{
unsigned char frame_header = 0XFD; //Frame header
unsigned int Text_Len = strlen((const char*)text);//Length of text to send
unsigned int Data_Len = Text_Len + 3; //Data area length; 3=frame header, frame tail and XOR check
unsigned char Xor_Check = 0; //XOR check storage
unsigned char Send_Buff[210]; //Command frame to send, max 206 bytes
uint8_t i = 0;
Send_Buff[0] = frame_header; //Frame header
Send_Buff[1] = Data_Len>>8; //High bit first
Send_Buff[2] = Data_Len&0x00ff; //Low bit first
Send_Buff[3] = CmdType; //Command word
Send_Buff[4] = CmdPar; //Command data
sprintf((char*)Send_Buff+5, "%s", text );
//Send data
for( i = 0; i < Text_Len+5; i++ )
{
Xor_Check = Xor_Check ^ Send_Buff[i];//Perform XOR check on each data and save
SYN6288_Send_Bit( Send_Buff[i] );//Send data
}
SYN6288_Send_Bit( Xor_Check );//Send the last bit: XOR check data
return 0;
}
/******************************************************************
* Function Name: BSP_SYN6288_Handler
* Function Description:
* Function Parameters: None
* Function Return: None
* Author: LC
* Notes: None
******************************************************************/
void BSP_SYN6288_Handler(void)
{
while(1)
{
SYN6288RX_LEN = uart_read_bytes(BSP_SYN6288_USART, SYN6288RX_BUFF, SYN6288RX_LEN_MAX - 1, 100 / portTICK_PERIOD_MS);
if( SYN6288RX_LEN > 0 && SYN6288RX_LEN == 0)//If data length is greater than 0, data has been received
{
SYN6288RX_BUFF[SYN6288RX_LEN] = '\0';//Set the last bit of serial port data to 0 to form a string
}
delay_ms(100);
}
}2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
In the file bsp_syn6288.h, write the following code.
/*
* LCSC-Openkits (LCKFB) software and hardware materials and related expansion board software and hardware materials are all open source on the official website.
* Dev board official website: www.lckfb.com
* Technical support resides on the forum; any technical questions are welcome for exchange and learning at any time.
* LCKFB Forum: club.szlcsc.com
* Follow our Bilibili account: [LCSC-Openkits (LCKFB)] to keep up with our latest updates!
* We do not make money by selling boards; we take cultivating engineers as our mission.
* Change Logs:
* Date Author Notes
* 2024-01-16 LCKFB-lp first version
*/
#ifndef _BSP_SYN6288_H
#define _BSP_SYN6288_H
#include <stdio.h>
#include "esp_log.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/uart.h"
#include "driver/gpio.h"
#include "driver/i2c.h"
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_log.h"
#include "freertos/queue.h"
#include <inttypes.h>
#include "sdkconfig.h"
#include "driver/gpio.h"
#include "esp_log.h"
#include "rom/ets_sys.h"
#include "esp_system.h"
#include "driver/gpio.h"
#include "driver/spi_master.h"
#include "driver/spi_common.h"
#include "hal/gpio_types.h"
#include "driver/ledc.h"
#include "driver/mcpwm.h"
#include "esp_adc/adc_cali_scheme.h"
#include "esp_adc/adc_cali.h"
#include "driver/adc.h"
#include "esp_adc_cal.h"
#include "string.h"
#define BSP_SYN6288_TX_PIN 1 // Serial port TX pin
#define BSP_SYN6288_RX_PIN 2 // Serial port RX pin
#define BSP_SYN6288_USART UART_NUM_2 // Serial port 2
void SYN6288_GPIO_Init(uint32_t band_rate);
unsigned char SYN6288_Send_Cmd(uint8_t CmdType, uint8_t CmdPar, uint8_t *text);
void BSP_SYN6288_Handler(void);
#endif2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Porting Verification
In the main function of your project, write the following code.
/*
* LCSC-Openkits (LCKFB) software and hardware materials and related expansion board software and hardware materials are all open source on the official website.
* Dev board official website: www.lckfb.com
* Technical support resides on the forum; any technical questions are welcome for exchange and learning at any time.
* LCKFB Forum: club.szlcsc.com
* Follow our Bilibili account: [LCSC-Openkits (LCKFB)] to keep up with our latest updates!
* We do not make money by selling boards; we take cultivating engineers as our mission.
* Change Logs:
* Date Author Notes
* 2024-01-16 LCKFB-lp first version
*/
#include <stdio.h>
#include "bsp_syn6288.h"
#include "string.h"
#include "esp_private/esp_task_wdt.h"
#include "esp_private/esp_task_wdt_impl.h"
int app_main(void)
{
esp_task_wdt_deinit();
SYN6288_GPIO_Init(9600);
printf("Start.......\r\n");
vTaskDelay(1000 / portTICK_PERIOD_MS);
SYN6288_Send_Cmd(0x01,0x00,(uint8_t *)"LCKFB");
while(1)
{
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
}2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Driver code:
File Download
📌 Materials Download Center (Click to Jump)
📌 In the Materials Download Center -> Module Porting Materials Download, inside the compressed package of this chapter.