{
  "id": "task_libraries:audio-processing/python",
  "path": "/exapedia/python-audio-processing-libraries",
  "template": {
    "id": "task_libraries",
    "version": 4
  },
  "title": "Python audio processing libraries",
  "answer": [
    {
      "t": "text",
      "text": "Python audio processing libraries read, write, and transform sound files and sample arrays. Most decode audio into a NumPy array of samples that analysis and resampling code can operate on. These libraries let speech pipelines, music apps, and machine learning models prepare audio for analysis."
    }
  ],
  "breadcrumb": [
    {
      "label": "Tools"
    },
    {
      "label": "Python audio processing libraries"
    }
  ],
  "sections": [
    {
      "id": "libraries_popularity",
      "anchor": "popularity",
      "heading": "Popularity",
      "blocks": [
        {
          "b": "table",
          "columns": [
            "Library",
            "Monthly downloads",
            "Stars",
            "Last release",
            "License"
          ],
          "rows": [
            [
              [
                {
                  "t": "link",
                  "href": "#av",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F119"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F120"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F128"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F123"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F121"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#soundfile",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F136"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F137"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F143"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F140"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F138"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#pydub",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F151"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F152"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F158"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F155"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F153"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#soxr",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F166"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F167"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F175"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F170"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F168"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#ffmpeg-python",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F183"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F184"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F192"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F187"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F185"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#librosa",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F200"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F201"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F207"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F204"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F202"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#audioread",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F215"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F216"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F224"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F219"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F217"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#torchaudio",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F232"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F233"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F239"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F236"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F234"
                }
              ]
            ]
          ],
          "variant": "pop",
          "caption": [
            {
              "t": "text",
              "text": "Downloads: "
            },
            {
              "t": "text",
              "text": "PyPI"
            },
            {
              "t": "text",
              "text": ", last thirty days. Stars and releases: GitHub. Amber: no release in over a year."
            }
          ]
        }
      ],
      "note": [
        {
          "t": "link",
          "href": "#av",
          "label": [
            {
              "t": "text",
              "text": "PyAV"
            }
          ]
        },
        {
          "t": "text",
          "text": ", whose count also covers video work, has the most monthly downloads in this comparison, at "
        },
        {
          "t": "fact",
          "fact": "F120"
        },
        {
          "t": "text",
          "text": "."
        }
      ]
    },
    {
      "id": "libraries_capabilities",
      "anchor": "capabilities",
      "heading": "Capabilities",
      "blocks": [
        {
          "b": "table",
          "columns": [
            "Library",
            "Audio file encoding",
            "Sample-rate conversion"
          ],
          "rows": [
            [
              [
                {
                  "t": "link",
                  "href": "#av",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F119"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F129"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F130"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#soundfile",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F136"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F144"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F145"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#pydub",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F151"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F159"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F160"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#soxr",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F166"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F176"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F177"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#ffmpeg-python",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F183"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F193"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F194"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#librosa",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F200"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F208"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F209"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#audioread",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F215"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F225"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F226"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#torchaudio",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F232"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F240"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F241"
                }
              ]
            ]
          ],
          "variant": "cap"
        }
      ]
    },
    {
      "id": "libraries_entries",
      "anchor": "libraries",
      "heading": "Libraries",
      "blocks": [
        {
          "b": "entry",
          "anchor": "av",
          "name": [
            {
              "t": "fact",
              "fact": "F119"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/PyAV-Org/PyAV"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/av"
            },
            {
              "label": "Docs",
              "href": "https://pypi.org/project/av/"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F126"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F120"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F128"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F122"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F121"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://pypi.org/project/av/",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F119"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F134"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F135"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/ManimCommunity/manim",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F134"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def convert_audio(input_path: Path, output_path: Path, codec_name: str):\n    with (\n        av.open(input_path) as input_audio,\n        av.open(output_path, \"w\") as output_audio,\n    ):\n        input_audio_stream = input_audio.streams.audio[0]\n        output_audio_stream = output_audio.add_stream(codec_name)\n        for frame in input_audio.decode(input_audio_stream):\n            for packet in output_audio_stream.encode(frame):\n                output_audio.mux(packet)\n\n        for packet in output_audio_stream.encode():\n            output_audio.mux(packet)",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/ManimCommunity/manim/blob/c2dfb597ff470f0cdb01ce9074edb426f45000bc/manim/scene/scene_file_writer.py#L62-L74",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F133"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=av%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F119"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "import av\nwith av.open('input.wav') as container:\n    frame = next(container.decode(audio=0))\n    samples = frame.to_ndarray()\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://pyav.basswood-io.com/docs/stable/api/container.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "container.html"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F124"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "soundfile",
          "name": [
            {
              "t": "fact",
              "fact": "F136"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/bastibe/python-soundfile"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/soundfile"
            },
            {
              "label": "Docs",
              "href": "https://pypi.org/project/soundfile/"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F11"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F137"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F143"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F139"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F138"
                }
              ]
            },
            {
              "label": "Runs on",
              "value": [
                {
                  "t": "fact",
                  "fact": "F7"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://pypi.org/project/soundfile/",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F136"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F12"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F13"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F14"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F15"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F16"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F17"
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F149"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F150"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/librosa/librosa",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F149"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def __soundfile_load(path, offset, duration, dtype):\n    \"\"\"Load an audio buffer using soundfile.\"\"\"\n    if isinstance(path, sf.SoundFile):\n        # If the user passed an existing soundfile object,\n        # we can use it directly\n        context = path\n    else:\n        # Otherwise, create the soundfile object\n        context = sf.SoundFile(path)\n\n    with context as sf_desc:\n        sr_native = sf_desc.samplerate\n        if offset != 0:\n            if offset > 0:\n                # Seek to the start of the target read\n                sf_desc.seek(int(offset * sr_native))\n            else:\n                sf_desc.seek(-int(abs(offset) * sr_native), whence=sf.SEEK_END)\n\n        if duration is not None:\n            frame_duration = int(duration * sr_native)\n        else:\n            frame_duration = -1\n\n        # Load the target number of frames, and transpose to match librosa form\n        y = sf_desc.read(frames=frame_duration, dtype=dtype, always_2d=False).T\n\n    return y, sr_native",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/librosa/librosa/blob/76f10b8d2d00870fed47b4698927a4e7e78d1fb4/librosa/core/audio.py#L171-L198",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F148"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Python%20projects%20using%20soundfile%20for%20mel%20filters%2C%20silence%20trimming%2C%20partial%20audio%20decoding%20and%20timeline%20mixing&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F136"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "import soundfile as sf\nsamples, sample_rate = sf.read('input.wav')\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://python-soundfile.readthedocs.io/en/latest/",
                  "label": [
                    {
                      "t": "text",
                      "text": "latest.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F141"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "pydub",
          "name": [
            {
              "t": "fact",
              "fact": "F151"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/jiaaro/pydub"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/pydub"
            },
            {
              "label": "Docs",
              "href": "https://pypi.org/project/pydub/"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F34"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F152"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F158"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F154"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F153"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://pypi.org/project/pydub/",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F151"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F35"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F36"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F37"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F38"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F39"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F40"
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F164"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F165"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/ManimCommunity/manim",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F164"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def add_audio_segment(\n    self,\n    new_segment: AudioSegment,\n    time: float | None = None,\n    gain_to_background: float | None = None,\n):\n    \"\"\"\n    This method adds an audio segment from an\n    AudioSegment type object and suitable parameters.\n\n    Parameters\n    ----------\n    new_segment\n        The audio segment to add\n\n    time\n        the timestamp at which the\n        sound should be added.\n\n    gain_to_background\n        The gain of the segment from the background.\n    \"\"\"\n    if not self.includes_sound:\n        self.includes_sound = True\n        self.create_audio_segment()\n    segment = self.audio_segment\n    curr_end = segment.duration_seconds\n    if time is None:\n        time = curr_end\n    if time < 0:\n        raise ValueError(\"Adding sound at timestamp < 0\")\n\n    new_end = time + new_segment.duration_seconds\n    diff = new_end - curr_end\n    if diff > 0:\n        segment = segment.append(\n            AudioSegment.silent(int(np.ceil(diff * 1000))),\n            crossfade=0,\n        )\n    self.audio_segment = segment.overlay(\n        new_segment,\n        position=int(1000 * time),\n        gain_during_overlay=gain_to_background,\n    )",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/ManimCommunity/manim/blob/c2dfb597ff470f0cdb01ce9074edb426f45000bc/manim/scene/scene_file_writer.py#L297-L340",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F163"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Python%20projects%20using%20pydub%20for%20mel%20filters%2C%20silence%20trimming%2C%20partial%20audio%20decoding%20and%20timeline%20mixing&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F151"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "from pydub import AudioSegment\naudio = AudioSegment.from_wav('input.wav')\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://github.com/jiaaro/pydub",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.markdown"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F156"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "soxr",
          "name": [
            {
              "t": "fact",
              "fact": "F166"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/dofuuz/python-soxr"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/soxr"
            },
            {
              "label": "Docs",
              "href": "https://python-soxr.readthedocs.io"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F173"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F167"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F175"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F169"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F168"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://python-soxr.readthedocs.io",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F166"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F181"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F182"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/CPJKU/beat_this",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F181"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def signal2spect(self, signal, sr):\n    if signal.ndim == 2:\n        signal = signal.mean(1)\n    elif signal.ndim != 1:\n        raise ValueError(f\"Expected 1D or 2D signal, got shape {signal.shape}\")\n    if sr != 22050:\n        signal = soxr.resample(signal, in_rate=sr, out_rate=22050)\n    signal = torch.tensor(signal, dtype=torch.float32, device=self.device)\n    return self.spect(signal)",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/CPJKU/beat_this/blob/b95c8ab0c58c2d9fcfd40508ae8dffbc05ac4f5c/beat_this/inference.py#L269-L277",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F180"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=soxr%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F166"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "import numpy as np\nimport soxr\nsamples = np.zeros(48000, dtype=np.float32)\nconverted = soxr.resample(samples, 48000, 16000)\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://python-soxr.readthedocs.io/en/stable/soxr.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "soxr.html"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F171"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "ffmpeg-python",
          "name": [
            {
              "t": "fact",
              "fact": "F183"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/kkroening/ffmpeg-python"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/ffmpeg-python"
            },
            {
              "label": "Docs",
              "href": "https://pypi.org/project/ffmpeg-python/"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F190"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F184"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F192"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F186"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F185"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://pypi.org/project/ffmpeg-python/",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F183"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F198"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F199"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/openai/whisper",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F198"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def load_audio(file: str, sr: int = SAMPLE_RATE):\n    \"\"\"\n    Open an audio file and read as mono waveform, resampling as necessary\n\n    Parameters\n    ----------\n    file: str\n        The audio file to open\n\n    sr: int\n        The sample rate to resample the audio if necessary\n\n    Returns\n    -------\n    A NumPy array containing the audio waveform, in float32 dtype.\n    \"\"\"\n    try:\n        # This launches a subprocess to decode audio while down-mixing and resampling as necessary.\n        # Requires the ffmpeg CLI and `ffmpeg-python` package to be installed.\n        out, _ = (\n            ffmpeg.input(file, threads=0)\n            .output(\"-\", format=\"s16le\", acodec=\"pcm_s16le\", ac=1, ar=sr)\n            .run(cmd=[\"ffmpeg\", \"-nostdin\"], capture_stdout=True, capture_stderr=True)\n        )\n    except ffmpeg.Error as e:\n        raise RuntimeError(f\"Failed to load audio: {e.stderr.decode()}\") from e\n\n    return np.frombuffer(out, np.int16).flatten().astype(np.float32) / 32768.0",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/openai/whisper/blob/28769fcfe50755a817ab922a7bc83483159600a9/whisper/audio.py#L22-L49",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F197"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=ffmpeg-python%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F183"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "import ffmpeg\nffmpeg.input('input.wav').output('output.flac').run()\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://kkroening.github.io/ffmpeg-python/",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F188"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "librosa",
          "name": [
            {
              "t": "fact",
              "fact": "F200"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/librosa/librosa"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/librosa"
            },
            {
              "label": "Docs",
              "href": "https://librosa.org/doc"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F57"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F201"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F207"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F203"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F202"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://librosa.org/doc",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F200"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F58"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F59"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F60"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F61"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F62"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F63"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F64"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F65"
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F213"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F214"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/coqui-ai/TTS",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F213"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def build_mel_basis(\n    *,\n    sample_rate: int = None,\n    fft_size: int = None,\n    num_mels: int = None,\n    mel_fmax: int = None,\n    mel_fmin: int = None,\n    **kwargs,\n) -> np.ndarray:\n    \"\"\"Build melspectrogram basis.\n\n    Returns:\n        np.ndarray: melspectrogram basis.\n    \"\"\"\n    if mel_fmax is not None:\n        assert mel_fmax <= sample_rate // 2\n        assert mel_fmax - mel_fmin > 0\n    return librosa.filters.mel(sr=sample_rate, n_fft=fft_size, n_mels=num_mels, fmin=mel_fmin, fmax=mel_fmax)",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/coqui-ai/TTS/blob/dbf1a08a0d4e47fdad6172e433eeb34bc6b13b4e/TTS/utils/audio/numpy_transforms.py#L14-L31",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F212"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Python%20projects%20using%20librosa%20for%20mel%20filters%2C%20silence%20trimming%2C%20partial%20audio%20decoding%20and%20timeline%20mixing&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F200"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "import librosa\nsamples, sample_rate = librosa.load('input.wav', sr=None)\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://raw.githubusercontent.com/librosa/librosa/1.0.1/librosa/core/audio.py",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F205"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "audioread",
          "name": [
            {
              "t": "fact",
              "fact": "F215"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/beetbox/audioread"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/audioread"
            },
            {
              "label": "Docs",
              "href": "https://pypi.org/project/audioread/"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F222"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F216"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F224"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F218"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F217"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://pypi.org/project/audioread/",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F215"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F230"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F231"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/lhotse-speech/lhotse",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F230"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def audioread_info(path: Pathlike) -> LibsndfileCompatibleAudioInfo:\n    \"\"\"\n    Return an audio info data structure that's a compatible subset of ``pysoundfile.info()``\n    that we need to create a ``Recording`` manifest.\n    \"\"\"\n    import audioread\n\n    # We just read the file and compute the number of samples\n    # -- no other method seems fully reliable...\n    with audioread.audio_open(\n        str(path), backends=_available_audioread_backends()\n    ) as input_file:\n        shape = audioread_load(input_file)[0].shape\n        if len(shape) == 1:\n            num_samples = shape[0]\n        else:\n            num_samples = shape[1]\n        return LibsndfileCompatibleAudioInfo(\n            channels=input_file.channels,\n            frames=num_samples,\n            samplerate=int(input_file.samplerate),\n            duration=num_samples / input_file.samplerate,\n        )",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/lhotse-speech/lhotse/blob/3a4f0971f4f05c3d012e36b85097ddb5cb235c33/lhotse/audio/backend.py#L1383-L1405",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F229"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=audioread%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F215"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "import audioread\nwith audioread.audio_open('input.wav') as audio:\n    sample_rate = audio.samplerate\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://github.com/beetbox/audioread",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F220"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "torchaudio",
          "name": [
            {
              "t": "fact",
              "fact": "F232"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/pytorch/audio"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/torchaudio"
            },
            {
              "label": "Docs",
              "href": "https://pypi.org/project/torchaudio/"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F84"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F233"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F239"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F235"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F234"
                }
              ]
            },
            {
              "label": "Runs on",
              "value": [
                {
                  "t": "fact",
                  "fact": "F79"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://pypi.org/project/torchaudio/",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F232"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F85"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F86"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F87"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F88"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F89"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F90"
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F245"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F246"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/embeddings-benchmark/mteb",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F245"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "@staticmethod\ndef resample_audio(\n    audio: dict[str, Any],\n    *,\n    target_sampling_rate: int,\n    max_samples: int | None = None,\n) -> np.typing.NDArray[np.floating]:\n    \"\"\"Resample an audio input to a target sampling rate and optionally truncate to a maximum number of samples.\n\n    Args:\n        audio: A list of dictionaries containing audio data under the \"audio\" key, where each audio is a dictionary with \"array\" and \"sampling_rate\" keys.\n        target_sampling_rate: The sampling rate to resample the audio to.\n        max_samples: The maximum number of samples to keep for each audio. If None, no truncation is applied.\n    \"\"\"\n    import torchaudio\n\n    audio = audio[\"audio\"]\n    if audio[\"sampling_rate\"] != target_sampling_rate:\n        logger.debug(\n            f\"Resampling audio from {audio['sampling_rate']} Hz to {target_sampling_rate} Hz.\"\n        )\n        resampler = torchaudio.transforms.Resample(\n            orig_freq=audio[\"sampling_rate\"],\n            new_freq=target_sampling_rate,\n        )\n        audio_array = resampler(torch.from_numpy(audio[\"array\"]).float()).numpy()\n    else:\n        audio_array = audio[\"array\"]\n\n    # Convert to mono if needed\n    if audio_array.ndim > 1 and audio_array.shape[0] > 1:\n        audio_array = np.mean(audio_array, axis=0)\n\n    if max_samples is not None:\n        num_samples = audio_array.shape[-1]\n        if num_samples > max_samples:\n            audio_array = audio_array[..., :max_samples]\n\n    audio_array = cast(\n        \"np.ndarray[tuple[Any, ...], np.dtype[np.floating[Any]]]\",\n        audio_array,\n    )\n    return audio_array",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/embeddings-benchmark/mteb/blob/cd1828837acc188bde2a483e1dca177ba9ed260a/mteb/models/modality_collators.py#L78-L120",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F244"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Python%20projects%20using%20torchaudio%20for%20mel%20filters%2C%20silence%20trimming%2C%20partial%20audio%20decoding%20and%20timeline%20mixing&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F232"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "import torch\nfrom torchaudio.transforms import Resample\nwaveform = torch.zeros(1, 16000)\nconverted = Resample(orig_freq=16000, new_freq=8000)(waveform)\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://docs.pytorch.org/audio/stable/generated/torchaudio.transforms.Resample.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "audio_resampling_tutorial.py"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F237"
            }
          ]
        }
      ]
    }
  ],
  "questions": [
    {
      "q": "Which Python audio processing library should I use?",
      "a": [
        {
          "t": "link",
          "href": "#soundfile",
          "label": [
            {
              "t": "text",
              "text": "SoundFile"
            }
          ]
        },
        {
          "t": "text",
          "text": " suits reading and writing audio files as NumPy arrays. "
        },
        {
          "t": "link",
          "href": "#librosa",
          "label": [
            {
              "t": "text",
              "text": "librosa"
            }
          ]
        },
        {
          "t": "text",
          "text": " suits music and audio analysis. "
        },
        {
          "t": "link",
          "href": "#pydub",
          "label": [
            {
              "t": "text",
              "text": "pydub"
            }
          ]
        },
        {
          "t": "text",
          "text": " suits slicing, joining, and converting audio clips."
        }
      ]
    },
    {
      "q": "What is librosa?",
      "a": [
        {
          "t": "link",
          "href": "#librosa",
          "label": [
            {
              "t": "text",
              "text": "librosa"
            }
          ]
        },
        {
          "t": "text",
          "text": " provides algorithms for audio and music signal processing, such as spectrograms, beat tracking, and pitch features."
        }
      ]
    },
    {
      "q": "What is pydub?",
      "a": [
        {
          "t": "link",
          "href": "#pydub",
          "label": [
            {
              "t": "text",
              "text": "pydub"
            }
          ]
        },
        {
          "t": "text",
          "text": " represents audio as immutable AudioSegment objects that support slicing, concatenation, and format conversion. It uses FFmpeg to read formats other than WAV."
        }
      ]
    },
    {
      "q": "What is torchaudio?",
      "a": [
        {
          "t": "link",
          "href": "#torchaudio",
          "label": [
            {
              "t": "text",
              "text": "TorchAudio"
            }
          ]
        },
        {
          "t": "text",
          "text": " provides audio loading, transforms, and models for PyTorch. Its transforms run on tensors inside training pipelines."
        }
      ]
    },
    {
      "q": "How do I use FFmpeg from Python?",
      "a": [
        {
          "t": "link",
          "href": "#ffmpeg-python",
          "label": [
            {
              "t": "text",
              "text": "ffmpeg-python"
            }
          ]
        },
        {
          "t": "text",
          "text": " builds FFmpeg command lines with filter graphs from Python. "
        },
        {
          "t": "link",
          "href": "#av",
          "label": [
            {
              "t": "text",
              "text": "PyAV"
            }
          ]
        },
        {
          "t": "text",
          "text": " binds the FFmpeg libraries directly for frame-level access."
        }
      ]
    }
  ],
  "facts": {
    "F1": {
      "label": "Library name, soundfile",
      "display": "SoundFile",
      "asOf": "2026-11-17"
    },
    "F2": {
      "label": "Monthly downloads, soundfile",
      "display": "34.7M",
      "asOf": "2026-11-16"
    },
    "F3": {
      "label": "License, soundfile",
      "display": "BSD 3-Clause License",
      "asOf": "2026-11-17"
    },
    "F4": {
      "label": "Package release, soundfile",
      "display": "0.14.0, Jun 2026",
      "asOf": "2026-06-06"
    },
    "F5": {
      "label": "Package release date, soundfile",
      "display": "Jun 2026",
      "asOf": "2026-06-06"
    },
    "F6": {
      "label": "Repository stars, soundfile",
      "display": "874",
      "asOf": "2026-11-17"
    },
    "F7": {
      "label": "Runtime, soundfile",
      "display": "libsndfile",
      "asOf": "2026-11-17"
    },
    "F8": {
      "label": "Audio file I/O, soundfile",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F9": {
      "label": "Output formats, soundfile",
      "display": "WAV",
      "asOf": "2026-11-17"
    },
    "F10": {
      "label": "Install, soundfile",
      "display": "pip install soundfile",
      "asOf": "2026-11-17"
    },
    "F11": {
      "label": "What it does, soundfile",
      "display": "Reads and writes audio files.",
      "asOf": "2026-11-17"
    },
    "F12": {
      "label": "strengths lead, soundfile",
      "display": "Reads and writes sound files",
      "asOf": "2026-11-17"
    },
    "F13": {
      "label": "strengths, soundfile",
      "display": "Use soundfile.read and soundfile.write for supported audio formats.",
      "asOf": "2026-11-17"
    },
    "F14": {
      "label": "strengths lead, soundfile",
      "display": "Processes audio in blocks",
      "asOf": "2026-11-17"
    },
    "F15": {
      "label": "strengths, soundfile",
      "display": "Read short overlapping blocks without loading the entire recording.",
      "asOf": "2026-11-17"
    },
    "F16": {
      "label": "limitations lead, soundfile",
      "display": "Raw audio needs format details",
      "asOf": "2026-11-17"
    },
    "F17": {
      "label": "limitations, soundfile",
      "display": "Specify the sample rate, channel count, and subtype when opening headerless audio.",
      "asOf": "2026-11-17"
    },
    "F18": {
      "label": "Quickstart, soundfile",
      "display": "import soundfile as sf\n\ndata, samplerate = sf.read('existing_file.wav')\nsf.write('new_file.flac', data, samplerate)\n",
      "asOf": "2026-11-17"
    },
    "F19": {
      "label": "Project function, soundfile",
      "display": "def __soundfile_load(path, offset, duration, dtype):\n    # ...\n    if isinstance(path, sf.SoundFile):\n        # If the user passed an existing soundfile object,\n        # we can use it directly\n        context = path\n    else:\n        # Otherwise, create the soundfile object\n        context = sf.SoundFile(path)\n\n    with context as sf_desc:\n        sr_native = sf_desc.samplerate\n        if offset != 0:\n            if offset > 0:\n                # Seek to the start of the target read\n                sf_desc.seek(int(offset * sr_native))\n            else:\n                sf_desc.seek(-int(abs(offset) * sr_native), whence=sf.SEEK_END)\n\n        if duration is not None:\n            frame_duration = int(duration * sr_native)\n        else:\n            frame_duration = -1\n\n        # Load the target number of frames, and transpose to match librosa form\n        y = sf_desc.read(frames=frame_duration, dtype=dtype, always_2d=False).T\n\n    return y, sr_native\n",
      "asOf": "2026-11-17"
    },
    "F20": {
      "label": "Project function reference, soundfile",
      "display": "audio.py · __soundfile_load()",
      "asOf": "2026-11-17"
    },
    "F21": {
      "label": "Project repository, soundfile",
      "display": "librosa/librosa",
      "asOf": "2026-11-17"
    },
    "F22": {
      "label": "Project stars, librosa/librosa",
      "display": "9.0K",
      "asOf": "2026-11-17"
    },
    "F23": {
      "label": "Project push date, librosa/librosa",
      "display": "Nov 2026",
      "asOf": "2026-11-15"
    },
    "F24": {
      "label": "Library name, pydub",
      "display": "Pydub",
      "asOf": "2026-11-17"
    },
    "F25": {
      "label": "Monthly downloads, pydub",
      "display": "16.7M",
      "asOf": "2026-11-16"
    },
    "F26": {
      "label": "License, pydub",
      "display": "MIT",
      "asOf": "2026-11-17"
    },
    "F27": {
      "label": "Package release, pydub",
      "display": "0.25.1, Mar 2021",
      "asOf": "2021-03-10"
    },
    "F28": {
      "label": "Package release date, pydub",
      "display": "Mar 2021",
      "asOf": "2021-03-10"
    },
    "F29": {
      "label": "Repository stars, pydub",
      "display": "9.8K",
      "asOf": "2026-11-17"
    },
    "F30": {
      "label": "Audio file I/O, pydub",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F31": {
      "label": "Resampling, pydub",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F32": {
      "label": "Output formats, pydub",
      "display": "MP3",
      "asOf": "2026-11-17"
    },
    "F33": {
      "label": "Install, pydub",
      "display": "pip install pydub",
      "asOf": "2026-11-17"
    },
    "F34": {
      "label": "What it does, pydub",
      "display": "Represents audio with immutable AudioSegment objects.",
      "asOf": "2026-11-17"
    },
    "F35": {
      "label": "strengths lead, pydub",
      "display": "Slices clips by time",
      "asOf": "2026-11-17"
    },
    "F36": {
      "label": "strengths, pydub",
      "display": "Select a section of audio using millisecond-based slices.",
      "asOf": "2026-11-17"
    },
    "F37": {
      "label": "strengths lead, pydub",
      "display": "Mixes clips on a timeline",
      "asOf": "2026-11-17"
    },
    "F38": {
      "label": "strengths, pydub",
      "display": "Overlay clips at a chosen position with background-gain control.",
      "asOf": "2026-11-17"
    },
    "F39": {
      "label": "limitations lead, pydub",
      "display": "Compressed formats need ffmpeg",
      "asOf": "2026-11-17"
    },
    "F40": {
      "label": "limitations, pydub",
      "display": "Install ffmpeg to open or save formats such as MP3.",
      "asOf": "2026-11-17"
    },
    "F41": {
      "label": "Quickstart, pydub",
      "display": "from pydub import AudioSegment\n\nsong = AudioSegment.from_wav(\"never_gonna_give_you_up.wav\")\n\n# pydub does things in milliseconds\nten_seconds = 10 * 1000\n\nfirst_10_seconds = song[:ten_seconds]\n\nlast_5_seconds = song[-5000:]\n\n# boost volume by 6dB\nbeginning = first_10_seconds + 6\n\n# reduce volume by 3dB\nend = last_5_seconds - 3\n\nwithout_the_middle = beginning + end\n\n# 1.5 second crossfade\nwith_style = beginning.append(end, crossfade=1500)\n\n# repeat the clip twice\ndo_it_over = with_style * 2\n\n# 2 sec fade in, 3 sec fade out\nawesome = do_it_over.fade_in(2000).fade_out(3000)\n\nawesome.export(\"mashup.mp3\", format=\"mp3\")\n",
      "asOf": "2026-11-17"
    },
    "F42": {
      "label": "Project function, pydub",
      "display": "def add_audio_segment(\n    self,\n    new_segment: AudioSegment,\n    time: float | None = None,\n    gain_to_background: float | None = None,\n):\n    # ...\n    if not self.includes_sound:\n        self.includes_sound = True\n        self.create_audio_segment()\n    segment = self.audio_segment\n    curr_end = segment.duration_seconds\n    if time is None:\n        time = curr_end\n    if time < 0:\n        raise ValueError(\"Adding sound at timestamp < 0\")\n\n    new_end = time + new_segment.duration_seconds\n    diff = new_end - curr_end\n    if diff > 0:\n        segment = segment.append(\n            AudioSegment.silent(int(np.ceil(diff * 1000))),\n            crossfade=0,\n        )\n    self.audio_segment = segment.overlay(\n        new_segment,\n        position=int(1000 * time),\n        gain_during_overlay=gain_to_background,\n    )\n",
      "asOf": "2026-11-17"
    },
    "F43": {
      "label": "Project function reference, pydub",
      "display": "scene_file_writer.py · add_audio_segment()",
      "asOf": "2026-11-17"
    },
    "F44": {
      "label": "Project repository, pydub",
      "display": "ManimCommunity/manim",
      "asOf": "2026-11-17"
    },
    "F45": {
      "label": "Project stars, ManimCommunity/manim",
      "display": "42.6K",
      "asOf": "2026-11-17"
    },
    "F46": {
      "label": "Project push date, ManimCommunity/manim",
      "display": "Nov 2026",
      "asOf": "2026-11-14"
    },
    "F47": {
      "label": "Library name, librosa",
      "display": "librosa",
      "asOf": "2026-11-17"
    },
    "F48": {
      "label": "Monthly downloads, librosa",
      "display": "10.8M",
      "asOf": "2026-11-16"
    },
    "F49": {
      "label": "License, librosa",
      "display": "ISC",
      "asOf": "2026-11-17"
    },
    "F50": {
      "label": "Package release, librosa",
      "display": "1.0.1, Nov 2026",
      "asOf": "2026-11-12"
    },
    "F51": {
      "label": "Package release date, librosa",
      "display": "Nov 2026",
      "asOf": "2026-11-12"
    },
    "F52": {
      "label": "Repository stars, librosa",
      "display": "9.0K",
      "asOf": "2026-11-17"
    },
    "F53": {
      "label": "Audio file I/O, librosa",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F54": {
      "label": "Resampling, librosa",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F55": {
      "label": "Feature extraction, librosa",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F56": {
      "label": "Install, librosa",
      "display": "pip install librosa matplotlib ipython",
      "asOf": "2026-11-17"
    },
    "F57": {
      "label": "What it does, librosa",
      "display": "Provides algorithms for audio and music signal processing.",
      "asOf": "2026-11-17"
    },
    "F58": {
      "label": "strengths lead, librosa",
      "display": "Analyzes rhythm and onset strength",
      "asOf": "2026-11-17"
    },
    "F59": {
      "label": "strengths, librosa",
      "display": "Estimate beat positions and build onset-strength features from audio.",
      "asOf": "2026-11-17"
    },
    "F60": {
      "label": "strengths lead, librosa",
      "display": "Loads audio for analysis",
      "asOf": "2026-11-17"
    },
    "F61": {
      "label": "strengths, librosa",
      "display": "Decode audio into a floating-point waveform.",
      "asOf": "2026-11-17"
    },
    "F62": {
      "label": "limitations lead, librosa",
      "display": "Loading resamples audio by default",
      "asOf": "2026-11-17"
    },
    "F63": {
      "label": "limitations, librosa",
      "display": "Pass sr=None to keep the file’s original sample rate.",
      "asOf": "2026-11-17"
    },
    "F64": {
      "label": "limitations lead, librosa",
      "display": "Loading mixes channels by default",
      "asOf": "2026-11-17"
    },
    "F65": {
      "label": "limitations, librosa",
      "display": "Pass mono=False when each input channel must stay separate.",
      "asOf": "2026-11-17"
    },
    "F66": {
      "label": "Quickstart, librosa",
      "display": "import librosa\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport matplotlib.animation as animation\nfrom IPython.display import Audio, HTML\n\n# Load an example audio file with a beat\ny, sr = librosa.loadx(\"sweetwaltz\", duration=20.0)\nHTML(librosa.util.example_info(\"sweetwaltz\", html=True))\n\nonset_env = librosa.onset.onset_strength(y=y, sr=sr)\ntimes = librosa.times_like(onset_env, sr=sr)\nS = librosa.stft(y)\n\nfig, ax = plt.subplots(nrows=3, sharex=True, height_ratios=(1, 1, 2))\nax[0].plot(times, onset_env, label=\"Onset strength\", color=\"C1\")\nlibrosa.display.waveshow(y, sr=sr, ax=ax[1], label=\"Waveform\")\nimg = librosa.display.specshow(S, sr=sr, vscale=\"dBFS\", x_axis=\"time\", y_axis=\"log\", ax=ax[2])\nlibrosa.display.colorbar_db(img, label=\"dBFS\")\nax[0].legend(loc=\"upper right\")\nax[1].legend(loc=\"upper right\")\nax[0].label_outer()\nax[1].label_outer()\n",
      "asOf": "2026-11-17"
    },
    "F67": {
      "label": "Quickstart source reference, librosa",
      "display": "06-rhythm.html",
      "asOf": "2026-11-17"
    },
    "F68": {
      "label": "Project function, librosa",
      "display": "def build_mel_basis(\n    *,\n    sample_rate: int = None,\n    fft_size: int = None,\n    num_mels: int = None,\n    mel_fmax: int = None,\n    mel_fmin: int = None,\n    **kwargs,\n) -> np.ndarray:\n    # ...\n    if mel_fmax is not None:\n        assert mel_fmax <= sample_rate // 2\n        assert mel_fmax - mel_fmin > 0\n    return librosa.filters.mel(sr=sample_rate, n_fft=fft_size, n_mels=num_mels, fmin=mel_fmin, fmax=mel_fmax)\n",
      "asOf": "2026-11-17"
    },
    "F69": {
      "label": "Project function reference, librosa",
      "display": "numpy_transforms.py · build_mel_basis()",
      "asOf": "2026-11-17"
    },
    "F70": {
      "label": "Project repository, librosa",
      "display": "coqui-ai/TTS",
      "asOf": "2026-11-17"
    },
    "F71": {
      "label": "Project stars, coqui-ai/TTS",
      "display": "46.2K",
      "asOf": "2026-11-17"
    },
    "F72": {
      "label": "Project push date, coqui-ai/TTS",
      "display": "Aug 2024",
      "asOf": "2024-08-16"
    },
    "F73": {
      "label": "Library name, torchaudio",
      "display": "TorchAudio",
      "asOf": "2026-11-17"
    },
    "F74": {
      "label": "Monthly downloads, torchaudio",
      "display": "5.7M",
      "asOf": "2026-11-16"
    },
    "F75": {
      "label": "License, torchaudio",
      "display": "BSD",
      "asOf": "2026-11-17"
    },
    "F76": {
      "label": "Package release, torchaudio",
      "display": "2.11.1, Oct 2026",
      "asOf": "2026-10-28"
    },
    "F77": {
      "label": "Package release date, torchaudio",
      "display": "Oct 2026",
      "asOf": "2026-10-28"
    },
    "F78": {
      "label": "Repository stars, torchaudio",
      "display": "3.0K",
      "asOf": "2026-11-17"
    },
    "F79": {
      "label": "Runtime, torchaudio",
      "display": "PyTorch",
      "asOf": "2026-11-17"
    },
    "F80": {
      "label": "Audio file I/O, torchaudio",
      "display": "Via plugin",
      "asOf": "2026-11-17"
    },
    "F81": {
      "label": "Resampling, torchaudio",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F82": {
      "label": "Feature extraction, torchaudio",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F83": {
      "label": "Install, torchaudio",
      "display": "pip install torchaudio matplotlib numpy ipython",
      "asOf": "2026-11-17"
    },
    "F84": {
      "label": "What it does, torchaudio",
      "display": "Provides audio processing tools for the PyTorch ecosystem.",
      "asOf": "2026-11-17"
    },
    "F85": {
      "label": "strengths lead, torchaudio",
      "display": "Resamples PyTorch waveforms",
      "asOf": "2026-11-17"
    },
    "F86": {
      "label": "strengths, torchaudio",
      "display": "Resample waveform tensors through functional or reusable transform APIs.",
      "asOf": "2026-11-17"
    },
    "F87": {
      "label": "strengths lead, torchaudio",
      "display": "Runs resampling on GPUs",
      "asOf": "2026-11-17"
    },
    "F88": {
      "label": "strengths, torchaudio",
      "display": "Use tensor convolution to resample audio on compatible GPU hardware.",
      "asOf": "2026-11-17"
    },
    "F89": {
      "label": "limitations lead, torchaudio",
      "display": "Audio decoding needs TorchCodec",
      "asOf": "2026-11-17"
    },
    "F90": {
      "label": "limitations, torchaudio",
      "display": "Install TorchCodec for load and save, or use its classes directly.",
      "asOf": "2026-11-17"
    },
    "F91": {
      "label": "Quickstart, torchaudio",
      "display": "import torch\nimport torchaudio\nimport torchaudio.functional as F\nimport torchaudio.transforms as T\n\nprint(torch.__version__)\nprint(torchaudio.__version__)\n\nimport math\nimport timeit\n\nimport matplotlib.pyplot as plt\nfrom IPython.display import Audio\nimport numpy as np\n\nDEFAULT_OFFSET = 201\n\n\ndef _get_log_freq(sample_rate, max_sweep_rate, offset):\n    \"\"\"Get freqs evenly spaced out in log-scale, between [0, max_sweep_rate // 2]\n\n    offset is used to avoid negative infinity `log(offset + x)`.\n\n    \"\"\"\n    start, stop = math.log(offset), math.log(offset + max_sweep_rate // 2)\n    return torch.exp(torch.linspace(start, stop, sample_rate, dtype=torch.double)) - offset\n\n\ndef _get_inverse_log_freq(freq, sample_rate, offset):\n    \"\"\"Find the time where the given frequency is given by _get_log_freq\"\"\"\n    half = sample_rate // 2\n    return sample_rate * (math.log(1 + freq / offset) / math.log(1 + half / offset))\n\n\ndef _get_freq_ticks(sample_rate, offset, f_max):\n    # Given the original sample rate used for generating the sweep,\n    # find the x-axis value where the log-scale major frequency values fall in\n    times, freq = [], []\n    for exp in range(2, 5):\n        for v in range(1, 10):\n            f = v * 10**exp\n            if f < sample_rate // 2:\n                t = _get_inverse_log_freq(f, sample_rate, offset) / sample_rate\n                times.append(t)\n                freq.append(f)\n    t_max = _get_inverse_log_freq(f_max, sample_rate, offset) / sample_rate\n    times.append(t_max)\n    freq.append(f_max)\n    return times, freq\n\n\ndef get_sine_sweep(sample_rate, offset=DEFAULT_OFFSET):\n    max_sweep_rate = sample_rate\n    freq = _get_log_freq(sample_rate, max_sweep_rate, offset)\n    delta = 2 * math.pi * freq / sample_rate\n    cummulative = torch.cumsum(delta, dim=0)\n    signal = torch.sin(cummulative).unsqueeze(dim=0)\n    return signal\n\n\ndef plot_sweep(\n    waveform,\n    sample_rate,\n    title,\n    max_sweep_rate=48000,\n    offset=DEFAULT_OFFSET,\n):\n    x_ticks = [100, 500, 1000, 5000, 10000, 20000, max_sweep_rate // 2]\n    y_ticks = [1000, 5000, 10000, 20000, sample_rate // 2]\n\n    time, freq = _get_freq_ticks(max_sweep_rate, offset, sample_rate // 2)\n    freq_x = [f if f in x_ticks and f <= max_sweep_rate // 2 else None for f in freq]\n    freq_y = [f for f in freq if f in y_ticks and 1000 <= f <= sample_rate // 2]\n\n    figure, axis = plt.subplots(1, 1)\n    _, _, _, cax = axis.specgram(waveform[0].numpy(), Fs=sample_rate)\n    plt.xticks(time, freq_x)\n    plt.yticks(freq_y, freq_y)\n    axis.set_xlabel(\"Original Signal Frequency (Hz, log scale)\")\n    axis.set_ylabel(\"Waveform Frequency (Hz)\")\n    axis.xaxis.grid(True, alpha=0.67)\n    axis.yaxis.grid(True, alpha=0.67)\n    figure.suptitle(f\"{title} (sample rate: {sample_rate} Hz)\")\n    plt.colorbar(cax)\n\nsample_rate = 48000\nwaveform = get_sine_sweep(sample_rate)\n\nplot_sweep(waveform, sample_rate, title=\"Original Waveform\")\nAudio(waveform.numpy()[0], rate=sample_rate)\n\nresample_rate = 32000\nresampler = T.Resample(sample_rate, resample_rate, dtype=waveform.dtype)\nresampled_waveform = resampler(waveform)\n\nplot_sweep(resampled_waveform, resample_rate, title=\"Resampled Waveform\")\nAudio(resampled_waveform.numpy()[0], rate=resample_rate)\n",
      "asOf": "2026-11-17"
    },
    "F92": {
      "label": "Developer need",
      "display": "Music and rhythm analysis",
      "asOf": "2026-11-17"
    },
    "F93": {
      "label": "Why choose librosa",
      "display": "rhythm and onset-strength analysis",
      "asOf": "2026-11-17"
    },
    "F94": {
      "label": "Developer need in introduction",
      "display": "music and rhythm analysis",
      "asOf": "2026-11-17"
    },
    "F95": {
      "label": "When to consider soundfile",
      "display": "the task only needs audio decoding and encoding",
      "asOf": "2026-11-17"
    },
    "F96": {
      "label": "Developer need",
      "display": "Reading and writing audio files",
      "asOf": "2026-11-17"
    },
    "F97": {
      "label": "Why choose soundfile",
      "display": "direct audio-file I/O",
      "asOf": "2026-11-17"
    },
    "F98": {
      "label": "Developer need in introduction",
      "display": "reading and writing audio files",
      "asOf": "2026-11-17"
    },
    "F99": {
      "label": "When to consider librosa",
      "display": "the decoded audio needs rhythm analysis",
      "asOf": "2026-11-17"
    },
    "F100": {
      "label": "Developer need",
      "display": "Editing and mixing audio clips",
      "asOf": "2026-11-17"
    },
    "F101": {
      "label": "Why choose pydub",
      "display": "simple clip-editing operations",
      "asOf": "2026-11-17"
    },
    "F102": {
      "label": "Developer need in introduction",
      "display": "editing and mixing audio clips",
      "asOf": "2026-11-17"
    },
    "F103": {
      "label": "When to consider torchaudio",
      "display": "waveform tensors feed a PyTorch pipeline",
      "asOf": "2026-11-17"
    },
    "F104": {
      "label": "Developer need",
      "display": "PyTorch waveform processing",
      "asOf": "2026-11-17"
    },
    "F105": {
      "label": "Why choose torchaudio",
      "display": "functional and transform-based resampling",
      "asOf": "2026-11-17"
    },
    "F106": {
      "label": "Developer need in introduction",
      "display": "PyTorch waveform processing",
      "asOf": "2026-11-17"
    },
    "F107": {
      "label": "Page introduction",
      "display": "Python audio processing libraries let application developers read, transform, and analyze audio data.",
      "asOf": "2026-11-17"
    },
    "F108": {
      "label": "FAQ: What is the best Python audio processing library?",
      "display": "Choose librosa for audio and music signal analysis.",
      "asOf": "2026-11-17"
    },
    "F109": {
      "label": "FAQ: What is the best Python audio processing library?",
      "display": "Choose SoundFile for audio-file reading and writing.",
      "asOf": "2026-11-17"
    },
    "F110": {
      "label": "FAQ: What is the best Python audio processing library?",
      "display": "Pydub provides AudioSegment editing operations.",
      "asOf": "2026-11-17"
    },
    "F111": {
      "label": "FAQ: What is the best Python audio processing library?",
      "display": "TorchAudio resamples PyTorch waveform tensors.",
      "asOf": "2026-11-17"
    },
    "F112": {
      "label": "FAQ: Why did librosa change the sample rate or channel count?",
      "display": "librosa.load resamples by default; sr=None preserves the native sample rate.",
      "asOf": "2026-11-17"
    },
    "F113": {
      "label": "FAQ: Why did librosa change the sample rate or channel count?",
      "display": "The mono argument defaults to enabled; disable it to preserve separate channels.",
      "asOf": "2026-11-17"
    },
    "F114": {
      "label": "FAQ: How can I process a long recording in smaller pieces?",
      "display": "SoundFile reads short overlapping blocks through soundfile.blocks.",
      "asOf": "2026-11-17"
    },
    "F115": {
      "label": "FAQ: Does Pydub need ffmpeg?",
      "display": "Pydub opens and saves WAV files in Python, while formats such as MP3 require ffmpeg or libav.",
      "asOf": "2026-11-17"
    },
    "F116": {
      "label": "FAQ: Does TorchAudio still load and save audio directly?",
      "display": "Current load and save APIs are thin wrappers around TorchCodec and require that extra dependency.",
      "asOf": "2026-11-17"
    },
    "F117": {
      "label": "FAQ: Is TorchAudio still being developed?",
      "display": "TorchAudio has entered maintenance.",
      "asOf": "2026-11-17"
    },
    "F118": {
      "label": "FAQ: Is TorchAudio still being developed?",
      "display": "PyTorch audio/video decoding and encoding have consolidated into TorchCodec.",
      "asOf": "2026-11-17"
    },
    "F119": {
      "label": "Library name, av",
      "display": "PyAV",
      "asOf": "2026-11-20"
    },
    "F120": {
      "label": "Monthly downloads, av",
      "display": "52.3M",
      "asOf": "2026-11-20"
    },
    "F121": {
      "label": "License, av",
      "display": "BSD-3-Clause",
      "asOf": "2026-11-20"
    },
    "F122": {
      "label": "Package release, av",
      "display": "19.0.2",
      "asOf": "2026-11-20"
    },
    "F123": {
      "label": "Package release date, av",
      "display": "Oct 2026",
      "asOf": "2026-11-20"
    },
    "F124": {
      "label": "Install, av",
      "display": "pip install av",
      "asOf": "2026-11-20"
    },
    "F125": {
      "label": "Quickstart, av",
      "display": "import av\nwith av.open('input.wav') as container:\n    frame = next(container.decode(audio=0))\n    samples = frame.to_ndarray()\n",
      "asOf": "2026-11-20"
    },
    "F126": {
      "label": "Official description, av",
      "display": "Binds the FFmpeg libraries for Python.",
      "asOf": "2026-11-20"
    },
    "F127": {
      "label": "Quickstart source file, av",
      "display": "docs/api/container.rst and audio.rst (API recipe)",
      "asOf": "2026-11-20"
    },
    "F128": {
      "label": "Repository stars, av",
      "display": "3.3K",
      "asOf": "2026-11-20"
    },
    "F129": {
      "label": "Audio file encoding, av",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F130": {
      "label": "Sample-rate conversion, av",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F131": {
      "label": "Runtime, av",
      "display": "FFmpeg library bindings, not CLI subprocess wrapper",
      "asOf": "2026-11-20"
    },
    "F132": {
      "label": "Project function, av",
      "display": "def convert_audio(input_path: Path, output_path: Path, codec_name: str):\n    with (\n        av.open(input_path) as input_audio,\n        av.open(output_path, \"w\") as output_audio,\n    ):\n        input_audio_stream = input_audio.streams.audio[0]\n        output_audio_stream = output_audio.add_stream(codec_name)\n        for frame in input_audio.decode(input_audio_stream):\n            for packet in output_audio_stream.encode(frame):\n                output_audio.mux(packet)\n\n        for packet in output_audio_stream.encode():\n            output_audio.mux(packet)",
      "asOf": "2026-11-20"
    },
    "F133": {
      "label": "Project source file, av",
      "display": "manim/scene/scene_file_writer.py",
      "asOf": "2026-11-20"
    },
    "F134": {
      "label": "Project full_name, av",
      "display": "ManimCommunity/manim",
      "asOf": "2026-11-20"
    },
    "F135": {
      "label": "Project stargazers_count, av",
      "display": "42.6K",
      "asOf": "2026-11-20"
    },
    "F136": {
      "label": "Library name, soundfile",
      "display": "SoundFile",
      "asOf": "2026-11-20"
    },
    "F137": {
      "label": "Monthly downloads, soundfile",
      "display": "35.5M",
      "asOf": "2026-11-20"
    },
    "F138": {
      "label": "License, soundfile",
      "display": "BSD-3-Clause",
      "asOf": "2026-11-20"
    },
    "F139": {
      "label": "Package release, soundfile",
      "display": "0.14.0",
      "asOf": "2026-11-20"
    },
    "F140": {
      "label": "Package release date, soundfile",
      "display": "Jun 2026",
      "asOf": "2026-11-20"
    },
    "F141": {
      "label": "Install, soundfile",
      "display": "pip install soundfile",
      "asOf": "2026-11-20"
    },
    "F142": {
      "label": "Quickstart, soundfile",
      "display": "import soundfile as sf\nsamples, sample_rate = sf.read('input.wav')\n",
      "asOf": "2026-11-20"
    },
    "F143": {
      "label": "Repository stars, soundfile",
      "display": "874",
      "asOf": "2026-11-20"
    },
    "F144": {
      "label": "Audio file encoding, soundfile",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F145": {
      "label": "Sample-rate conversion, soundfile",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F146": {
      "label": "Runtime, soundfile",
      "display": "NumPy arrays and libsndfile",
      "asOf": "2026-11-20"
    },
    "F147": {
      "label": "Project function, soundfile",
      "display": "def __soundfile_load(path, offset, duration, dtype):\n    \"\"\"Load an audio buffer using soundfile.\"\"\"\n    if isinstance(path, sf.SoundFile):\n        # If the user passed an existing soundfile object,\n        # we can use it directly\n        context = path\n    else:\n        # Otherwise, create the soundfile object\n        context = sf.SoundFile(path)\n\n    with context as sf_desc:\n        sr_native = sf_desc.samplerate\n        if offset != 0:\n            if offset > 0:\n                # Seek to the start of the target read\n                sf_desc.seek(int(offset * sr_native))\n            else:\n                sf_desc.seek(-int(abs(offset) * sr_native), whence=sf.SEEK_END)\n\n        if duration is not None:\n            frame_duration = int(duration * sr_native)\n        else:\n            frame_duration = -1\n\n        # Load the target number of frames, and transpose to match librosa form\n        y = sf_desc.read(frames=frame_duration, dtype=dtype, always_2d=False).T\n\n    return y, sr_native",
      "asOf": "2026-11-20"
    },
    "F148": {
      "label": "Project source file, soundfile",
      "display": "librosa/core/audio.py",
      "asOf": "2026-11-20"
    },
    "F149": {
      "label": "Project full_name, soundfile",
      "display": "librosa/librosa",
      "asOf": "2026-11-20"
    },
    "F150": {
      "label": "Project stargazers_count, soundfile",
      "display": "9.0K",
      "asOf": "2026-11-20"
    },
    "F151": {
      "label": "Library name, pydub",
      "display": "pydub",
      "asOf": "2026-11-20"
    },
    "F152": {
      "label": "Monthly downloads, pydub",
      "display": "17.2M",
      "asOf": "2026-11-20"
    },
    "F153": {
      "label": "License, pydub",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F154": {
      "label": "Package release, pydub",
      "display": "0.25.1",
      "asOf": "2026-11-20"
    },
    "F155": {
      "label": "Package release date, pydub",
      "display": "Mar 2021",
      "asOf": "2026-11-20"
    },
    "F156": {
      "label": "Install, pydub",
      "display": "pip install pydub",
      "asOf": "2026-11-20"
    },
    "F157": {
      "label": "Quickstart, pydub",
      "display": "from pydub import AudioSegment\naudio = AudioSegment.from_wav('input.wav')\n",
      "asOf": "2026-11-20"
    },
    "F158": {
      "label": "Repository stars, pydub",
      "display": "9.8K",
      "asOf": "2026-11-20"
    },
    "F159": {
      "label": "Audio file encoding, pydub",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F160": {
      "label": "Sample-rate conversion, pydub",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F161": {
      "label": "Runtime, pydub",
      "display": "Immutable AudioSegment operations with millisecond positions",
      "asOf": "2026-11-20"
    },
    "F162": {
      "label": "Project function, pydub",
      "display": "def add_audio_segment(\n    self,\n    new_segment: AudioSegment,\n    time: float | None = None,\n    gain_to_background: float | None = None,\n):\n    \"\"\"\n    This method adds an audio segment from an\n    AudioSegment type object and suitable parameters.\n\n    Parameters\n    ----------\n    new_segment\n        The audio segment to add\n\n    time\n        the timestamp at which the\n        sound should be added.\n\n    gain_to_background\n        The gain of the segment from the background.\n    \"\"\"\n    if not self.includes_sound:\n        self.includes_sound = True\n        self.create_audio_segment()\n    segment = self.audio_segment\n    curr_end = segment.duration_seconds\n    if time is None:\n        time = curr_end\n    if time < 0:\n        raise ValueError(\"Adding sound at timestamp < 0\")\n\n    new_end = time + new_segment.duration_seconds\n    diff = new_end - curr_end\n    if diff > 0:\n        segment = segment.append(\n            AudioSegment.silent(int(np.ceil(diff * 1000))),\n            crossfade=0,\n        )\n    self.audio_segment = segment.overlay(\n        new_segment,\n        position=int(1000 * time),\n        gain_during_overlay=gain_to_background,\n    )",
      "asOf": "2026-11-20"
    },
    "F163": {
      "label": "Project source file, pydub",
      "display": "manim/scene/scene_file_writer.py",
      "asOf": "2026-11-20"
    },
    "F164": {
      "label": "Project full_name, pydub",
      "display": "ManimCommunity/manim",
      "asOf": "2026-11-20"
    },
    "F165": {
      "label": "Project stargazers_count, pydub",
      "display": "42.6K",
      "asOf": "2026-11-20"
    },
    "F166": {
      "label": "Library name, soxr",
      "display": "Python-SoXR",
      "asOf": "2026-11-20"
    },
    "F167": {
      "label": "Monthly downloads, soxr",
      "display": "13.9M",
      "asOf": "2026-11-20"
    },
    "F168": {
      "label": "License, soxr",
      "display": "LGPL-2.1-or-later",
      "asOf": "2026-11-20"
    },
    "F169": {
      "label": "Package release, soxr",
      "display": "1.1.0",
      "asOf": "2026-11-20"
    },
    "F170": {
      "label": "Package release date, soxr",
      "display": "May 2026",
      "asOf": "2026-11-20"
    },
    "F171": {
      "label": "Install, soxr",
      "display": "pip install soxr",
      "asOf": "2026-11-20"
    },
    "F172": {
      "label": "Quickstart, soxr",
      "display": "import numpy as np\nimport soxr\nsamples = np.zeros(48000, dtype=np.float32)\nconverted = soxr.resample(samples, 48000, 16000)\n",
      "asOf": "2026-11-20"
    },
    "F173": {
      "label": "Official description, soxr",
      "display": "Converts one-dimensional audio between sample rates.",
      "asOf": "2026-11-20"
    },
    "F174": {
      "label": "Quickstart source file, soxr",
      "display": "docs/soxr.rst (API recipe)",
      "asOf": "2026-11-20"
    },
    "F175": {
      "label": "Repository stars, soxr",
      "display": "119",
      "asOf": "2026-11-20"
    },
    "F176": {
      "label": "Audio file encoding, soxr",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F177": {
      "label": "Sample-rate conversion, soxr",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F178": {
      "label": "Array/stream boundary, soxr",
      "display": "One-shot arrays or persistent ResampleStream",
      "asOf": "2026-11-20"
    },
    "F179": {
      "label": "Project function, soxr",
      "display": "def signal2spect(self, signal, sr):\n    if signal.ndim == 2:\n        signal = signal.mean(1)\n    elif signal.ndim != 1:\n        raise ValueError(f\"Expected 1D or 2D signal, got shape {signal.shape}\")\n    if sr != 22050:\n        signal = soxr.resample(signal, in_rate=sr, out_rate=22050)\n    signal = torch.tensor(signal, dtype=torch.float32, device=self.device)\n    return self.spect(signal)",
      "asOf": "2026-11-20"
    },
    "F180": {
      "label": "Project source file, soxr",
      "display": "beat_this/inference.py",
      "asOf": "2026-11-20"
    },
    "F181": {
      "label": "Project full_name, soxr",
      "display": "CPJKU/beat_this",
      "asOf": "2026-11-20"
    },
    "F182": {
      "label": "Project stargazers_count, soxr",
      "display": "489",
      "asOf": "2026-11-20"
    },
    "F183": {
      "label": "Library name, ffmpeg-python",
      "display": "ffmpeg-python",
      "asOf": "2026-11-20"
    },
    "F184": {
      "label": "Monthly downloads, ffmpeg-python",
      "display": "11.1M",
      "asOf": "2026-11-20"
    },
    "F185": {
      "label": "License, ffmpeg-python",
      "display": "Apache-2.0",
      "asOf": "2026-11-20"
    },
    "F186": {
      "label": "Package release, ffmpeg-python",
      "display": "0.2.0",
      "asOf": "2026-11-20"
    },
    "F187": {
      "label": "Package release date, ffmpeg-python",
      "display": "Jul 2019",
      "asOf": "2026-11-20"
    },
    "F188": {
      "label": "Install, ffmpeg-python",
      "display": "pip install ffmpeg-python",
      "asOf": "2026-11-20"
    },
    "F189": {
      "label": "Quickstart, ffmpeg-python",
      "display": "import ffmpeg\nffmpeg.input('input.wav').output('output.flac').run()\n",
      "asOf": "2026-11-20"
    },
    "F190": {
      "label": "Official description, ffmpeg-python",
      "display": "Builds FFmpeg commands with complex filtering from Python.",
      "asOf": "2026-11-20"
    },
    "F191": {
      "label": "Quickstart source file, ffmpeg-python",
      "display": "README.md and public API (API recipe)",
      "asOf": "2026-11-20"
    },
    "F192": {
      "label": "Repository stars, ffmpeg-python",
      "display": "11.0K",
      "asOf": "2026-11-20"
    },
    "F193": {
      "label": "Audio file encoding, ffmpeg-python",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F194": {
      "label": "Sample-rate conversion, ffmpeg-python",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F195": {
      "label": "Runtime, ffmpeg-python",
      "display": "Python FFmpeg graph builder; executable installed separately",
      "asOf": "2026-11-20"
    },
    "F196": {
      "label": "Project function, ffmpeg-python",
      "display": "def load_audio(file: str, sr: int = SAMPLE_RATE):\n    \"\"\"\n    Open an audio file and read as mono waveform, resampling as necessary\n\n    Parameters\n    ----------\n    file: str\n        The audio file to open\n\n    sr: int\n        The sample rate to resample the audio if necessary\n\n    Returns\n    -------\n    A NumPy array containing the audio waveform, in float32 dtype.\n    \"\"\"\n    try:\n        # This launches a subprocess to decode audio while down-mixing and resampling as necessary.\n        # Requires the ffmpeg CLI and `ffmpeg-python` package to be installed.\n        out, _ = (\n            ffmpeg.input(file, threads=0)\n            .output(\"-\", format=\"s16le\", acodec=\"pcm_s16le\", ac=1, ar=sr)\n            .run(cmd=[\"ffmpeg\", \"-nostdin\"], capture_stdout=True, capture_stderr=True)\n        )\n    except ffmpeg.Error as e:\n        raise RuntimeError(f\"Failed to load audio: {e.stderr.decode()}\") from e\n\n    return np.frombuffer(out, np.int16).flatten().astype(np.float32) / 32768.0",
      "asOf": "2026-11-20"
    },
    "F197": {
      "label": "Project source file, ffmpeg-python",
      "display": "whisper/audio.py",
      "asOf": "2026-11-20"
    },
    "F198": {
      "label": "Project full_name, ffmpeg-python",
      "display": "openai/whisper",
      "asOf": "2026-11-20"
    },
    "F199": {
      "label": "Project stargazers_count, ffmpeg-python",
      "display": "113.0K",
      "asOf": "2026-11-20"
    },
    "F200": {
      "label": "Library name, librosa",
      "display": "librosa",
      "asOf": "2026-11-20"
    },
    "F201": {
      "label": "Monthly downloads, librosa",
      "display": "11.1M",
      "asOf": "2026-11-20"
    },
    "F202": {
      "label": "License, librosa",
      "display": "ISC",
      "asOf": "2026-11-20"
    },
    "F203": {
      "label": "Package release, librosa",
      "display": "1.0.1",
      "asOf": "2026-11-20"
    },
    "F204": {
      "label": "Package release date, librosa",
      "display": "Nov 2026",
      "asOf": "2026-11-20"
    },
    "F205": {
      "label": "Install, librosa",
      "display": "pip install librosa",
      "asOf": "2026-11-20"
    },
    "F206": {
      "label": "Quickstart, librosa",
      "display": "import librosa\nsamples, sample_rate = librosa.load('input.wav', sr=None)\n",
      "asOf": "2026-11-20"
    },
    "F207": {
      "label": "Repository stars, librosa",
      "display": "9.0K",
      "asOf": "2026-11-20"
    },
    "F208": {
      "label": "Audio file encoding, librosa",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F209": {
      "label": "Sample-rate conversion, librosa",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F210": {
      "label": "Scope, librosa",
      "display": "Music/audio analysis and feature transforms",
      "asOf": "2026-11-20"
    },
    "F211": {
      "label": "Project function, librosa",
      "display": "def build_mel_basis(\n    *,\n    sample_rate: int = None,\n    fft_size: int = None,\n    num_mels: int = None,\n    mel_fmax: int = None,\n    mel_fmin: int = None,\n    **kwargs,\n) -> np.ndarray:\n    \"\"\"Build melspectrogram basis.\n\n    Returns:\n        np.ndarray: melspectrogram basis.\n    \"\"\"\n    if mel_fmax is not None:\n        assert mel_fmax <= sample_rate // 2\n        assert mel_fmax - mel_fmin > 0\n    return librosa.filters.mel(sr=sample_rate, n_fft=fft_size, n_mels=num_mels, fmin=mel_fmin, fmax=mel_fmax)",
      "asOf": "2026-11-20"
    },
    "F212": {
      "label": "Project source file, librosa",
      "display": "TTS/utils/audio/numpy_transforms.py",
      "asOf": "2026-11-20"
    },
    "F213": {
      "label": "Project full_name, librosa",
      "display": "coqui-ai/TTS",
      "asOf": "2026-11-20"
    },
    "F214": {
      "label": "Project stargazers_count, librosa",
      "display": "46.2K",
      "asOf": "2026-11-20"
    },
    "F215": {
      "label": "Library name, audioread",
      "display": "audioread",
      "asOf": "2026-11-20"
    },
    "F216": {
      "label": "Monthly downloads, audioread",
      "display": "7.4M",
      "asOf": "2026-11-20"
    },
    "F217": {
      "label": "License, audioread",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F218": {
      "label": "Package release, audioread",
      "display": "3.1.0",
      "asOf": "2026-11-20"
    },
    "F219": {
      "label": "Package release date, audioread",
      "display": "Oct 2025",
      "asOf": "2026-11-20"
    },
    "F220": {
      "label": "Install, audioread",
      "display": "pip install audioread",
      "asOf": "2026-11-20"
    },
    "F221": {
      "label": "Quickstart, audioread",
      "display": "import audioread\nwith audioread.audio_open('input.wav') as audio:\n    sample_rate = audio.samplerate\n",
      "asOf": "2026-11-20"
    },
    "F222": {
      "label": "Official description, audioread",
      "display": "Decodes audio across platforms through several backend libraries.",
      "asOf": "2026-11-20"
    },
    "F223": {
      "label": "Quickstart source file, audioread",
      "display": "README.rst (API recipe)",
      "asOf": "2026-11-20"
    },
    "F224": {
      "label": "Repository stars, audioread",
      "display": "540",
      "asOf": "2026-11-20"
    },
    "F225": {
      "label": "Audio file encoding, audioread",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F226": {
      "label": "Sample-rate conversion, audioread",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F227": {
      "label": "PCM boundary, audioread",
      "display": "Signed little-endian integer PCM bytes from selected decoder",
      "asOf": "2026-11-20"
    },
    "F228": {
      "label": "Project function, audioread",
      "display": "def audioread_info(path: Pathlike) -> LibsndfileCompatibleAudioInfo:\n    \"\"\"\n    Return an audio info data structure that's a compatible subset of ``pysoundfile.info()``\n    that we need to create a ``Recording`` manifest.\n    \"\"\"\n    import audioread\n\n    # We just read the file and compute the number of samples\n    # -- no other method seems fully reliable...\n    with audioread.audio_open(\n        str(path), backends=_available_audioread_backends()\n    ) as input_file:\n        shape = audioread_load(input_file)[0].shape\n        if len(shape) == 1:\n            num_samples = shape[0]\n        else:\n            num_samples = shape[1]\n        return LibsndfileCompatibleAudioInfo(\n            channels=input_file.channels,\n            frames=num_samples,\n            samplerate=int(input_file.samplerate),\n            duration=num_samples / input_file.samplerate,\n        )",
      "asOf": "2026-11-20"
    },
    "F229": {
      "label": "Project source file, audioread",
      "display": "lhotse/audio/backend.py",
      "asOf": "2026-11-20"
    },
    "F230": {
      "label": "Project full_name, audioread",
      "display": "lhotse-speech/lhotse",
      "asOf": "2026-11-20"
    },
    "F231": {
      "label": "Project stargazers_count, audioread",
      "display": "1.2K",
      "asOf": "2026-11-20"
    },
    "F232": {
      "label": "Library name, torchaudio",
      "display": "TorchAudio",
      "asOf": "2026-11-20"
    },
    "F233": {
      "label": "Monthly downloads, torchaudio",
      "display": "5.8M",
      "asOf": "2026-11-20"
    },
    "F234": {
      "label": "License, torchaudio",
      "display": "BSD-2-Clause",
      "asOf": "2026-11-20"
    },
    "F235": {
      "label": "Package release, torchaudio",
      "display": "2.11.1",
      "asOf": "2026-11-20"
    },
    "F236": {
      "label": "Package release date, torchaudio",
      "display": "Oct 2026",
      "asOf": "2026-11-20"
    },
    "F237": {
      "label": "Install, torchaudio",
      "display": "pip install torch==2.11.1 torchaudio==2.11.1",
      "asOf": "2026-11-20"
    },
    "F238": {
      "label": "Quickstart, torchaudio",
      "display": "import torch\nfrom torchaudio.transforms import Resample\nwaveform = torch.zeros(1, 16000)\nconverted = Resample(orig_freq=16000, new_freq=8000)(waveform)\n",
      "asOf": "2026-11-20"
    },
    "F239": {
      "label": "Repository stars, torchaudio",
      "display": "3.0K",
      "asOf": "2026-11-20"
    },
    "F240": {
      "label": "Audio file encoding, torchaudio",
      "display": "Via plugin",
      "asOf": "2026-11-20"
    },
    "F241": {
      "label": "Sample-rate conversion, torchaudio",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F242": {
      "label": "Runtime, torchaudio",
      "display": "Torch tensors with PyTorch>=2.11; current I/O uses TorchCodec",
      "asOf": "2026-11-20"
    },
    "F243": {
      "label": "Project function, torchaudio",
      "display": "@staticmethod\ndef resample_audio(\n    audio: dict[str, Any],\n    *,\n    target_sampling_rate: int,\n    max_samples: int | None = None,\n) -> np.typing.NDArray[np.floating]:\n    \"\"\"Resample an audio input to a target sampling rate and optionally truncate to a maximum number of samples.\n\n    Args:\n        audio: A list of dictionaries containing audio data under the \"audio\" key, where each audio is a dictionary with \"array\" and \"sampling_rate\" keys.\n        target_sampling_rate: The sampling rate to resample the audio to.\n        max_samples: The maximum number of samples to keep for each audio. If None, no truncation is applied.\n    \"\"\"\n    import torchaudio\n\n    audio = audio[\"audio\"]\n    if audio[\"sampling_rate\"] != target_sampling_rate:\n        logger.debug(\n            f\"Resampling audio from {audio['sampling_rate']} Hz to {target_sampling_rate} Hz.\"\n        )\n        resampler = torchaudio.transforms.Resample(\n            orig_freq=audio[\"sampling_rate\"],\n            new_freq=target_sampling_rate,\n        )\n        audio_array = resampler(torch.from_numpy(audio[\"array\"]).float()).numpy()\n    else:\n        audio_array = audio[\"array\"]\n\n    # Convert to mono if needed\n    if audio_array.ndim > 1 and audio_array.shape[0] > 1:\n        audio_array = np.mean(audio_array, axis=0)\n\n    if max_samples is not None:\n        num_samples = audio_array.shape[-1]\n        if num_samples > max_samples:\n            audio_array = audio_array[..., :max_samples]\n\n    audio_array = cast(\n        \"np.ndarray[tuple[Any, ...], np.dtype[np.floating[Any]]]\",\n        audio_array,\n    )\n    return audio_array",
      "asOf": "2026-11-20"
    },
    "F244": {
      "label": "Project source file, torchaudio",
      "display": "mteb/models/modality_collators.py",
      "asOf": "2026-11-20"
    },
    "F245": {
      "label": "Project full_name, torchaudio",
      "display": "embeddings-benchmark/mteb",
      "asOf": "2026-11-20"
    },
    "F246": {
      "label": "Project stargazers_count, torchaudio",
      "display": "3.5K",
      "asOf": "2026-11-20"
    }
  },
  "dataCheckedAt": "2026-11-20",
  "agent": {
    "exaCall": {
      "endpoint": "/search",
      "body": {
        "query": "Best Python audio processing libraries librosa soundfile pydub torchaudio resampling features editing code examples",
        "numResults": 5
      },
      "docsUrl": "https://exa.ai/docs/reference/search"
    },
    "calls": []
  }
}
