1 Star 0 Fork 0

嗜雪的蚂蚁/asr_timestamp_insert_text_grid

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
.idea
Debug
TextGrid
__pycache__
asr
asr_timestamp
result
工具类临时处理脚本
asr_timestamp_client.py
genarate_timestamp_json.py
generate_TextGrid.py
generate_scp_linux.py
generate_st_text_for_align.py
标注系统textgrid文件生成步骤.md
label
result
wav
README.md
SpeechrepeScore.py
generate_TextGrid.py
generate_TextGrid_YZS.py
label_alignment.py
label_alignment_1.py
timestamp_detail.txt
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
generate_scp_linux.py 1.14 KB
一键复制 编辑 原始数据 按行查看 历史
import os
import re
# 设置音频文件所在目录
audio_dir = '/home00/dwenxu/asr_timestamp_insert_text_grid/asr/wer0-50andtext10-15-wav'
# 设置输出文件名
output_file = '/home00/dwenxu/asr_timestamp_insert_text_grid/asr/wav/wav.scp'
def natural_sort_key(s):
return [
int(text) if text.isdigit() else text.lower()
for text in re.split(r'(\d+)', s)
]
def generate_scp(audio_dir, audio_files):
# 获取音频文件列表,并排序
audio_files = sorted(os.listdir(audio_dir), key=natural_sort_key)
# 生成scp文件内容
with open(output_file, 'w', encoding='utf-8') as f:
for audio_file in audio_files:
if audio_file.endswith('.wav'):
# 获取不含文件格式的音频文件名
file_name = os.path.splitext(audio_file)[0]
# 拼接绝对路径
absolute_path = os.path.join(audio_dir, audio_file).replace('\\', '/')
# 将路径写入到scp文件中
f.write(f'{file_name} {absolute_path}\n')
print("SCP 文件已生成.")
if __name__ == "__main__":
generate_scp(audio_dir, output_file)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mayi123/asr_timestamp_insert_text_grid.git
git@gitee.com:mayi123/asr_timestamp_insert_text_grid.git
mayi123
asr_timestamp_insert_text_grid
asr_timestamp_insert_text_grid
master

搜索帮助