python - 运行函数 pyttsx3 文本到语音导致应用程序关闭
问题描述
每次将意大利语单词插入列表框时,我都会运行文本到语音功能。在发音所有单词后,有时 python 脚本会失败。有时在发音所有单词后,所有插入列表框的操作都完成了,没有任何失败。由于单词是通过循环插入到列表框中的,因此人们会期望单词后面跟着它的发音,因为每个单词都会调用parla_italiano() 。但似乎该函数正在持有另一个 python 线程。我还没有使用过线程。有没有办法在发音后释放这个功能,并允许单词插入到列表框中?我在 windows10 上使用 python 3.9
def parla_italiano(phrase):
import pyttsx3
engine = pyttsx3.init()
it_voice_id = r"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\Voices\Tokens\TTS_MS_IT-IT_ELSA_11.0"
engine.setProperty('voice', it_voice_id)
engine.say(phrase)
engine.runAndWait()
这是错误消息:
Fatal Python error: PyEval_RestoreThread: the function must be called with the GIL held, but the GIL is released (the current Python thread state is NULL)
Python runtime state: initialized
解决方案
推荐阅读
- javascript - 淘汰赛Js模板不显示数据
- php - 在 Ubuntu 终端中运行“php artisan migrate”返回错误
- java - 在 Katalon-Studio 中使用 Firebase SDK
- java - Test for any related rows in PostgreSQL
- sql-server - 如何使用 Visual Studio 中的 DACPAC 部署具有不同架构的对象
- c# - 共享主机上 php 中的 MQTT
- sql-server - Visual Studio 2015 工具 SQL Server 架构比较不适用于 SQL Server 2017
- javascript - Vis.js/React/JavaScript:渲染 Vis.timeline
- android - 安装时将图像存储在应用程序数据文件夹中
- authentication - 通过 ssh 而没有 root 编辑数据库的用户权限