sairate d4c4cd1af9 feat(第7讲 字母卡牌): 实现记忆游戏并添加开始界面
- 新增 jiyi.py 文件,实现字母翻牌记忆游戏功能
- 添加 youxijiemian.py 文件,创建游戏开始界面
- 使用 turtle 和 tkinter 模块分别实现游戏和界面
- 支持选择不同难度的游戏模式
2025-07-09 15:01:12 +08:00

37 lines
982 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
》》》运行前必做《《《
1. 运行【安装第三方库.py】文件
2. 注册百度云账号获取API配置后查看完整效果
账号注册指南:
https://huewq7h021.feishu.cn/wiki/Ry3UwaoceiMRXgklbWtc9mEUn9f?from=from_copylink
"""
# pip install -i https://mirrors.aliyun.com/pypi/simple/ baidu-aip pyaudio keyboard chardet
from aip import AipSpeech
# 定义常量
APP_ID = '117920031'
API_KEY = '4icZSO1OlMCU2ZiRMhgGCXFu'
SECRET_KEY = '6wJldJ08m1jIX9hb0ULcJrIJ9D1OJW3c'
# 准备【语音识别器】
client = AipSpeech(APP_ID, API_KEY, SECRET_KEY)
# 定义要识别的语音文件
file = 'pyaudio.wav'
# 读取音频文件
def read_audio(file):
with open(file, 'rb') as f:
return f.read()
# 调用【语音识别器】
res = client.asr(read_audio(file), 'wav', 16000, {
'dev_pid': 1537 # 普通话识别
})
# 打印返回结果
if 'result' in res:
print("识别结果:", res['result'][0])
else:
print("识别失败:", res)