当前位置:网站首页>Wave view audio information

Wave view audio information

2022-06-12 02:22:00 weixin_ forty-five million nine hundred and sixty-five thousand

View audio information

import wave
def info_wav(wavFile):
    f = wave.open(wavFile)
    #  Audio head   Parameters 
    params = f.getparams()
    Channels = f.getnchannels()
    SampleRate = f.getframerate()
    bit_type = f.getsampwidth() * 8
    frames = f.getnframes()
    # Duration  That is, the audio duration  =  Number of sampling points / Sampling rate  
    Duration = wav_time = frames / float(SampleRate)  #  Unit is s
    # Print 
    print(" Audio head parameters :", params)
    print(" The channel number (Channels):", Channels)
    print(" Sampling rate (SampleRate):", SampleRate)
    print(" The bit (Precision):", bit_type)
    print(" Number of sampling points (frames):", frames)
    print(" Number of frames or time (Duration):", Duration)
#  test 
wavFile = r'1.wav'
info_wav(wavFile)

原网站

版权声明
本文为[weixin_ forty-five million nine hundred and sixty-five thousand]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203011150428503.html