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

38 lines
978 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
"""
from aip import AipSpeech
# 定义常量
APP_ID = '你的 AppID'
API_KEY = '你的 API Key'
SECRET_KEY = '你的 Secret Key'
# 准备【语音合成器】
client = AipSpeech(APP_ID, API_KEY, SECRET_KEY)
# 要合成的文本
text = "你好我是P仔很高兴认识你"
# 调用【语音合成器】
res = client.synthesis(text, 'zh', 1, {
'vol': 5, # 音量
'per': 0, # 发音人
'spd': 5 # 语速
})
print(res)
# 判断调用是否成功
if not isinstance(res, dict):
# 获取合成音频结果
with open('save.mp3', 'wb') as f:
f.write(res)
print('音频文件保存成功')
else:
print('调用失败, 错误码: %s, 错误信息: %s' % (res['err_no'], res['err_msg']))