- 新增 jiyi.py 文件,实现字母翻牌记忆游戏功能 - 添加 youxijiemian.py 文件,创建游戏开始界面 - 使用 turtle 和 tkinter 模块分别实现游戏和界面 - 支持选择不同难度的游戏模式
37 lines
982 B
Python
37 lines
982 B
Python
"""
|
||
》》》运行前必做《《《
|
||
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)
|