一、项目背景
二十四节气是中国古代农业文明的产物,
是古人通过观察自然界的气候变化现象总结出来的一套时间知识体系,
它反映了一年四季气温、降水等的变化,是中国古代农业社会的时间指南。
利用AIGC(人工智能生成内容)技术,分享一个作品
《AIGC2024——二十四节气之秋》,
实现了软件与硬件之间的互动与协同工作。
很高兴参加“造物记AIGC技术入门&应用挑战赛”,
感谢蘑菇云提供这么好的一个平台。
二、项目设计
我们将利用图形化编程工具Mind+,结合Kimi文字生成,Hidream.ai的文生图技术,以及TTSMaker的文字转语音服务,让孩子认识秋天的六个节气,学习地理知识,这是一个富有教育意义的项目。
1.Kimi实现 二十四节气之秋的6个节气分镜文字生成;
2.Hidream.ai实现 将立秋、处暑、白露、秋分、寒露、霜降等文字生成图片;
3.TTSMaker实现二十四节气文本转换为语音;
4.removed对节气关键字消除艺术字背景;
5.Mind+中发送数据的实时模块,语音控制展示二十四节气内容。
项目工作过程:
在上传模式下,一旦我们发送特定的节气信息,该信息即被语音合成模块迅速接收。随后,模块将节气信息转换为对应数字编号,并实时将这一数据通过数据线推送给Mind+实时接受端。另一边,Mind+在实时模式下一旦接收到这些数据,便立即触发角色小麦,使其能够即时播放相匹配的节气画面与音频信息。这一过程完美实现了软件与硬件之间的互动与协同工作。
三、AIGC技术搜集相关素材
1、二十四节气分镜文本生成
打开Kimi,搜索框输入:介绍二十四节气——秋,对每个主题生成分镜文字;
将生成对应节气文字,复制粘贴电脑上备用。
2、二十四节气的分镜图片生成
2.打开Hidream网站,www.hidreamai.com/img
将立秋、处暑、白露、秋分、寒露、霜降等文字复制AI生成框中,图片尺寸:4:3,自动生成对应4张图片;
3.语音合成
TTSMaker(马克配音)是一款免费的文本转语音工具,提供语音合成服务,支持多种语言,以及超过300种语音风格。
将节气文字信息复制到配音栏里,选择潇潇女声播放,输入验证码,开始转换对应音频文件。
4.消除艺术字背景
四、Mind+编写
1. 发送语音端
步骤1 打开Mind+,通过数据线连接microbit和计算机,选择右上角上传模式
步骤2 扩展模块中,添加microbit ;物联网扩展板;语音合成模块,发送数据实时模块
步骤3 发送数据实时程序
/*!
* MindPlus
* microbit
*
*/
#include <DFRobot_ASR_M.h>
#include <Microbit_Matrix.h>
#include <DFRobot_SerialPort.h>
#include <DFRobot_SSD1306_I2C.h>
// 动态变量
volatile float mind_n_ZhiLing;
// 静态常量
const uint8_t bbcBitmap[][5] = {
{B01010,B10101,B10001,B01010,B00100},
{B00000,B01010,B01110,B00100,B00000},
{B01100,B00100,B00100,B00100,B11111},
{B11111,B00001,B11111,B10000,B11111},
{B11111,B00001,B11111,B00001,B11111},
{B00110,B01010,B10010,B11111,B00010},
{B11111,B10000,B11111,B00001,B11111},
{B11111,B10000,B11111,B10001,B11111},
{B11111,B10001,B10001,B10001,B11111}
};
const chCode chBuf[] = {
{0x7acb,0xe7ab8b,0xC1A2,{0x02,0x00,0x01,0x00,0x01,0x00,0x00,0x00,0x7f,0xfc,0x00,0x00,0x00,0x10,0x10,0x10,0x08,0x20,0x08,0x20,0x04,0x40,0x04,0x40,0x04,0x80,0x00,0x00,0xff,0xfe,0x00,0x00}},
{0x79cb,0xe7a78b,0xC7EF,{0x08,0x40,0x1c,0x40,0xf0,0x40,0x10,0x40,0x11,0x44,0xfd,0x44,0x11,0x48,0x32,0x50,0x38,0x40,0x54,0xa0,0x54,0xa0,0x90,0x90,0x11,0x10,0x11,0x08,0x12,0x04,0x14,0x02}},
{0x5904,0xe5a484,0xB4A6,{0x10,0x40,0x10,0x40,0x10,0x40,0x1e,0x40,0x12,0x60,0x22,0x50,0x22,0x48,0x52,0x44,0x94,0x44,0x14,0x40,0x08,0x40,0x08,0x40,0x14,0x40,0x23,0x00,0x40,0xfe,0x80,0x00}},
{0x6691,0xe69a91,0xCAEE,{0x1f,0xf0,0x10,0x10,0x1f,0xf0,0x10,0x10,0x1f,0xf0,0x02,0x00,0x1f,0xd0,0x02,0x20,0xff,0xfe,0x03,0x00,0x0f,0xf0,0x38,0x10,0xcf,0xf0,0x08,0x10,0x0f,0xf0,0x08,0x10}},
{0x767d,0xe799bd,0xB0D7,{0x01,0x00,0x02,0x00,0x04,0x00,0x3f,0xf8,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x3f,0xf8,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x3f,0xf8,0x20,0x08}},
{0x9732,0xe99cb2,0xC2B6,{0x3f,0xf8,0x01,0x00,0x7f,0xfe,0x41,0x02,0x9d,0x74,0x01,0x00,0x1d,0x70,0x00,0x40,0x7c,0xf8,0x45,0x48,0x7c,0x30,0x11,0xce,0x5c,0x00,0x50,0xf8,0x5c,0x88,0xe0,0xf8}},
{0x5206,0xe58886,0xB7D6,{0x00,0x40,0x04,0x40,0x04,0x20,0x08,0x20,0x10,0x10,0x20,0x08,0x40,0x04,0x9f,0xe2,0x04,0x20,0x04,0x20,0x04,0x20,0x08,0x20,0x08,0x20,0x10,0x20,0x21,0x40,0x40,0x80}},
{0x5bd2,0xe5af92,0xBAAE,{0x02,0x00,0x01,0x00,0x7f,0xfe,0x44,0x42,0x9f,0xf4,0x04,0x40,0x3f,0xf8,0x04,0x40,0xff,0xfe,0x08,0x20,0x13,0x10,0x20,0x88,0xc0,0x46,0x06,0x00,0x01,0x80,0x00,0x40}},
{0x971c,0xe99c9c,0xCBAA,{0x3f,0xf8,0x01,0x00,0x7f,0xfe,0x41,0x02,0x9d,0x74,0x01,0x00,0x1d,0x70,0x00,0x00,0x08,0xfc,0x7e,0x84,0x18,0xfc,0x2c,0x84,0x4a,0xfc,0x88,0x84,0x08,0xfc,0x08,0x84}},
{0x964d,0xe9998d,0xBDB5,{0x00,0x80,0x7c,0x80,0x44,0xfc,0x49,0x08,0x4a,0x90,0x50,0x60,0x49,0x98,0x4e,0x26,0x44,0x20,0x45,0xfc,0x44,0x20,0x6a,0x20,0x53,0xfe,0x40,0x20,0x40,0x20,0x40,0x20}},
{0x89e3,0xe8a7a3,0xBDE2,{0x10,0x00,0x10,0xfc,0x3c,0x24,0x24,0x24,0x48,0x54,0xbe,0x88,0x2a,0x10,0x2a,0x50,0x3e,0x7c,0x2a,0x90,0x2a,0x10,0x3e,0xfe,0x2a,0x10,0x4a,0x10,0x42,0x10,0x86,0x10}},
{0x8bfb,0xe8afbb,0xB6C1,{0x00,0x20,0x20,0x20,0x11,0xfc,0x10,0x20,0x00,0x20,0x03,0xfe,0xf0,0x02,0x10,0x94,0x10,0x50,0x11,0x10,0x10,0x90,0x13,0xfe,0x14,0x28,0x18,0x44,0x10,0x82,0x03,0x02}},
{0x4e8c,0xe4ba8c,0xB6FE,{0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xfe,0x00,0x00,0x00,0x00,0x00,0x00}},
{0x5341,0xe58d81,0xCAAE,{0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0xff,0xfe,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00}},
{0x56db,0xe59b9b,0xCBC4,{0x00,0x00,0x00,0x00,0x7f,0xfc,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x48,0x44,0x48,0x3c,0x50,0x04,0x60,0x04,0x40,0x04,0x7f,0xfc,0x40,0x04,0x00,0x00}},
{0x8282,0xe88a82,0xBDDA,{0x08,0x20,0x08,0x20,0xff,0xfe,0x08,0x20,0x08,0x20,0x00,0x00,0x7f,0xf8,0x02,0x08,0x02,0x08,0x02,0x08,0x02,0x08,0x02,0x50,0x02,0x20,0x02,0x00,0x02,0x00,0x02,0x00}},
{0x6c14,0xe6b094,0xC6F8,{0x10,0x00,0x10,0x00,0x3f,0xfc,0x20,0x00,0x4f,0xf0,0x80,0x00,0x3f,0xf0,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x0a,0x00,0x0a,0x00,0x06,0x00,0x02}}
};
// 创建对象
DFRobot_SSD1306_I2C oled12864;
DFRobot_ASR asr;
DFRobot_SerialPort serialport;
// 主程序开始
void setup() {
oled12864.begin(0x3c);
oled12864.setChCode(chBuf);
oled12864.setCursor(42, 22);
oled12864.print("Mind+");
MMatrix.show(bbcBitmap[0]);
delay(1000);
MMatrix.show(bbcBitmap[1]);
delay(1000);
MMatrix.show(bbcBitmap[0]);
asr.begin(LOOP, MIC);
Serial.begin(9600);
asr.addCommand("li qiu", 1);
asr.addCommand("chu shu", 2);
asr.addCommand("bai lu", 3);
asr.addCommand("qiu fen", 4);
asr.addCommand("han lu", 5);
asr.addCommand("shuang jiang", 6);
asr.start();
}
void loop() {
mind_n_ZhiLing = asr.read();
delay(100);
if ((mind_n_ZhiLing>0)) {
if ((mind_n_ZhiLing==1)) {
serialport.writeData("message", String("1"));
MMatrix.show(bbcBitmap[2]);
oled12864.fillScreen(0);
oled12864.setCursor(42, 22);
oled12864.print("立秋");
}
if ((mind_n_ZhiLing==2)) {
serialport.writeData("message", String("2"));
MMatrix.show(bbcBitmap[3]);
oled12864.fillScreen(0);
oled12864.setCursor(42, 22);
oled12864.print("处暑");
}
if ((mind_n_ZhiLing==3)) {
serialport.writeData("message", String("3"));
MMatrix.show(bbcBitmap[4]);
oled12864.fillScreen(0);
oled12864.setCursor(42, 22);
oled12864.print("白露");
}
if ((mind_n_ZhiLing==4)) {
serialport.writeData("message", String("4"));
MMatrix.show(bbcBitmap[5]);
oled12864.fillScreen(0);
oled12864.setCursor(42, 22);
oled12864.print("秋分");
mind_n_ZhiLing = 0;
}
if ((mind_n_ZhiLing==5)) {
serialport.writeData("message", String("5"));
MMatrix.show(bbcBitmap[6]);
oled12864.fillScreen(0);
oled12864.setCursor(42, 22);
oled12864.print("寒露");
}
if ((mind_n_ZhiLing==6)) {
serialport.writeData("message", String("6"));
MMatrix.show(bbcBitmap[7]);
oled12864.fillScreen(0);
oled12864.setCursor(42, 22);
oled12864.print("霜降");
}
}
else {
serialport.writeData("message", String("0"));
MMatrix.show(bbcBitmap[8]);
oled12864.fillScreen(0);
oled12864.setCursorLine(1);
oled12864.printLine("AIGC2024");
oled12864.setCursor(0, 22);
oled12864.print("解读二十四节气");
}
}
2.接受语音端
步骤4 打开Mind+,选择右上角实时模式
步骤5 点击”扩展”,在”功能模块”下点击添加“接收上传模式数据”扩展模块。
步骤6 添加角色和背景
添加节气文字角色
添节气图片背景
添加节气音频
步骤7 在”功能模块“分类下,点击感叹号,实时模式连接上传模式。
接收上传模式数据窗口出现,点击连接。成功连接上传模式后原功能模块指令处感叹号会变成绿色的对勾(如下图)
步骤8 编写程序
1.Mind+角色脚本
2.立秋脚本
3.处暑脚本
4.白露脚本
5. 秋分脚本
6.寒露脚本
7.霜降脚本
五、AIGC
AIGC,全称Artificial Intelligence Generated Content,即人工智能生成内容。这是指利用人工智能技术来创作生成文本、图像、音频、视频、游戏等不同形式内容的过程。
风隐2024.10.15
666
罗罗罗2024.10.12
666