unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Matt <matt@excalamus.com>
To: "guix-devel" <guix-devel@gnu.org>
Subject: QtTextToSpeech
Date: Mon, 21 Nov 2022 21:49:16 -0500	[thread overview]
Message-ID: <1849d3d626c.c7f6f4032451917.7268941726749635039@excalamus.com> (raw)
In-Reply-To: 

[-- Attachment #1: Type: text/plain, Size: 2529 bytes --]

I'm trying to get Text-To-Speech included within the python-pyqt package.

It looks like the definition is simply missing a declaration for qtspeech (patch attached).  I updated the definition, the package builds, and I'm now able to import the QtTextToSpeech module.  However, I'm not able to find an engine, so I can't verify that it's working 100%.

To validate the new pyqt functionality, I'm trying to get TTS working using the python-pyside-2 package.  That definition already has qtspeech included and I assume it works.  Unfortunately, I can't get that to work either.

I've installed speech-dispatcher, espeak, espeak-ng, and festival.  I'm able to get TTS from the command-line (i.e. spd-say, speak, etc.).  However, no voices or engine are found by PyQt or PySide.  I've verified that the same program works on a separate Debian machine.  Is there some setup for speech-dispatcher that I'm missing?

import sys
from PySide2 import QtCore, QtWidgets, QtTextToSpeech


class MainWindow(QtWidgets.QMainWindow):

    def __init__(self):
        super().__init__()

        self.engine = None
        self.engine_name = None

        text ='''Every effort has been made to replicate this text as faithfully as
possible, including inconsistencies in spelling and hyphenation.  Some
corrections of spelling and punctuation have been made. They are
listed at the end of the text.'''

        self.text_edit = QtWidgets.QTextEdit()
        self.text_edit.setText(text)

        self.speak_button = QtWidgets.QPushButton('Speak once')
        self.speak_button.clicked.connect(self.on_speak_button_clicked)

        # Central widget
        layout = QtWidgets.QVBoxLayout()
        layout.addWidget(self.text_edit)
        layout.addWidget(self.speak_button)

        centralWidget = QtWidgets.QWidget()
        centralWidget.setLayout(layout)
        self.setCentralWidget(centralWidget)

        engineNames = QtTextToSpeech.QTextToSpeech.availableEngines()

        if len(engineNames) > 0:
            self.engine_name = engineNames[0]
            self.engine = QtTextToSpeech.QTextToSpeech(self.engine_name)

            voice = self.engine.availableVoices()[0]
            self.engine.setVoice(voice)
        else:
            self.speak_button.setEnabled(False)

    def on_speak_button_clicked(self):
        text = self.text_edit.toPlainText()
        self.engine.say(text)



if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    mainWin = MainWindow()
    mainWin.show()
    sys.exit(app.exec_())

[-- Attachment #2: 0001-Add-qtspeech-to-python-pyqt.patch --]
[-- Type: application/octet-stream, Size: 706 bytes --]

From 93abe594035ae4694aa78cf0ca32b226dbd84eb3 Mon Sep 17 00:00:00 2001
From: Matt <matt@excalamus.com>
Date: Mon, 21 Nov 2022 18:31:17 -0500
Subject: [PATCH] Add qtspeech to python-pyqt

---
 gnu/packages/qt.scm | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gnu/packages/qt.scm b/gnu/packages/qt.scm
index 30bf429897..c5ac67a483 100644
--- a/gnu/packages/qt.scm
+++ b/gnu/packages/qt.scm
@@ -3128,6 +3128,7 @@ (define-public python-pyqt
        ("qtmultimedia-5" ,qtmultimedia-5)
        ("qtsensors" ,qtsensors)
        ("qtserialport" ,qtserialport)
+       ("qtspeech" ,qtspeech)
        ("qtsvg-5" ,qtsvg-5)
        ("qttools-5" ,qttools-5)
        ("qtwebchannel-5" ,qtwebchannel-5)
-- 
2.38.1


                 reply	other threads:[~2022-11-22  2:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1849d3d626c.c7f6f4032451917.7268941726749635039@excalamus.com \
    --to=matt@excalamus.com \
    --cc=guix-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).