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. [PyQT] QAudioRecorder settings not correct in recorded .wav file
Forum Update on Monday, May 27th 2025

[PyQT] QAudioRecorder settings not correct in recorded .wav file

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 696 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.
  • A Offline
    A Offline
    axelfowlie
    wrote on last edited by
    #1

    Hey everyone,
    I'm using the QAudioRecorder to record some audio to do some speech recognition.
    The sample rate of the output should be 16kHz.
    My settings look like this:

        settings = QAudioEncoderSettings()
        settings.setCodec(self.supportedAudioCodecs()[0])
        settings.setBitRate(32000)
        settings.setSampleRate(16000)
        settings.setChannelCount(1)
        settings.setQuality(QMultimedia.VeryHighQuality)
        recorder.setAudioSettings(settings)
    

    if I print out the settings, it shows the correct values.

    But checking the recorded .wav file with Audacity, the sample rate is always 96kHz and the bitrate is 192k instead of the 32k.
    Currently I'm downsampling the .wav file before sending it to the speech recognizer but I want to implement a streaming mode as well, where it's not possible to downsample the piecesof audio beforehand.

    If anyone knows a solution to my problem, I'd be glad to hear it :)
    Thanks in advance,

    jsulmJ 1 Reply Last reply
    0
    • A axelfowlie

      Hey everyone,
      I'm using the QAudioRecorder to record some audio to do some speech recognition.
      The sample rate of the output should be 16kHz.
      My settings look like this:

          settings = QAudioEncoderSettings()
          settings.setCodec(self.supportedAudioCodecs()[0])
          settings.setBitRate(32000)
          settings.setSampleRate(16000)
          settings.setChannelCount(1)
          settings.setQuality(QMultimedia.VeryHighQuality)
          recorder.setAudioSettings(settings)
      

      if I print out the settings, it shows the correct values.

      But checking the recorded .wav file with Audacity, the sample rate is always 96kHz and the bitrate is 192k instead of the 32k.
      Currently I'm downsampling the .wav file before sending it to the speech recognizer but I want to implement a streaming mode as well, where it's not possible to downsample the piecesof audio beforehand.

      If anyone knows a solution to my problem, I'd be glad to hear it :)
      Thanks in advance,

      jsulmJ Online
      jsulmJ Online
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @axelfowlie Maybe it's because you use QMultimedia.VeryHighQuality?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • A Offline
        A Offline
        axelfowlie
        wrote on last edited by
        #3

        @jsulm said in [PyQT] QAudioRecorder settings not correct in recorded .wav file:

        @axelfowlie Maybe it's because you use QMultimedia.VeryHighQuality?

        Oh my god. I feel so stupid. This kind of went over my head.
        I removed the quality setting and set the encodingMode to ConstantBitrateEncoding,
        now it's working as intended.
        Big thank you!

        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