xcb_connection_error() returned true with gTTS library

1.7k views Asked by At

I'm trying the following simple code with module gTTS, but it isn't working.

from gtts import gTTS
import os
tts = gTTS(text="hello",lang='id')
tts.save("uhuy.mp3")
os.system("mpg123 uhuy.mp3")

When I try to run it I get 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

My playback hardware devices are shown below:

 [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

My operating system is Fedora 25.

What's the problem here?

1

There are 1 answers

0
Alexander Shcheblikin On

Looks like X server access issue.

Try adding the user running the program to the xhost DB:

xhost +SI:localuser:the_username_here