import pyttsx3
engine =pyttsx5. init()
words ='要说的文字'
sentence='要翻译的话'
vioces='文字转语音'
engine. say( words)
engine. say( sentence)
engine. say( ‘测试语音’)
engine. runAndWait()
①明确目标 ②代码运行 ③选择开源项目 ④文档整理 ⑤硬件搭建 ⑥系统调试
import time
from pinpong.board import Board, Pin
Board("handpy"), begin()? # 初始化开源硬件
btn = Pin(Pin. D13, Pin.IN)
buzzer= Pin(Pin. D6, Pin.PWM)
while True:
v= btn.read digital() #读取引脚电平
print(v) # 终端打印读取的电平状态
buzzer.write analog(v) #将状态设置给引脚
time. sleep(0.2)