python - 需要帮助将 Windows 通知转换为 python 中的文本转语音
问题描述
有什么方法可以获取通知示例的信息/文本,如果有通知,我希望能够将其作为字符串获取,以进一步使其成为文本到语音
解决方案
您可以使用 gtts 和 playsound 库创建一个 python 脚本来将文本转换为语音。
import gtts
from playsound import playsound #https://pypi.org/project/playsound/
#Load the string into gtts
tts = gtts.gTTS("STRINGTOCONVERTTOAUDIO")
filename = "audio.mp3"
#Remove the audio file if already exists
os.remove(filename)
# save the audio file to a convenient location...
tts.save(filename)
# play the audio file
playsound(filename)
然后,您可以在任何操作系统上的任何需要的地方调用此脚本/函数。
推荐阅读
- python - 按时间值升序对数据帧索引进行排序
- java - 当使用 Intent 时从 Java Activity 启动 Kotlin Activity 时,应用程序崩溃
- c++ - 将 std::decay 与 std::forward 一起使用
- python - Xpath selenium Python的双重条件
- c# - 我可以在 c# 中为 Realm 自定义 getter 和 setter 吗?
- c - C11 标准中的哪些规则决定了 `int tx = INT_MAX +1` 的评估?
- laravel - 如何通过一个表单提交插入多个数据 [ LARAVEL - Eloquent ]
- reactjs - 为什么在事件回调中偶尔会丢失按钮的值字段
- c# - 如何通过WPF中的TCPserver从客户端应用程序接收消息
- datetime - 日期和时间数据类型菜单在 Google 数据洞察中被禁用