我正在使用模块gTTS
尝试以下简单代码,但它不起作用。
from gtts import gTTS
import os
tts = gTTS(text="hello",lang='id')
tts.save("uhuy.mp3")
os.system("mpg123 uhuy.mp3")
当我尝试运行它时,我得到xcb_connection_has_error() returned true
:
[s1gnific4nt@s1gnific4nt] sudo python3 testt.py
High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3
version 1.23.8; written and copyright by Michael Hipp and others
free software (LGPL) without any warranty but with best wishes
No protocol specified
xcb_connection_has_error() returned true
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
No protocol specified
xcb_connection_has_error() returned true
我的播放硬件设备如下所示:
[s1gnific4nt@s1gnific4nt] aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC269VB Analog [ALC269VB Analog]
Subdevices: 0/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0]
Subdevices: 1/1
Subdevice #0: subdevice #0
我的操作系统是Fedora 25。
这里的问题是什么?
答案 0 :(得分:0)
看起来像X服务器访问问题。
尝试将运行该程序的用户添加到xhost DB:
xhost +SI:localuser:the_username_here