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. QAudioRecorder detect user not speaking and stop
QtWS25 Last Chance

QAudioRecorder detect user not speaking and stop

Scheduled Pinned Locked Moved Unsolved General and Desktop
qaudiorecorderqaudioinputqmediarecorder
2 Posts 2 Posters 1.1k 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.
  • D Offline
    D Offline
    Dhaval Panchal
    wrote on 17 May 2016, 06:47 last edited by
    #1

    I want to use QAudioRecorder to record audio from user and then use audio file for speech to text. I could successfully run and record audio from this example, http://doc.qt.io/qt-5/qtmultimedia-multimedia-audiorecorder-example.html

    But my problem is, I want to while QAudioRecorder is actively recording audio, I need to detect if user stopped speaking audio. So QAudioRecorder should only stop when user is not speaking.

    I could stop QAudioRecorder for fixed seconds using QTimer as below,

    void AudioRecorder::toggleRecord()
    {
        if (audioRecorder->state() == QMediaRecorder::StoppedState) {
            audioRecorder->setAudioInput(boxValue(ui->audioDeviceBox).toString());
    
            QAudioEncoderSettings settings;
            settings.setCodec(boxValue(ui->audioCodecBox).toString());
            settings.setSampleRate(boxValue(ui->sampleRateBox).toInt());
            settings.setBitRate(boxValue(ui->bitrateBox).toInt());
            settings.setChannelCount(boxValue(ui->channelsBox).toInt());
            settings.setQuality(QMultimedia::EncodingQuality(ui->qualitySlider->value()));
            settings.setEncodingMode(ui->constantQualityRadioButton->isChecked() ?
                                     QMultimedia::ConstantQualityEncoding :
                                     QMultimedia::ConstantBitRateEncoding);
    
            QString container = boxValue(ui->containerBox).toString();
    
            audioRecorder->setEncodingSettings(settings, QVideoEncoderSettings(), container);
            audioRecorder->record();
            this->recordTimeout();
        }
        else {
            this->stopRecording();
        }
    }
    
    void AudioRecorder::recordTimeout()
    {
        QTimer* mTimer = new QTimer(this);
        mTimer->setSingleShot(true);
        connect(mTimer, SIGNAL(timeout()), SLOT(stopRecording()));
        mTimer->start(6000);
    }
    
    void AudioRecorder::stopRecording()
    {
        audioRecorder->stop();
    }
    
    

    But instead of this it should stop recording when user is not speaking. As per my guessing, QAudioProbe class has this signal audioBufferProbed(QAudioBuffer) which may be helpful to check level of audio but I don't know how to use it and what level can be used to detect user is not speaking.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 19 May 2016, 20:45 last edited by
      #2

      Hi and welcome to devnet,

      You have an example on how to use QAudioProbe in the detailed documentation of the class. As for measuring the level of a silent user, it's a completely other topic, you'll have to take into account the noise of the environment of the user.

      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

      2/2

      19 May 2016, 20:45

      • Login

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