回到首页 返回首页
回到顶部 回到顶部
返回上一页 返回上一页

报听写小程序 简单

头像 杨添淮 2023.01.11 779 6

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

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

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

 

材料清单

  • 掌控板 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,0x0,0x0,0x0,0x3f,0xf8,0x0,0x0,0x0,0x0,0x0,0x3f,0xf8,0x0,0x0,0x0,0x0,0x0,0x3f,0xf8,0x0,0x0,0x0,0x0,0x0,0x1f,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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() {

}

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

评论

user-avatar
  • 空城旧梦1

    空城旧梦12023.09.30

    有没有图形化的啊

    0
    • rzyzzxw

      rzyzzxw2023.01.16

      很棒的

      0
      • 花生编程

        花生编程2023.01.12

        支持

        0
        • 花生编程

          花生编程2023.01.12

          厉害厉害

          0
          • 三春牛-创客

            三春牛-创客2023.01.12

            666

            0
            • 三春牛-创客

              三春牛-创客2023.01.12

              厉害了

              0