20.04 – Sound issue of LDOCE5 viewer (written in Python3 using Gstreamer)

I have installed LDOCE5 viewer on Ubuntu 20.04 as described here. In summary:

  1. Install some dependencies:

    sudo apt-get install git make python pyqt5-dev-tools python3-pyqt5 
    python3-pyqt5.qtwebkit python3-lxml python3-whoosh  qtgstreamer-plugins-qt5
    
  2. Install further dependencies for python3.8 on Ubuntu 20.04:

    sudo apt-get install python3-pip python3-setuptools python3-distutils
    
  3. Download ldoce5viewer-pyqt5 into ~/Downloads:

    cd ~/Downloads && git clone https://github.com/purboo/ldoce5viewer-pyqt5.git
    
  4. Open the Makefile in the download folder and change python to python3 on line 2:

    gedit ~/Downloads/ldoce5viewer-pyqt5/Makefile
    
  5. There is an obsolete library in the ldoce5viewer-pyqt5 called cgi.escape()
    which has been removed from python3.8. this library is used in three files.
    in order to fix the issue, we need to change cgi to html where we see
    from cgi import escape in the following three files:

    gedit ~/Downloads/ldoce5viewer-pyqt5/ldoce5viewer/ldoce5/transform.py 
    gedit ~/Downloads/ldoce5viewer-pyqt5/ldoce5viewer/qtgui/indexer.py 
    gedit ~/Downloads/ldoce5viewer-pyqt5/ldoce5viewer/ldoce5/extract.py 
    
  6. There is an issue in the sound-player part of the software. According to this answer, to fix the issue we can open the following file and change

    'appsrc.emit('push-buffer', Gst.Buffer.new_wrapped(self._data(:size)))'
    

    to

    'appsrc.emit('push-buffer', Gst.Buffer.new_wrapped(self._data(:size).data()))'
    

    on line 114:

    gedit ~/Downloads/ldoce5viewer-pyqt5/ldoce5viewer/qtgui/utils/soundplayer.py
    
  7. Final step:

    make && sudo make install
    

Now the software can be found in the installed applications (press Super key and search for ldoce5).

The installation is successful and the dictionary is mostly functional. The only issue is that clicking on a sentence or word’s pronunciation does not play anything. The sound-related part of the software is in the following file:

gedit ~/Downloads/ldoce5viewer-pyqt5/ldoce5viewer/qtgui/utils/soundplayer.py

I tried to debug the issue and confirmed that:

  1. Gstreamer is used in the software to play sound (there are other alternatives in the code, but they are not used in Ubuntu 20.04)

  2. Gstreamer is installed on Ubuntu and words properly as per the official instructions.

  3. The mp3 file of the sound exists and it can be downloaded (there is a download option in the gui as can be seen in the following screenshot):

enter image description here

I just don’t know why the sound is not playing when clicking on the sound button (blue or red icons). Each time I click on one of them, the play method of the GstreamerBackend(Backend) class in soundplayer.py is hit. There is no error and I could confirm that the last line of the method (self._player.set_state(Gst.State.PLAYING)) is also reached. I could not go any further in my investigation of the issue. I appreciate any help to fix this.