2 Star 29 Fork 7

李子 / Sound_File_Processing

Create your Gitee Account
Explore and code with more than 8 million developers,Free private repositories !:)
Sign up
Clone or Download
contribute
Sync branch
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
readme.md

机器学习声音数据集处理软件

期望能够实现:长音频切割,文本录入,批量改名等功能

安装依赖

pip install -r requirements.txt

长音频截取功能

根据长音频中的语句间隔,将音频切割为一个个小段

使用方法:修改long_file_cut.py文件中的wan_root_path字符串值,程序会从wan_root_path/input目录下读取音频,将其分割为短音频后存储在wan_root_path/output目录下

修改min_length 使截取出的音频长度不会低于这个值,单位:ms

修改min_silence_len 使当语音间隔的长度大于这个值时才进行一次截断,单位:ms

修改min_to_cut 如果原音频短于这个长度则不会被切割,单位:ms

注意:如果最后一段切出的音频过短,则会将它合入到上一个音频切片中

执行 python long_file_cut.py

通过srt字幕文件裁切音频文件并生成transcript文件

注意:你的srt字幕文件应该和音频文件的文件名相同或仅相差一个CHS_前缀 例如:CHS_abc.srt abc.wav abc.srt

修改long_file_cut_by_srt.py文件

srt_root_path = "srt" srt字幕文件所在的根目录

sound_root_path = "wav" 音频文件的根目录,程序会根据srt文件读取其下的input文件夹中同名音频文件然后输出到sound_root_path/output中

transcript_root_path = "transcript" transcript文件的保存目录,生成的transcript会以续写的方法保存在transcript_root_path/transcript.txt中

其中比较短的音频(默认是100毫秒以下或对应文字少于6个,符合其一即会被过滤)会被过滤到sound_root_path/output_short文件夹下,对应的文字会被储存在transcript_root_path/transcript_short.txt中。

你可以在txt文件中手动校对,删除语气词等,只留下你想保留的文本。然后执行short_file_clicing.py文件,它会将未被删除txt文本的短的音频进行合并。存储位置是sound_root_path/output 并且txt文本会续写在transcript_root_path/transcript.txt中

注意:

  • 只会合并前缀相同的音频文件,比如短音频abc_1.wav和abc_2.wav可以被合并成abc_1_2.wav 而abc_1.wav和xyz_2.wav不会被合并。

  • 如果最后有多余的短音频,则它会被抛弃

这时候就有人问了 我从哪搞字幕文件去呢?

请使用 网易见外jianwai.youdao.com 的语音转写-输出字幕 免费的!感谢网易!

或者使用Videosrt这个软件

执行 python long_file_cut_by_srt.py

切除音频中间隔

修改remove_sound_slience.py文件,wan_root_path为音频根目录,程序会从wav_root_path/output/下读取音频文件, 然后输出到wav_root_path/cut_silent_output/目录下。min_silence_len 单位为ms 长于这个值的语音停顿会被裁切

按照文本内容重命名音频文件

修改rename_by_txt.py文件 sound_root_path为音频根目录,transcript_root_path为transcript根目录。程序会从sound_root_path/output/下读取音频文件, 重命名后输出到sound_root_path/output_rename_by_txt/目录下 新的transcript文本会输出到transcript_root_path/transcript_rename_by_txt.txt下

修改is_full_old_name为1 则新文件名会保留老文件名。如果就改为0则新文件名不会保留老文件名。

例:老文件名:abc.wav 值为1时新文件名为:abc_文件文本.wav

值为0时新文件名为:文件文本.wav

下一步实现功能

额。。。

可能是图形化吧

...

About

切割音频文件的脚本,太旧了 建议用新开发的这个https://github.com/kslz/SoundLabel expand collapse
Python
MIT
Cancel

Releases

No release

Contributors

All

Activities

Load More
can not load any more
Python
1
https://gitee.com/kslizi/Sound_File_Processing.git
git@gitee.com:kslizi/Sound_File_Processing.git
kslizi
Sound_File_Processing
Sound_File_Processing
master

Search