AudioRecording Help



  • Hello,
    When creating a voice application under reconnaissace QtCreator I want to add two buttons, one for voice recording of a microphone and one for stop and the voice is automatically saved in a .wav file I would like to know the source code and the library used to achieve this.
    it's urgent
    Thanks


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    QAudioInput is your friend.



  • Thanx for reply
    I am a beginner in QtCreator, I want a complete function for recording if possible, in order to call this function by the button in the application.
    it's urgent please



  • @aminnov
    Here is one example.



  • Thanx for reply
    I found a function in this site, and I paste in my code but an error servenu: QAudioInput :: No such file or directory?
    I searched this problem but I have not solved.
    the code is :

    QFile outputFile;         // class member.
    QAudioInput *audioInput;  // class member.
    ...
    void startRecording()
    {
        outputFile.setFileName("/tmp/test.raw");
        outputFile.open( QIODevice::WriteOnly | QIODevice::Truncate );
        QAudioFormat format;
        // set up the format you want, eg.
        format.setFrequency(8000);
        format.setChannels(1);
        format.setSampleSize(8);
        format.setCodec("audio/pcm");
        format.setByteOrder(QAudioFormat::LittleEndian);
        format.setSampleType(QAudioFormat::UnSignedInt);
        QAudioDeviceInfo info = QAudioDeviceInfo::defaultInputDevice();
        if (!info.isFormatSupported(format)) {
            qWarning()<<"default format not supported try to use nearest";
            format = info.nearestFormat(format);
        }
        audioInput = new QAudioInput(format, this);
        QTimer::singleShot(3000, this, SLOT(stopRecording()));
        audioInput->start(&outputFile);
        // Records audio for 3000ms
    }

  • Lifetime Qt Champion

    Because you are missing QT += multimedia in your .pro file.

    On a side note, asking on a community forum for someone to do the work for you because it's urgent for you isn't exactly professional. If you are in such a hurry then consider hiring someone with the expertise you need.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.