Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. Q: Qt - [c++] texttospeech is not working when QSound plays

Q: Qt - [c++] texttospeech is not working when QSound plays

Scheduled Pinned Locked Moved Unsolved Game Development
7 Posts 3 Posters 1.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.
  • K Offline
    K Offline
    kevin_d
    wrote on last edited by
    #1

    Hello Dear Qt Forum!

    When playing a QSound and triggering a texttospeech->say("some text"), texttospeech seems to be not able to say.

    I tried to invoke texttospeech->say(..) in a QMetaObject-call, but did not help.

    Is there a possibility to do both "sounds" immediately after each other?

    best regards, kevin_d

    JoeCFDJ 1 Reply Last reply
    0
    • K kevin_d

      Hello Dear Qt Forum!

      When playing a QSound and triggering a texttospeech->say("some text"), texttospeech seems to be not able to say.

      I tried to invoke texttospeech->say(..) in a QMetaObject-call, but did not help.

      Is there a possibility to do both "sounds" immediately after each other?

      best regards, kevin_d

      JoeCFDJ Offline
      JoeCFDJ Offline
      JoeCFD
      wrote on last edited by
      #2

      @kevin_d you need some mixing mechanism to send two audio sources to a mixer for the audio sink

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

        Hi,

        How exactly are you doing that ?
        On which OS ?

        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
        0
        • K Offline
          K Offline
          kevin_d
          wrote on last edited by
          #4

          I am using Qt 5.12.5 on Windows.

          auto* sound = new QSound(":/Resources/jingle.wav");
          auto* text2Speech = new QTextToSpeech(this);
          QVector<QLocale> _l = text2Speech->availableLocales();
          text2Speech->setLocale(_l[0]);
          QVector<QVoice> _v = text2Speech->availableVoices();
          text2Speech->setVoice(_v.at(0));
          
          sound->play();
          
          text2Speech->say("Welcome");
          
          SGaistS 1 Reply Last reply
          0
          • K kevin_d

            I am using Qt 5.12.5 on Windows.

            auto* sound = new QSound(":/Resources/jingle.wav");
            auto* text2Speech = new QTextToSpeech(this);
            QVector<QLocale> _l = text2Speech->availableLocales();
            text2Speech->setLocale(_l[0]);
            QVector<QVoice> _v = text2Speech->availableVoices();
            text2Speech->setVoice(_v.at(0));
            
            sound->play();
            
            text2Speech->say("Welcome");
            
            SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            You might want to try QSoundEffect.

            That said, 5.12 is deprecated. You should move 5.15 or even better Qt 6.

            That said, @JoeCFD has a point, there might be a need for some mixing.

            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
            • K Offline
              K Offline
              kevin_d
              wrote on last edited by
              #6

              Any hints?
              Is it possible to wait for QSound->play() ?

              SGaistS 1 Reply Last reply
              0
              • K kevin_d

                Any hints?
                Is it possible to wait for QSound->play() ?

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

                QSound being asynchronous, you would need to pole its state using the isFinished function and then start the next audio item.

                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
                0

                • Login

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