'init'
This commit is contained in:
parent
0efe7627a8
commit
49b33f48db
2
.gitignore
vendored
2
.gitignore
vendored
@ -128,4 +128,4 @@ dmypy.json
|
||||
|
||||
# Pyre type checker
|
||||
.pyre/
|
||||
|
||||
.idea
|
||||
|
40
main.py
Normal file
40
main.py
Normal file
@ -0,0 +1,40 @@
|
||||
# -*- coding:utf-8 -*-
|
||||
import os
|
||||
import re
|
||||
from ffmpeg import audio
|
||||
|
||||
root_dir = r'I:\work\SVN\new_shenghua\chengxu\client\res\sound'
|
||||
|
||||
|
||||
def get_files(path):
|
||||
res = []
|
||||
r = os.listdir(path) # 列出文件夹下所有的目录与文件
|
||||
for i in r:
|
||||
file_path = os.path.join(path, i)
|
||||
if os.path.isfile(file_path) and file_path.endswith('mp3'):
|
||||
if re.match(r'.*x[\d\.]+\.mp3$', file_path):
|
||||
continue
|
||||
res.append(file_path)
|
||||
return res
|
||||
|
||||
|
||||
def change_speed(file, x, error_info):
|
||||
res = audio.a_speed(file, x, re.sub(r'(\.mp3$)', f'_x{x}.mp3', file))
|
||||
if not res:
|
||||
error_info.append(f'{file} to {x} error')
|
||||
|
||||
|
||||
def run():
|
||||
files = get_files(root_dir)
|
||||
error_info = []
|
||||
for file in files:
|
||||
change_speed(file, '1.5', error_info)
|
||||
change_speed(file, '3', error_info)
|
||||
|
||||
print('*'*20)
|
||||
for i in error_info:
|
||||
print(i)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
run()
|
Loading…
Reference in New Issue
Block a user