From 1457262175283df8a0f233f10f6ceff74e2874b7 Mon Sep 17 00:00:00 2001 From: nl <3210346136@qq.com> Date: Wed, 9 Jan 2019 16:37:10 +0800 Subject: [PATCH] Add IPv6 support to asrserver --- asrserver.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/asrserver.py b/asrserver.py index 7931064..08f59a6 100644 --- a/asrserver.py +++ b/asrserver.py @@ -11,10 +11,10 @@ from SpeechModel251 import ModelSpeech from LanguageModel import ModelLanguage -datapath = 'data/' +datapath = './' modelpath = 'model_speech/' ms = ModelSpeech(datapath) -ms.LoadModel(modelpath + 'm251/speech_model251_e_0_step_12000.model') +ms.LoadModel(modelpath + 'm251/speech_model251_e_0_step_117000.model') ml = ModelLanguage('model_language') ml.LoadModel() @@ -114,9 +114,19 @@ def recognize(self, wavs, fs): def recognize_from_file(self, filename): pass - + +import socket + +class HTTPServerV6(http.server.HTTPServer): + address_family = socket.AF_INET6 + def start_server(ip, port): - http_server = http.server.HTTPServer((ip, int(port)), TestHTTPHandle) + + if(':' in ip): + http_server = HTTPServerV6((ip, port), TestHTTPHandle) + else: + http_server = http.server.HTTPServer((ip, int(port)), TestHTTPHandle) + print('服务器已开启') try: @@ -127,8 +137,9 @@ def start_server(ip, port): print('HTTP server closed') if __name__ == '__main__': + start_server('', 20000) # For IPv4 Network Only + #start_server('::', 20000) # For IPv6 Network - start_server('', 20000)