kandi background

python-soundfile | SoundFile is an audio library based on libsndfile, CFFI, and NumPy | Data Manipulation library

Download this library from

kandi X-RAY | python-soundfile Summary

python-soundfile is a Python library typically used in Utilities, Data Manipulation, Numpy applications. python-soundfile has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has low support. You can download it from GitHub.
SoundFile is an audio library based on libsndfile, CFFI, and NumPy

kandi-support Support

  • python-soundfile has a low active ecosystem.
  • It has 437 star(s) with 65 fork(s). There are 17 watchers for this library.
  • There were 1 major release(s) in the last 6 months.
  • There are 63 open issues and 99 have been closed. On average issues are closed in 13 days. There are 8 open pull requests and 0 closed requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of python-soundfile is 0.11.0b1

quality kandi Quality

  • python-soundfile has 0 bugs and 0 code smells.

securitySecurity

  • python-soundfile has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • python-soundfile code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.

license License

  • python-soundfile is licensed under the BSD-3-Clause License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.

buildReuse

  • python-soundfile releases are available to install and integrate.
  • Build file is available. You can build the component from source.
  • python-soundfile saves you 796 person hours of effort in developing the same functionality from scratch.
  • It has 1908 lines of code, 200 functions and 10 files.
  • It has high code complexity. Code complexity directly impacts maintainability of the code.
Top functions reviewed by kandi - BETA

kandi has reviewed python-soundfile and discovered the below as its top functions. This is intended to give you an instant insight into python-soundfile implemented functionality, and help decide if they suit your requirements.

  • Initialize the file .
  • Generate blocks from a sound file .
  • Format an unsigned integer .
  • Create a SF_INFO struct .
  • Get the format from a filename .
  • Return available subtypes .
  • Return available formats .
  • Check mode .
  • Check if a format is valid .
  • Return the default subtype for the given format .

python-soundfile Key Features

SoundFile is an audio library based on libsndfile, CFFI, and NumPy

python-soundfile Examples and Code Snippets

  • Convert from opus to ogg file using ffmpeg [python soundfile]

Convert from opus to ogg file using ffmpeg [python soundfile]

# converting opus to ogg files for reading audio files with python soundfile
from glob import glob
from tqdm import tqdm
import soundfile as sf 
import librosa
import os

for f in tqdm(glob("/Data/AUDIO_DATA/mls_dutch_opus/*/audio/*/*/*.opus") + glob("/Data/AUDIO_DATA/mls_german_opus/*/audio/*/*/*.opus")):
    audio, sr = librosa.load(f, res_type='kaiser_fast', sr = 16000)
    sf.write(f.replace(".opus", ".ogg"), audio, sr, format='ogg', subtype='vorbis')
    os.remove(f)
-----------------------
ffmpeg -i input.opus -c:a vorbis -strict experimental output.ogg
ffmpeg -i input.opus -f wav - | oggenc -o output.ogg -
-----------------------
ffmpeg -i input.opus -c:a vorbis -strict experimental output.ogg
ffmpeg -i input.opus -f wav - | oggenc -o output.ogg -

Community Discussions

Trending Discussions on python-soundfile
  • Convert from opus to ogg file using ffmpeg [python soundfile]
Trending Discussions on python-soundfile

QUESTION

Convert from opus to ogg file using ffmpeg [python soundfile]

Asked 2021-Sep-27 at 16:16

I'm using python soundfile to audio files in one of my projects. I have a dataset that contains opus files.

python soundfile can not read opus files directly but can read ogg files. (https://github.com/bastibe/python-soundfile/issues/252)

How can I convert all the opus files to ogg files with ffmpeg?

I have tried the following command,

 ffmpeg -i test_file_2.opus -c:a libvorbis -b:a 16k test_file_2.ogg

But I get an error,

ffmpeg version 4.3 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 7.3.0 (crosstool-NG 1.23.0.449-a04d0)
  configuration: --prefix=/opt/conda --cc=/opt/conda/conda-bld/ffmpeg_1597178665428/_build_env/bin/x86_64-conda_cos6-linux-gnu-cc --disable-doc --disable-openssl --enable-avresample --enable-gnutls --enable-hardcoded-tables --enable-libfreetype --enable-libopenh264 --enable-pic --enable-pthreads --enable-shared --disable-static --enable-version3 --enable-zlib --enable-libmp3lame
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
[ogg @ 0x55bad6b9cbc0] 543 bytes of comment header remain
Input #0, ogg, from 'test_file_2.opus':
  Duration: 00:00:14.10, start: 0.000000, bitrate: 34 kb/s
    Stream #0:0: Audio: opus, 48000 Hz, mono, fltp
    Metadata:
      album           : Onder Moeders Vleugels
      ENCODER_OPTIONS : --quiet
      artist          : Louisa May Alcott
      title           : 02 - Een vroolijk kerstfeest
      encoder         : opusenc from opus-tools 0.1.10;Lavf57.83.100
Unknown encoder 'libvorbis'

ANSWER

Answered 2021-Sep-27 at 11:13

I'm using librosa right now for conversion, but this is extremely slow:

# converting opus to ogg files for reading audio files with python soundfile
from glob import glob
from tqdm import tqdm
import soundfile as sf 
import librosa
import os

for f in tqdm(glob("/Data/AUDIO_DATA/mls_dutch_opus/*/audio/*/*/*.opus") + glob("/Data/AUDIO_DATA/mls_german_opus/*/audio/*/*/*.opus")):
    audio, sr = librosa.load(f, res_type='kaiser_fast', sr = 16000)
    sf.write(f.replace(".opus", ".ogg"), audio, sr, format='ogg', subtype='vorbis')
    os.remove(f)

Source https://stackoverflow.com/questions/69342452

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install python-soundfile

You can download it from GitHub.
You can use python-soundfile like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.

Support

For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .

Explore Related Topics

Build your Application

Share this kandi XRay Report