报听写小程序

2023-01-11939
AI 快速预览详细 收起
本文介绍了如何使用掌控板和Gravity:中英文语音合成模块V2.0制作一个报听写小程序。该程序可以自动报读单词,帮助学生在家中完成听写任务。项目所需材料包括掌控板和语音合成模块。代码示例展示了如何设置语音合成参数并随机选择单词进行听写。总结部分提到制作简单,但使用较为复杂。

寒假已到,作业也一同来到。

最让我头疼的就是报听写:一个人在家,咋整?

于是,我就开始用压箱底的 语音合成&掌控版自己造一个报听写机器

 

材料清单

  • 掌控板 X1 链接
  • Gravity:中英文语音合成模块V2.0 X1 链接

代码如下

代码
/*!
 * MindPlus
 * mpython
 *
 */
#include <MPython.h>
#include <SimpleList.h>
#include <DFRobot_SpeechSynthesis_M.h>

// 动态变量
volatile float     mind_n_my_float_variable, mind_n_DanCi;
SimpleList<String> mind_l_DanCiBiao;
// 静态常量
const uint8_t imageMatrix[][350] = {
	{0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x80,0x0,0x0,0x0,0x0,0x0,0xf,0xc0,0x0,0x0,0x0,0x0,0x0,0x1f,0xe0,0x0,0x0,0x0,0x0,0x0,0x1f,0xf8,0x0,0x0,0x0,0x0,0x0,0x3f,0xf8,0x0,0x0,0x0,0x0,0x0,0x3f,0xf8,0x0,0x0,0x0,0x0,0x0,0x3f,0xf8,0x0,0x0,0x0,0x0,0x0,0x3f,0xf8,0x0,0x0,0x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xff,0xff,0xff,0xff,0xc0,0xff,0xfe,0xff,0xff,0xff,0xff,0xc0,0xff,0xfc,0xff,0xff,0xff,0xff,0xc0,0xff,0xfc,0xff,0xff,0xff,0xff,0xc0,0xff,0xf8,0xff,0xff,0xff,0xff,0xc0,0xff,0xf8,0xf,0xff,0xff,0xff,0xc0,0xff,0xc0,0x3,0xfe,0x1f,0xff,0xc0,0xff,0x80,0x1,0xf8,0xf,0xff,0xc0,0xff,0x80,0xf0,0xe3,0xf7,0xff,0xc0,0xff,0x0,0xfc,0xe7,0xff,0xff,0xc0,0xff,0x0,0x7f,0xff,0xff,0xff,0xc0,0xff,0x0,0x7f,0xff,0xff,0xff,0xc0,0xfe,0x0,0xfe,0xff,0xff,0xff,0xc0,0xfe,0x1,0x6,0x7e,0x3f,0xff,0xc0,0xfe,0x1,0xfe,0x7f,0xff,0xff,0xc0,0xfe,0x1,0xfe,0xff,0xff,0xff,0xc0,0xfe,0x1,0xfe,0xff,0xff,0xff,0xc0,0xff,0x1,0xfe,0xff,0xff,0xff,0xc0,0xff,0x1,0xfc,0xff,0xff,0xff,0xc0,0xff,0x1,0xfe,0xff,0xff,0xff,0xc0,0xff,0x0,0xf8,0x7f,0xff,0xff,0xc0,0xff,0x0,0x30,0x7f,0xff,0xff,0xc0,0xff,0x0,0x0,0x3f,0xff,0xff,0xc0,0xff,0x0,0x0,0xf,0xdf,0xff,0xc0,0xff,0x0,0x0,0xf,0x9f,0xff,0xc0,0xff,0x0,0x0,0x43,0x3f,0xff,0xc0,0xff,0x0,0x0,0xe0,0x7f,0xff,0xc0,0xff,0x80,0x1,0xf9,0xff,0xff,0xc0,0xff,0xc0,0x3,0xff,0xff,0xff,0xc0,0xff,0xc0,0x0,0x7f,0xff,0xff,0xc0,0xff,0xe0,0x0,0x1f,0xff,0xff,0xc0,0xff,0xf0,0x0,0x1f,0xff,0xff,0xc0,0xff,0xf0,0x2c,0x1f,0xff,0xff,0xc0,0xff,0xf8,0x1e,0x1f,0xff,0xff,0xc0,0xff,0xfc,0xe,0xf,0xff,0xff,0xc0,0xff,0xfe,0x0,0xf,0xff,0xff,0xc0,0xff,0xff,0x0,0xf,0xff,0xff,0xc0,0xff,0xff,0x80,0xf,0xff,0xff,0xc0,0xff,0xff,0xc0,0x1f,0xff,0xff,0xc0,0xff,0xff,0xc0,0x1f,0xff,0xff,0xc0,0xff,0xff,0xe0,0x1f,0xff,0xff,0xc0,0xff,0xff,0xf0,0x3f,0xff,0xff,0xc0,0xff,0xff,0xf8,0xff,0xff,0xff,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xc0},
	{0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xff,0xff,0xff,0xbf,0xff,0xff,0xc0,0xff,0xff,0xff,0xdb,0xff,0xff,0xc0,0xff,0xff,0xff,0xdb,0xff,0xff,0xc0,0xff,0xff,0xff,0xd3,0xff,0xff,0xc0,0xff,0xff,0xff,0xc7,0xff,0xff,0xc0,0xff,0xff,0xff,0xcf,0xff,0xff,0xc0,0xff,0xff,0xff,0xcb,0xff,0xff,0xc0,0xff,0xff,0xff,0xc7,0xff,0xff,0xc0,0xff,0xff,0xff,0xc7,0xff,0xff,0xc0,0xff,0xff,0xff,0xc3,0xff,0xff,0xc0,0xff,0xff,0xff,0x83,0xff,0xff,0xc0,0xff,0xff,0xff,0x3,0xff,0xff,0xc0,0xff,0xff,0xfe,0x3,0xff,0xff,0xc0,0xff,0xff,0xfc,0x3,0xff,0xff,0xc0,0xff,0xff,0xf8,0x3,0xff,0xff,0xc0,0xff,0xff,0xf8,0x3,0xff,0xff,0xc0,0xff,0xff,0xf0,0x3,0xff,0xff,0xc0,0xff,0xff,0xf0,0x7,0xff,0xff,0xc0,0xff,0xff,0xf0,0x7,0xff,0xff,0xc0,0xff,0xff,0xf0,0x7,0xff,0xff,0xc0,0xff,0xff,0xf0,0x7,0xff,0xff,0xc0,0xff,0xff,0xf8,0x7,0xff,0xff,0xc0,0xff,0xff,0xf0,0x7,0xff,0xff,0xc0,0xff,0xff,0xe0,0x7,0xff,0xff,0xc0,0xff,0xff,0xe0,0x5,0xff,0xff,0xc0,0xff,0xff,0xc0,0x18,0xff,0xff,0xc0,0xff,0xff,0xc0,0x0,0xff,0xff,0xc0,0xff,0xff,0x80,0x0,0xff,0xff,0xc0,0xff,0xff,0x80,0x0,0xff,0xff,0xc0,0xff,0xff,0xc0,0x0,0xff,0xff,0xc0,0xff,0xff,0xc0,0x1,0xff,0xff,0xc0,0xff,0xff,0xe0,0x1,0xff,0xff,0xc0,0xff,0xff,0xf0,0x1,0xff,0xff,0xc0,0xff,0xff,0xf0,0x87,0xff,0xff,0xc0,0xff,0xff,0xf8,0xe7,0xff,0xff,0xc0,0xff,0xff,0xfc,0x8f,0xff,0xff,0xc0,0xff,0xff,0xff,0xf,0xff,0xff,0xc0,0xff,0xff,0xff,0x8f,0xff,0xff,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xc0}
};
// 创建对象
DFRobot_SpeechSynthesis_UART sstts;


// 主程序开始
void setup() {
	mPython.begin();
	dfrobotRandomSeed();
	sstts.begin(sstts.eV2, &Serial1, P13, P14);
	mind_l_DanCiBiao.push_back("spring ");
	mind_l_DanCiBiao.push_back("summer");
	mind_l_DanCiBiao.push_back(" autumn");
	mind_l_DanCiBiao.push_back(" winter ");
	mind_l_DanCiBiao.push_back("windy ");
	mind_l_DanCiBiao.push_back(" warm");
	mind_l_DanCiBiao.push_back(" rain");
	mind_l_DanCiBiao.push_back(" snow ");
	mind_l_DanCiBiao.push_back("January");
	mind_l_DanCiBiao.push_back(" February");
	display.fillScreen(0);
	sstts.setVolume(10);
	sstts.setSpeed(4);
	sstts.setSoundType(sstts.eMale1);
	sstts.setTone(5);
	display.drawImage(0, 0, 50, 50, imageMatrix[0]);
	display.drawImage(43, 0, 50, 50, imageMatrix[1]);
	display.drawImage(84, 0, 50, 50, imageMatrix[2]);
	display.setCursorLine(2);
	display.printLine("Mind+");
	sstts.speak("正在载入");
	sstts.setEnglishPron(sstts.eWord);
	sstts.speak("听写程序已启动");
	mind_n_my_float_variable = 0;
	for (int index = 0; index < mind_l_DanCiBiao.size(); index++) {
		mind_n_my_float_variable += 1;
		mind_n_DanCi = (random(1, mind_l_DanCiBiao.size()+1));
		sstts.speak(mind_l_DanCiBiao[mind_n_DanCi-1]);
		delay(1000);
		sstts.speak(mind_l_DanCiBiao[mind_n_DanCi-1]);
		delay(1000);
		mind_l_DanCiBiao.remove(mind_n_DanCi-1);
		yield();
	}
	sstts.speak("听写完成");
	sstts.speak("请自行校对");
}
void loop() {

}

总结:制作简单,使用较复杂。

创作许可协议

本项目采用 None(不开放任何权利,保留所有权利) 进行许可。

所需材料/产品

加载全部

    掌控板2.0 编程入门学习主控板 - Python、图形化编程开发板

    掌控板2.0 编程入门学习主控板 - Python、图形化编程开发板

    掌控板2.0 编程入门学习主控板 - Python、图形化编程开发板

    Gravity:中英文语音合成模块V2.0 - 蘑菇云科创教育

    Gravity:中英文语音合成模块V2.0 - 蘑菇云科创教育

    Gravity:中英文语音合成模块V2.0 - 蘑菇云科创教育

相关推荐

评论(6)
空城旧梦1
空城旧梦1
有没有图形化的啊
rzyzzxw
rzyzzxw
很棒的
花生编程
花生编程
支持
花生编程
花生编程
厉害厉害
三春牛-创客
三春牛-创客
666
三春牛-创客
三春牛-创客
厉害了
- 没有更多了 -

创作许可协议

本项目采用 None(不开放任何权利,保留所有权利) 进行许可。

相关推荐

所需材料/产品

掌控板2.0 编程入门学习主控板 - Python、图形化编程开发板

掌控板2.0 编程入门学习主控板 - Python、图形化编程开发板

掌控板2.0 编程入门学习主控板 - Python、图形化编程开发板

Gravity:中英文语音合成模块V2.0 - 蘑菇云科创教育

Gravity:中英文语音合成模块V2.0 - 蘑菇云科创教育

Gravity:中英文语音合成模块V2.0 - 蘑菇云科创教育