python可以干什么### 统计音频时长
[Python] 纯文本查看 复制代码 import contextlib
import os
import wave
def count_time(file_path):
with contextlib.closing(wave.open(file_path, 'r')) as f:
frames = f.getnframes()
rate = f.getframerate()
wav_length = frames / float(rate)
return wav_length
# print("音频长度:", wav_length, "秒")
path=XXXX
s=0
count=0
all_number=len(os.listdir(path))
for i in os.listdir(path):
t=os.path.join(path,i)
s+=count_time(t)
count+=1
print(f"当前总时长:{s},剩余未统计:{all_number-count}文件名:{t}")
print(s)
### 还可以干好多事
欢迎提出问题,我会帮忙写出脚本的 |