• NVIDIA 7th SkyHackathon(二)Nemo ASR


    1.数据采集

    制作数据集,寻找了 65 个人单独采集样本,每人录制一个采样率为 44100HZ 的 wav 单声道语音文件,录制内容为下述的 15 句话,在对每个文件进行分割、数据清洗后,按类别存放在共计 15 个文件夹中,具体数据情况如下:

    编号内容数据量
    1请检测出果皮62
    2请检测出瓶子61
    3请检测出纸箱61
    4请检测出果皮和瓶子60
    5请检测出果皮和纸箱61
    6请检测出瓶子和果皮61
    7请检测出瓶子和纸箱59
    8请检测出纸箱和果皮61
    9请检测出纸箱和瓶子60
    10请检测出果皮、瓶子和纸箱60
    11请检测出果皮、纸箱和瓶子61
    12请检测出瓶子、果皮和纸箱60
    13请检测出瓶子、纸箱和果皮60
    14请检测出纸箱、果皮和瓶子61
    15请检测出纸箱、瓶子和果皮60

    2.数据清单要求

    数据清单格式要求如下例:

    {
        "audio_filepath": "/root/traindata/hi1.wav",
        "duration": 3.1463038548752835,
        "text": "你好请让我进入小区"
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5

    NVIDIA 官方建议使用 librosa 音频工具包获取音频时长

    import librosa 
    time = librosa.get_duration(filename="raw_data/请检测出果皮/10.wav")
    
    • 1
    • 2

    3.数据清单制作

    采用随机交叉验证,将清洗后的数据划分为训练集、测试集,并制作出 json 格式的数据清单:train.jsonval.json

    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    # @Time: 2022/11/12 16:25
    # @Author: FangXin
    
    import librosa
    import os
    import json
    import random
    
    raw_root = 'raw_data/'
    save_root = 'data/'
    
    sentences = os.listdir(raw_root)
    print(sentences)
    
    train_cnt = 0
    train = []
    
    val_cnt = 0
    val = []
    
    for s in sentences:
        path = raw_root + s + '/'
        files = os.listdir(path)
        for f in files:
            file_path = os.path.join(path, f)
            if not os.path.isfile(file_path):
                continue
            
            # 每个句子的时长
            time = librosa.get_duration(filename=file_path)
    
            dic = {"audio_filepath": file_path, "duration": time, "text": s}
            
            # 交叉验证
            if random.random() < 0.8:
                out_file = open(f"{save_root}" + 'train/' + f"{f.split('.')[0] + '_' + s}.json", "w")
                json.dump(dic, out_file)
                out_file.close()
                train_cnt += 1
                train.append(dic)
            else:
                out_file = open(f"{save_root}" + 'val/' + f"{f.split('.')[0] + '_' + s}.json", "w")
                json.dump(dic, out_file)
                out_file.close()
                val_cnt += 1
                val.append(dic)
    
    print(f"train 中数据数量:{train_cnt}")
    print(f"val 中数据数量:{val_cnt}")
    
    
    # 生成train.json文件
    with open(save_root+'train.json', 'w') as json_file:
        for each_dict in train:
            json_file.write(json.dumps(each_dict) + '\n')
    
    # 生成val.json文件
    with open(save_root+'val.json', 'w') as json_file:
        for each_dict in train:
            json_file.write(json.dumps(each_dict) + '\n')
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
  • 相关阅读:
    物联网ARM开发-4STM32串口通信USART应用
    国密加密工业路由器 数据安全升级
    实验2 数据表示实验
    7-5 最大子矩阵和问题
    智慧林业解决方案-最新全套文件
    网络安全(黑客)自学
    基于springboot+vue的云南旅游网(前后端分离)
    Spring项目配置
    k8s 自动扩缩容HPA原理及adapter配置详解
    java基于ssm的考试辅导网站
  • 原文地址:https://blog.csdn.net/u011815404/article/details/128015240