Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QStringList destroy my Voice Command , what is wrong?
Forum Updated to NodeBB v4.3 + New Features

QStringList destroy my Voice Command , what is wrong?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qstringlist qpqprocessspeech
2 Posts 2 Posters 825 Views
  • 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.
  • P Offline
    P Offline
    patrik08
    wrote on 5 Sept 2017, 15:48 last edited by patrik08 9 May 2017, 15:50
    #1

    I have to exec a QProcess comand but is not simple report escaped option ... on console run normal...
    mac comand ( say -v "?" )
    give me:
    Whisper en_US # Pssssst, hey you, Yeah you, Who do ya think I'm talking to, the mouse?
    Xander nl_NL # Hallo, mijn naam is Xander. Ik ben een Nederlandse stem.
    Yannick de_DE # Hallo, ich heiße Yannick und ich bin eine deutsche Stimme.
    Yelda tr_TR # Merhaba, benim adım Yelda. Ben Türkçe bir sesim.
    Yuna ko_KR # 안녕하세요. 제 이름은 Yuna입니다. 저는 한국어 음성입니다.
    Zarvox en_US # That looks like a peaceful planet.
    Zosia pl_PL # Witaj. Mam na imię Zosia, jestem głosem kobiecym dla języka polskiego.
    Zuzana cs_CZ # Dobrý den, jmenuji se Zuzana. Jsem český hlas.
    ..... ecc....
    i not find it solution :-(

    i become:
    ("Voice `"?"' not found.")
    ("")

    void VoiceBlock::FillvaiableVoice() {
        QStringList cmd; //// mac comand ( say -v "?" )
        cmd << QString("-v");
        cmd << QByteArray("\"?\"");
        const QString litflat = say_comand_sdout(cmd);
        if (litflat.size() > 0) {
                     QStringList linebyline = litflat.split(QString("\n"));
                     for (int x = 0; x < linebyline.size(); x++) {
                         QString liner =linebyline.at(x);
                         QStringList dd = liner.trimmed().split(QString("\t"));
                         SESSDEBUG() << dd;
                     }
        }
    
    }
    
    QString VoiceBlock::say_comand_sdout( QStringList comandlist ) {
        SESSDEBUG() << __FUNCTION__ << " exec - #say " << comandlist;
        QString lstr;
        QString cmd=QString("say");
        QProcess *process = new QProcess(NULL);
        process->setReadChannelMode(QProcess::MergedChannels);
        process->start(cmd,comandlist,QIODevice::ReadOnly );
          if (!process->waitForFinished()) {
               lstr = QString();
          } else {
              lstr = QString(process->readAll().constData());
          }
         return lstr;
    }
    
    1 Reply Last reply
    0
    • V Offline
      V Offline
      VRonin
      wrote on 5 Sept 2017, 17:34 last edited by VRonin 9 May 2017, 17:35
      #2

      You can't read from a finished program. you have to connect to readyRead();

      replace

      process->start(cmd,comandlist,QIODevice::ReadOnly );
            if (!process->waitForFinished()) {
                 lstr = QString();
            } else {
                lstr = QString(process->readAll().constData());
            }
           return lstr;
      

      with

      QObject::connect(process,&QProcess::readyReadStandardOutput,[&lstr,process]()->void{lstr.append(QString::fromLatin1(process->readAllStandardOutput()));});
      process->start(cmd,comandlist,QIODevice::ReadOnly );
       if (process->waitForFinished()) 
      return lstr;
      return QString();
      

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      1

      1/2

      5 Sept 2017, 15:48

      • Login

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