ASR_CNN.zip
ASR_CNN.zip
代码片段和文件信息
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2020-08-01 23:18 ASR_CNN
目录 0 2020-08-01 23:18 ASR_CNN.idea
文件 22437 2019-09-25 15:50 ASR_CNN.ideadbnavigator.xml
文件 240 2020-02-06 17:07 ASR_CNN.ideaencodings.xml
目录 0 2020-08-01 20:48 ASR_CNN.ideainspectionProfiles
文件 174 2019-09-24 18:07 ASR_CNN.ideainspectionProfilesprofiles_settings.xml
文件 215 2020-08-01 21:32 ASR_CNN.ideamisc.xml
文件 293 2019-09-24 18:07 ASR_CNN.ideamodules.xml
文件 239 2020-02-03 09:00 ASR_CNN.ideaother.xml
文件 465 2020-08-01 21:32 ASR_CNN.ideaSpeechRecognition.iml
文件 28334 2020-08-01 23:18 ASR_CNN.ideaworkspace.xml
文件 3597 2019-09-29 20:26 ASR_CNNasrserver.py
文件 413 2019-10-02 21:40 ASR_CNNClient.py
文件 10530 2020-08-01 19:21 ASR_CNNdata.syllable.txt
文件 1494 2020-08-01 19:20 ASR_CNNdata.wav.txt
文件 32747 2020-02-06 18:48 ASR_CNNdict.txt
目录 0 2020-08-01 23:17 ASR_CNNgeneral_function
目录 0 2020-08-01 20:48 ASR_CNNgeneral_function
文件 261 2019-09-28 11:03 ASR_CNNgeneral_functiondict.txt
文件 261 2019-09-28 11:03 ASR_CNNgeneral_functiondict.txt
文件 979 2020-08-01 23:17 ASR_CNNgeneral_functionfile_dict.py
文件 3155 2020-08-01 23:17 ASR_CNNgeneral_functionfile_wav.py
文件 487 2020-08-01 23:17 ASR_CNNgeneral_functiongen_func.py
文件 3249 2020-08-01 23:17 ASR_CNNgeneral_functionmuti_gpu.py
文件 126764 2019-09-19 12:35 ASR_CNNgeneral_function est1.wav
文件 168 2020-08-01 23:17 ASR_CNNgeneral_function\__init__.py
目录 0 2020-08-01 23:17 ASR_CNNgeneral_function\__pycache__
文件 1479 2019-09-09 18:43 ASR_CNNgeneral_function\__pycache__file_dict.cpython-35.pyc
文件 1092 2020-08-01 23:17 ASR_CNNgeneral_function\__pycache__file_dict.cpython-37.pyc
文件 6888 2019-09-09 18:39 ASR_CNNgeneral_function\__pycache__file_wav.cpython-35.pyc
文件 3010 2020-08-01 23:17 ASR_CNNgeneral_function\__pycache__file_wav.cpython-37.pyc
............此处省略153个文件信息
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
“““
语音识别API的HTTP服务器程序
“““
import os
import http.server
import urllib
import keras
from SpeechModel import ModelSpeech
from LanguageModel import ModelLanguage
import platform as plat
from package import pinyin2hanzi
root = ‘D:/SpeechRecognition‘ #根目录
num2pyyin_dict = pinyin2hanzi.get_num2pyyin_dict(os.path.join(root‘package/resource/num2pinyin.txt‘))
hangban_com_name_dict = pinyin2hanzi.make_tone_file(os.path.join(root‘package/resource/hb_name.txt‘) num2pyyin_dict)
hangban_num_dict = pinyin2hanzi.make_tone_file(os.path.join(root‘package/resource/hb_num.txt‘) num2pyyin_dict)
command_dict = pinyin2hanzi.make_tone_file(os.path.join(root‘package/resource/cmd.txt‘) num2pyyin_dict)
modelpath = ‘model_speech‘ #文件夹的名字
system_type = plat.system() #操作系统的类型
if(system_type == ‘Windows‘):
datapath = ‘D:\语音数据集‘
modelpath = modelpath + ‘\‘
elif(system_type == ‘Linux‘):
datapath = ‘dataset‘
modelpath = modelpath + ‘/‘
else:
print(‘*[Message] Unknown System
‘)
datapath = ‘dataset‘
modelpath = modelpath + ‘/‘
ms = ModelSpeech(datapath)
ms.LoadModel(modelpath + ‘speech_model251_e_0_step_625000.model‘)
class TestHTTPHandle(http.server.baseHTTPRequestHandler):
def setup(self):
self.request.settimeout(10)
http.server.baseHTTPRequestHandler.setup(self)
def _set_response(self):
self.send_response(200)
self.send_header(‘Content-type‘ ‘text/html‘)
self.end_headers()
def do_GET(self):
buf = ‘ASRT_SpeechRecognition API‘
self.protocal_version = ‘HTTP/1.1‘
self._set_response()
buf = bytes(bufencoding=“utf-8“)
self.wfile.write(buf)
def do_POST(self):
path = self.path
print(path)
datas = self.rfile.read(int(self.headers[‘content-length‘]))
datas = datas.decode(‘utf-8‘)
datas_split = datas.split(‘&‘)
token = ‘‘
fs = 0
wavs = []
for line in datas_split:
[key value]=line.split(‘=‘)
if(‘wavs‘ == key and ‘‘ != value):
wavs.append(int(value))
elif(‘fs‘ == key):
fs = int(value)
elif(‘token‘ == key ):
token = value
else:
print(key value)
if(token != ‘qwertasd‘):
buf = ‘403‘
print(buf)
buf = bytes(bufencoding=“utf-8“)
self.wfile.write(buf)
return
if(len(wavs)>0):
r = self.recognize([wavs] fs)
else:
r = ‘‘
if(token == ‘qwertasd‘):
buf = r
else:
buf = ‘403‘
self._set_response()
print(buf)
buf = bytes(bufencoding=“utf-8“)
self.wfile.write(buf)
def recognize(self wavs fs):
r=‘‘
try:
r_speech = ms.RecognizeSpeech(wavs fs)
result = pinyin2hanzi.get_result(hangban_com_name_dict hangban_num_dict command_dict r_speech)
print(result)
final_result = result[0][0]+‘ ‘+result[1][0]+‘ ‘+result[2][0]
except:
r=‘‘
print(‘[*Message] Server raise a bug. ‘)
return final_result
pass
def recognize_from_file(self filename):
pass
import socket
class HTTPServerV6(http.server.HTTPServer):
addre
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2020-08-01 23:18 ASR_CNN
目录 0 2020-08-01 23:18 ASR_CNN.idea
文件 22437 2019-09-25 15:50 ASR_CNN.ideadbnavigator.xm
文件 240 2020-02-06 17:07 ASR_CNN.ideaencodings.xm
目录 0 2020-08-01 20:48 ASR_CNN.ideainspectionProfiles
文件 174 2019-09-24 18:07 ASR_CNN.ideainspectionProfilesprofiles_settings.xm
文件 215 2020-08-01 21:32 ASR_CNN.ideamisc.xm
文件 293 2019-09-24 18:07 ASR_CNN.ideamodules.xm
文件 239 2020-02-03 09:00 ASR_CNN.ideaother.xm
文件 465 2020-08-01 21:32 ASR_CNN.ideaSpeechRecognition.iml
文件 28334 2020-08-01 23:18 ASR_CNN.ideaworkspace.xm
文件 3597 2019-09-29 20:26 ASR_CNNasrserver.py
文件 413 2019-10-02 21:40 ASR_CNNClient.py
文件 10530 2020-08-01 19:21 ASR_CNNdata.syllable.txt
文件 1494 2020-08-01 19:20 ASR_CNNdata.wav.txt
文件 32747 2020-02-06 18:48 ASR_CNNdict.txt
目录 0 2020-08-01 23:17 ASR_CNNgeneral_function
目录 0 2020-08-01 20:48 ASR_CNNgeneral_function
文件 261 2019-09-28 11:03 ASR_CNNgeneral_functiondict.txt
文件 261 2019-09-28 11:03 ASR_CNNgeneral_functiondict.txt
文件 979 2020-08-01 23:17 ASR_CNNgeneral_functionfile_dict.py
文件 3155 2020-08-01 23:17 ASR_CNNgeneral_functionfile_wav.py
文件 487 2020-08-01 23:17 ASR_CNNgeneral_functiongen_func.py
文件 3249 2020-08-01 23:17 ASR_CNNgeneral_functionmuti_gpu.py
文件 126764 2019-09-19 12:35 ASR_CNNgeneral_function est1.wav
文件 168 2020-08-01 23:17 ASR_CNNgeneral_function\__init__.py
目录 0 2020-08-01 23:17 ASR_CNNgeneral_function\__pycache__
文件 1479 2019-09-09 18:43 ASR_CNNgeneral_function\__pycache__file_dict.cpython-35.pyc
文件 1092 2020-08-01 23:17 ASR_CNNgeneral_function\__pycache__file_dict.cpython-37.pyc
文件 6888 2019-09-09 18:39 ASR_CNNgeneral_function\__pycache__file_wav.cpython-35.pyc
文件 3010 2020-08-01 23:17 ASR_CNNgeneral_function\__pycache__file_wav.cpython-37.pyc
............此处省略153个文件信息
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)