Windows computer simple real-time tts voice broadcast wsay; python pyttsx3 language real-time broadcast text-to-speech; Microsoft edge-tts natural tone is offline and not real-time

1、wsay

Reference:
https://github.com/p-groarke/wsay

Download and install:
https://github.com/p-groarke/wsay/releases/tag/v1.5.0
Download the exe file and add it to the environment variable
Insert image description here
Insert image description here

use

# Say something.
wsay "Hello there."

wsay  "你好"

Insert image description here

Video_20230813075925

2、puddlex3

Reference:
https://zhuanlan.zhihu.com/p/507369886
https://blog.51cto.com/u_12891/6705605

Install:

pip install pyttsx3 -i https://pypi.tuna.tsinghua.edu.cn/simple --user

Usage:
Call pyttsx3.speak() directly

import pyttsx3

#语音播放 
pyttsx3.speak("How are you?")
pyttsx3.speak("I am fine, thank you")


pyttsx3.speak("具体来说,这个命令中的参数-NL表示创建本地端口转发。它将本地机器的7860端口与远程服务器的192.168.19.14:7860端口进行连接。实际上,当本地机器收到对本地7860端口的请求时,请求将被转发到远程服务器的192.168.19.14:7860端口。通过这个隧道建立的通信是安全的,因为SSH使用了加密来保护数据的传输。这意味着在本地机器和远程服务器之间传输的数据被加密,只有具有正确密钥的两端才能解密和读取数据。在隧道建立后,您可以在本地机器上通过访问localhost:7860来与远程服务器上的服务进行通信。本地机器上的请求会被转发到远程服务器,并得到响应。这样,您可以通过安全的通道在本地机器和远程服务器之间进行通信。")

Insert image description here

3. Microsoft edge-tts sound is naturally offline and not real-time

Reference: https://github.com/rany2/edge-tts

Installation:
pip install edge-tts

use:

edge-tts --text "Hello, world!" --write-media hello.mp3 --write-subtitles hello.vtt

Specify language tone selection:

edge-tts --list-voices   ##查看支持的

edge-tts --voice ar-EG-SalmaNeural  ##添加 --voice 
If you want sound broadcast, you need to install the mpv command line video playback tool, download: https://mpv.io/installation/

After downloading the windows zip file and compressing it, you need to add the path to the environment variable.
Insert image description here

After installation, you can play sounds from the command line:

The playback speed will be relatively delayed, which is equivalent to converting the text into a voice mp3 file first, and then playing the mp3 file; the advantage is that the sound quality is great and close to real people.

edge-playback --text "Hello, world!"

edge-playback --text "这个错误表明在尝试进行SSL连接时,出现了证书验证问题。具体来说,问题出在证书验证过程中,证书验证失败的原因是" --voice zh-CN-XiaoxiaoNeural

If an SSL error is reported here, refer to https://github.com/rany2/edge-tts/issues/110. Change the SSL file in the edge-tts report, mainly in C:\Us****p\Lib\ Change and add in the list_voices.py and communicate.py files under the site-packages\edge_tts path; then run edge-playback to play the sound command.

verify_ssl=False,

Insert image description here

Guess you like

Origin blog.csdn.net/weixin_42357472/article/details/132256328