虚怀若谷 发表于 2024-4-22 13:50:22

行空板驱动的“大牙”乐观新闻播报器,融合ChatGPT技术

本帖最后由 虚怀若谷 于 2024-4-22 17:25 编辑

## 行空板驱动的“大牙”乐观新闻播报器,融合ChatGPT技术

这款名为行空板的小巧Debian Linux主板配备了一块集成触摸屏,被设计用于通过RSS源获取最新的新闻标题。

在播报新闻前,首先运用OpenAI的ChatGPT API对这些新闻标题进行重写,但加入了一个有趣的转折——要求ChatGPT以一种快乐、乐观的语调来重写这些标题。随后,该回应会被输入到Google翻译的文本转语音API中生成音频文件。生成的音频文件会借助蓝牙音箱播放出来。在音频播放的过程中,一个SG90伺服电机会驱动一套塑料仿真牙齿摆动,模拟开口闭合的动作,仿佛是在喜剧效果下朗读新闻标题。
## 材料清单
* (https://www.dfrobot.com.cn/goods-3404.html)
* (https://www.dfrobot.com.cn/goods-214.html)
* [蓝牙扬声器](https://www.amazon.com/CosyFame-Bluetooth-Speakers-Portable-Waterproof/dp/B0C4T8112G?crid=2S8CPR5FRQ7AP&keywords=bluetooth%2Bspeaker&qid=1692129868&refinements=p_36:1253503011&rnid=386442011&sprefix=bluetooth%2Bspeak,aps,240&sr=8-11&th=1&linkCode=sl1&tag=bloderonban-20&linkId=f4aaf95c5e4ebbcf7843cc16c992a247&language=en_US&ref_=as_li_ss_tl)
* [可选3D舵机支持](https://cults3d.com/en/3d-model/gadget/animatronic-mouth-with-sg90-and-a-toy-jaw)
* [塑料仿真牙齿](https://www.amazon.com/Dreidel-Company-Chomping-Chattering-Birthday/dp/B08BJDCD8N?crid=LWORI2C3YCMZ&keywords=chatter%2Bteeth&qid=1692129783&sprefix=chatter%2Bteeth%2Caps%2C246&sr=8-3&th=1&linkCode=sl1&tag=bloderonban-20&linkId=d72499082cde223bfc9d5dcab35b61ec&language=en_US&ref_=as_li_ss_tl)

此外,还配备了一些公对公跳线

![](https://files.mdnice.com/user/56048/b31f3ab1-8efa-4f4d-aa58-5759e0293928.png)
## 软件配置

1. 使用USBC电缆将行空板连接到 PC。
2. 在浏览器中加载10.1.2.3
3. 配置您的WiFi SSID和密码并获取行空板的IP
4. 现在打开Putty或其他SSH客户端,并使用 IP、用户 root 和密码 dfrobot连接到行空板。

5. 运行以下命令:
```
pip install reader
pip install openai
pip install gTTS
pip3 install simpleaudio
```


6. 访问OpenAI平台网站(<https://platform.openai.com/>),注册并获取API密钥。平台提供了免费试用额度,足够支撑数月内的本项目使用。

7. 登录OpenAI账户后,在“<https://platform.openai.com/account/api-keys/>”创建一个新的密钥,并将其安全保存。

8. 打开Yrigoyen.ino代码文件,将你的OpenAI API密钥填入指定位置:
   ```cpp
   openai.api_key = ""
   ```

4. 可根据需求编辑使用的OpenAI模型:
   ```cpp
   model_to_use = "text-davinci-003"
   ```
   
5. 设置转换提示信息:
   ```cpp
   prompt = "Rewrite this news headline with a joyful and optimistic tone:"
   ```

6. 设定RSS源地址:
   ```cpp
   feed_url = "https://www.cbsnews.com/latest/rss/main"
   ```

7. 使用FileZilla或其他FTP客户端,使用与SSH客户端相同的IP地址、用户名和密码进行连接。

8. 将`yrigoyen_en.py`和`background.png`文件上传至/home目录。

9. 开启蓝牙音箱。

10. 在终端中执行以下命令以配置蓝牙设备连接:
    ```
    bluetoothctl
    default-agent
    power on
    scan on
    pair
    trust xx:xx:xx:xx:xx:xx #(Device MAC ID)
    pair xx:xx:xx:xx:xx:xx#(Device ID)
    connect xx:xx:xx:xx:xx:xx #(Device ID)
    ```

11. 蓝牙配对只需要进行一次,之后设备将会自动重新连接。

![](https://files.mdnice.com/user/56048/60106534-6f5f-4e97-aaca-175af373aefa.png)


## 硬件配置部分:

要访问GPIO端口,请使用所提供的电缆之一。将该电缆连接到UNIHIKER侧面的D22引脚上。接下来,准备3根公对公跳线电缆,按正极(+)、负极(-)和信号顺序正确连接至伺服电机。

下载并打印伺服电机底座。

拆除塑料颌部的所有内部零件,然后将伺服电机的连杆粘接到颌部一侧。

## 软件部分:

从GitHub上的以下链接下载Python代码:
<https://github.com/ronibandini/yrigoyen>

![](https://files.mdnice.com/user/56048/5020f1f9-a0fd-4ff6-a410-9a5d77183287.png)

## 它是如何工作的


![](https://files.mdnice.com/user/56048/7d9240bc-6649-49a0-8d46-f388c6d84b1d.png)

现在一切都应该准备好了。返回 SSH 客户端并运行:

`/home python yrigoyen_en.py`





## 成果展示

https://www.youtube.com/watch?v=s045KdS1rB0

#### 原作者:RoniBandini
#### 上传时间:2023年8月24日
#### 原文链接:(https://community.dfrobot.com/makelog-313472.html)


shzrzxlee 发表于 2024-4-28 16:24:23

国外的openai注册不了,哪位老师有办法,分享一下,谢谢
页: [1]
查看完整版本: 行空板驱动的“大牙”乐观新闻播报器,融合ChatGPT技术