资源简介
ASR_CNN.zip
代码片段和文件信息
#!/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\n‘)
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\.idea\dbnavigator.xm
文件 240 2020-02-06 17:07 ASR_CNN\.idea\encodings.xm
目录 0 2020-08-01 20:48 ASR_CNN\.idea\inspectionProfiles\
文件 174 2019-09-24 18:07 ASR_CNN\.idea\inspectionProfiles\profiles_settings.xm
文件 215 2020-08-01 21:32 ASR_CNN\.idea\misc.xm
文件 293 2019-09-24 18:07 ASR_CNN\.idea\modules.xm
文件 239 2020-02-03 09:00 ASR_CNN\.idea\other.xm
文件 465 2020-08-01 21:32 ASR_CNN\.idea\SpeechRecognition.iml
文件 28334 2020-08-01 23:18 ASR_CNN\.idea\workspace.xm
文件 3597 2019-09-29 20:26 ASR_CNN\asrserver.py
文件 413 2019-10-02 21:40 ASR_CNN\Client.py
文件 10530 2020-08-01 19:21 ASR_CNN\data.syllable.txt
文件 1494 2020-08-01 19:20 ASR_CNN\data.wav.txt
文件 32747 2020-02-06 18:48 ASR_CNN\dict.txt
目录 0 2020-08-01 23:17 ASR_CNN\general_function\
目录 0 2020-08-01 20:48 ASR_CNN\general_function\b\
文件 261 2019-09-28 11:03 ASR_CNN\general_function\b\dict.txt
文件 261 2019-09-28 11:03 ASR_CNN\general_function\dict.txt
文件 979 2020-08-01 23:17 ASR_CNN\general_function\file_dict.py
文件 3155 2020-08-01 23:17 ASR_CNN\general_function\file_wav.py
文件 487 2020-08-01 23:17 ASR_CNN\general_function\gen_func.py
文件 3249 2020-08-01 23:17 ASR_CNN\general_function\muti_gpu.py
文件 126764 2019-09-19 12:35 ASR_CNN\general_function\test1.wav
文件 168 2020-08-01 23:17 ASR_CNN\general_function\__init__.py
目录 0 2020-08-01 23:17 ASR_CNN\general_function\__pycache__\
文件 1479 2019-09-09 18:43 ASR_CNN\general_function\__pycache__\file_dict.cpython-35.pyc
文件 1092 2020-08-01 23:17 ASR_CNN\general_function\__pycache__\file_dict.cpython-37.pyc
文件 6888 2019-09-09 18:39 ASR_CNN\general_function\__pycache__\file_wav.cpython-35.pyc
文件 3010 2020-08-01 23:17 ASR_CNN\general_function\__pycache__\file_wav.cpython-37.pyc
............此处省略153个文件信息
相关资源
- OptiFiber.v2.0.rar
- TIMS.zip
- 彩虹最新免授权.zip
- 橱衣柜雕刻机开料软件V4.0免费破解版
- Mir3SourceDev.zip
- jiazhaomoban.zip
- 公安视频图像分析系统第2部分视频图
- 2020年系统分析师历年真题及解析.zi
- XPOEM免激活.exe
- 5a3721135c73f4f95f331ccb88c009bc.rar
- 时时彩计划自动追投源码.rar
- 直播教室+4.8.9.rar
- GB_T18336.3-2015信息技术安全技术信息技
- GB_T18336.2-2015.pdf
- 扩频通信系统实用仿真技术++赵刚主编
- QPSK_PROJECT.rar
- EPLANP8高手教程.pdf
- ComputerNetworking-ATopDownApproach7thconverte
- DiskGeniusV4.7.2_x32_x64(完美破解版).
- chmm.zip
- rar(2)
- nettydemo.zip
- iPhoneConfigUtility.dmg.zip
- Shopz7z.rar
- 28181.rar
- lua程序设计第四版中英文第二版中文
- Xshell6Xftp6绿色破解永久授权激活版,
- zw_MFTV.zip
- 项目源代码.rar
- 基于SSH框架的在线考试系统.zip
评论
共有 条评论