Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTextToSpeech---setVoice
Qt 6.12 LTS is out! See what's new in the release blog

QTextToSpeech---setVoice

Scheduled Pinned Locked Moved Unsolved General and Desktop
13 Posts 3 Posters 3.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Aqib
    wrote on last edited by
    #3

    I am using QT 5.15 & Ubuntu 20.04

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #4

      Can you provide a minimal compilable application that reproduces your issue so people can also test on their side.

      On a side note, shouldn't that be myvoice->setVoice(QVoice::Female); ?
      Second note, myvoice is a bit confusing as it makes it look like a QVoice object but is likely a QTextSpeech object, correct ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • A Offline
        A Offline
        Aqib
        wrote on last edited by Aqib
        #5

        I tried it like you said setVoice(QVoice::Female);
        and Yes myvoice or _tts is QTextToSpeech object as you said.
        _tts = new QTextToSpeech(this);
        _tts->setLocale(QLocale("en_US"));
        _tts->setVoice(QVoice::Female);

        Attached is the screenshot of the issue I am facing.Screenshot from 2022-06-29 13-01-21.pngScreenshot from 2022-06-29 13-17-08.png

        JonBJ 1 Reply Last reply
        0
        • A Aqib

          I tried it like you said setVoice(QVoice::Female);
          and Yes myvoice or _tts is QTextToSpeech object as you said.
          _tts = new QTextToSpeech(this);
          _tts->setLocale(QLocale("en_US"));
          _tts->setVoice(QVoice::Female);

          Attached is the screenshot of the issue I am facing.Screenshot from 2022-06-29 13-01-21.pngScreenshot from 2022-06-29 13-17-08.png

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #6

          @Aqib
          I know nothing about Qt voice/speech. But worrying as it is to have to question @SGaist's answer:

          myvoice->setVoice(QVoice::Female)
          

          As per the error message you are being shown, QTextToSpeech::setVoice(const QVoice &voice) requires a QVoice parameter, but QVoice::Female is a QVoice::Gender.

          I note that QVoice does not even have/document a (public) constructor? Maybe you are supposed to use QVector<QVoice> QTextToSpeech::availableVoices() const to access QVoices for each available one, and pick one whose QVoice::Gender QVoice::gender() const == QVoice::Female?? Pure guesswork on my part though!

          UPDATE
          I have just gone try this, and that's exactly how it works: you must pick one of the availableVoices(), look at their gender() to pick one.

          Under my Ubuntu 20.04 with the voice package installed I get 5 UK voices. Regional variations, but all are "Unknown Gender" "Other Age". They are all male, and adult. No female! So pretty sexist (and ageist) for 2022 ;-) probably better on Windows.

          1 Reply Last reply
          1
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #7

            @JonB good catch ! Regarding my answer, there's likely some automatic conversion going on somewhere.

            As for the available voices on Linux, did you check what was installed with your backend ? There might simply be sound packs missing or something like that.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            JonBJ 1 Reply Last reply
            0
            • SGaistS SGaist

              @JonB good catch ! Regarding my answer, there's likely some automatic conversion going on somewhere.

              As for the available voices on Linux, did you check what was installed with your backend ? There might simply be sound packs missing or something like that.

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #8

              @SGaist
              My backend is fine, thank you very much :) It's the default Ubuntu voice, using those apt -get install I posted in another question. I was only playing with it because of this question. But it would be nicer if it offered a female voice, let me know if you actually know what you'd need for Ubuntu.

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #9

                Which backend are you using ?

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                JonBJ 1 Reply Last reply
                0
                • SGaistS SGaist

                  Which backend are you using ?

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by JonB
                  #10

                  @SGaist
                  I did sudo apt-get install qtspeech5-speechd-plugin. I think it's called speechd. Is that the right answer to "which backend"?

                  Oh and per https://forum.qt.io/topic/75426/qt-speech-plug-in/20

                  And the speech engine can be installed with:
                  sudo apt-get install speech-dispatcher

                  It said that was already installed.

                  SGaistS 1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    Aqib
                    wrote on last edited by Aqib
                    #11

                    Thank you guys @SGaist & @JonB

                    JonBJ 1 Reply Last reply
                    0
                    • A Aqib

                      Thank you guys @SGaist & @JonB

                      JonBJ Offline
                      JonBJ Offline
                      JonB
                      wrote on last edited by
                      #12

                      @Aqib said in QTextToSpeech---setVoice:

                      Thank you guys @JonB & @JonB

                      We are both happy :)

                      1 Reply Last reply
                      0
                      • JonBJ JonB

                        @SGaist
                        I did sudo apt-get install qtspeech5-speechd-plugin. I think it's called speechd. Is that the right answer to "which backend"?

                        Oh and per https://forum.qt.io/topic/75426/qt-speech-plug-in/20

                        And the speech engine can be installed with:
                        sudo apt-get install speech-dispatcher

                        It said that was already installed.

                        SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #13

                        @JonB that was the answer I was looking for.

                        It looks like speechd is an intermediate layer to other speech system so it might require a bit more research to find where you can get additional voices.

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        1

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt
                        • Unsolved