Skip to content

Commit

Permalink
Add IPv6 support to asrserver
Browse files Browse the repository at this point in the history
  • Loading branch information
nl8590687 committed Jan 9, 2019
1 parent ee9f723 commit 1457262
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions asrserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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:
Expand All @@ -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)



0 comments on commit 1457262

Please sign in to comment.