Unknown module(s) in QT: texttospeech

发布于:2024-06-06 ⋅ 阅读:(156) ⋅ 点赞:(0)

前些天发现了一个巨牛的人工智能学习网站,通俗易懂,风趣幽默,忍不住分享一下给大家。点击跳转到网站:前言 – 人工智能教程

组件安装 MaintenanceTool

目录

文字转声音

Qt TextToSpeech Engines

tts测试代码:

pro配置:

报错:connection to speech-dispatcher failed

不支持中文播报

1. 安装 espeak-ng 和中文语音库

2. 配置 Speech Dispatcher 使用 espeak-ng

3. 配置 espeak-ng 支持中文

4. 重启 Speech Dispatcher

5. 测试中文支持

通过调用不同的 TTS 工具(如 pico2wave、flite、gTTS),实现文本转语音功能。

espeak-ng 可以中文:


文字转声音

文字转声音 配音-CSDN博客

Unknown module(s) in QT: texttospeech

windows系统:

重新在MaintenanceTool.exe中下载需要的模块包来进行下载

注意执行文件目录下由texttospeech文件夹,含有qtexttospeech_sapi.dll

Qt TextToSpeech Engines

tts测试代码:

#include <QApplication>
#include <QPushButton>
#include <QVBoxLayout>
#include <QLineEdit>
#include <QTextToSpeech>
#include <QWidget>
#include <QLabel>
#include <QDebug>

QTextToSpeech* tts = new QTextToSpeech();
if(tts->state() == QTextToSpeech::Ready)
{
    tts->say(QString::fromLocal8Bit("欢迎光临"));
}

pro配置:

QT += core gui widgets texttospeech
CONFIG += c++11

SOURCES += main.cpp


报错:connection to speech-dispatcher failed

解决方法:

sudo apt update
sudo apt install speech-dispatcher speech-dispatcher-espeak-ng
 

不支持中文播报

1. 安装 espeak-ng 和中文语音库

首先,确保你已经安装了 espeak-ng

sudo apt update sudo apt install espeak-ng

然后,确保安装了支持中文的语音库。对于 espeak-ng,你需要安装中文语音数据:


sudo apt install espeak-ng-data

2. 配置 Speech Dispatcher 使用 espeak-ng

编辑 Speech Dispatcher 的配置文件 /etc/speech-dispatcher/speechd.conf,确保 espeak-ng 模块已启用:

sudo nano /etc/speech-dispatcher/speechd.conf

确保文件包含以下内容,并且没有被注释掉:


plaintext

AddModule "espeak-ng" "sd_espeak-ng" "espeak-ng.conf"

3. 配置 espeak-ng 支持中文

确保 espeak-ng 配置文件中包含对中文的支持。你可以在 /etc/speech-dispatcher/modules/espeak-ng.conf 文件中添加或修改中文支持设置:

sudo nano /etc/speech-dispatcher/modules/espeak-ng.conf

添加或修改以下内容以支持中文:

DefaultVoiceType "zh"

4. 重启 Speech Dispatcher

重启 Speech Dispatcher 服务以应用更改:

pkill speech-dispatcher speech-dispatcher --spawn

5. 测试中文支持

你可以使用 spd-say 命令来测试中文语音合成:

spd-say -l zh "你好,世界!"

如果你听到了中文语音,说明配置成功。如果没有,请确保你的系统支持中文显示,并检查 espeak-ng 是否正确安装和配置。

通过调用不同的 TTS 工具(如 pico2waveflitegTTS),实现文本转语音功能。

espeak-ng 可以中文:

sudo apt update sudo apt install espeak-ng

你可以通过以下命令测试 espeak-ng

espeak-ng -v zh "你好,世界"


网站公告

今日签到

点亮在社区的每一天
去签到