1 Star 1 Fork 2

tisttsf/ASRT_SpeechRecognition

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
train_mspeech.py 1.40 KB
一键复制 编辑 原始数据 按行查看 历史
AI柠檬 提交于 2020-10-22 20:10 . 更新MS_OUTPUT_SIZE
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@author: nl8590687
用于训练语音识别系统语音模型的程序
"""
import platform as plat
import os
import tensorflow as tf
from keras.backend.tensorflow_backend import set_session
from SpeechModel251 import ModelSpeech, ModelName
os.environ["CUDA_VISIBLE_DEVICES"] = "0"
#进行配置,使用95%的GPU
config = tf.compat.v1.ConfigProto()
config.gpu_options.per_process_gpu_memory_fraction = 0.95
#config.gpu_options.allow_growth=True #不全部占满显存, 按需分配
sess = tf.compat.v1.Session(config=config)
tf.compat.v1.keras.backend.set_session(sess)
datapath = ''
modelpath = 'model_speech'
if(not os.path.exists(modelpath)): # 判断保存模型的目录是否存在
os.makedirs(modelpath) # 如果不存在,就新建一个,避免之后保存模型的时候炸掉
os.makedirs(modelpath + '/m' + ModelName)
system_type = plat.system() # 由于不同的系统的文件路径表示不一样,需要进行判断
if(system_type == 'Windows'):
datapath = 'D:\\SpeechData'
modelpath = modelpath + '\\'
elif(system_type == 'Linux'):
datapath = 'dataset'
modelpath = modelpath + '/'
else:
print('*[Message] Unknown System\n')
datapath = 'dataset'
modelpath = modelpath + '/'
ms = ModelSpeech(datapath)
#ms.LoadModel(modelpath + 'speech_model251_e_0_step_327500.model')
ms.TrainModel(datapath, epoch = 50, batch_size = 16, save_step = 500)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/DataTraveler_0817/ASRT_SpeechRecognition.git
git@gitee.com:DataTraveler_0817/ASRT_SpeechRecognition.git
DataTraveler_0817
ASRT_SpeechRecognition
ASRT_SpeechRecognition
master

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385