diff --git a/LanguageModel.py b/LanguageModel.py index 71dd562..7652a78 100644 --- a/LanguageModel.py +++ b/LanguageModel.py @@ -1,5 +1,23 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- +# +# Copyright 2016-2099 Ailemon.net +# +# This file is part of ASRT Speech Recognition Tool. +# +# ASRT is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# ASRT is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ASRT. If not, see . +# ============================================================================ + """ @author: nl8590687 语音识别的语言模型 diff --git a/LanguageModel2.py b/LanguageModel2.py index 7d8da62..c1e4ec7 100644 --- a/LanguageModel2.py +++ b/LanguageModel2.py @@ -1,5 +1,23 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- +# +# Copyright 2016-2099 Ailemon.net +# +# This file is part of ASRT Speech Recognition Tool. +# +# ASRT is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# ASRT is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ASRT. If not, see . +# ============================================================================ + """ @author: nl8590687 语音识别的语言模型 @@ -241,7 +259,8 @@ if(__name__=='__main__'): #str_pinyin = ['wo3', 'men5', 'qun2', 'li3', 'xiong1', 'di4', 'jian4', 'mei4', 'dou1', 'zai4', 'shuo1'] #str_pinyin = ['su1', 'an1', 'ni3', 'sui4', 'li4', 'yun4', 'sui2', 'cong2', 'jiao4', 'ming2', 'tao2', 'qi3', 'yu2', 'peng2', 'ya4', 'yang4', 'chao1', 'dao3', 'jiang1', 'li3', 'yuan2', 'kang1', 'zhua1', 'zou3'] #str_pinyin = ['da4', 'jia1', 'hao3'] - str_pinyin = ['kao3', 'yan2', 'yan1', 'yu3', 'ci2', 'hui4'] + #str_pinyin = ['kao3', 'yan2', 'yan1', 'yu3', 'ci2', 'hui4'] + str_pinyin = ['mei2', 'xiang3', 'jing4', 'ran2', 'can3', 'bai4'] #r = ml.decode(str_pinyin) r=ml.SpeechToText(str_pinyin) print('语音转文字结果:\n',r) diff --git a/SpeechModel24.py b/SpeechModel24.py index 537ea34..857cee1 100644 --- a/SpeechModel24.py +++ b/SpeechModel24.py @@ -1,5 +1,23 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- +# +# Copyright 2016-2099 Ailemon.net +# +# This file is part of ASRT Speech Recognition Tool. +# +# ASRT is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# ASRT is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ASRT. If not, see . +# ============================================================================ + """ @author: nl8590687 """ diff --git a/SpeechModel25.py b/SpeechModel25.py index 09b33fd..c164b5a 100644 --- a/SpeechModel25.py +++ b/SpeechModel25.py @@ -1,5 +1,23 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- +# +# Copyright 2016-2099 Ailemon.net +# +# This file is part of ASRT Speech Recognition Tool. +# +# ASRT is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# ASRT is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ASRT. If not, see . +# ============================================================================ + """ @author: nl8590687 """ diff --git a/SpeechModel251.py b/SpeechModel251.py index fc4c1ef..fd98404 100644 --- a/SpeechModel251.py +++ b/SpeechModel251.py @@ -1,8 +1,27 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- +# +# Copyright 2016-2099 Ailemon.net +# +# This file is part of ASRT Speech Recognition Tool. +# +# ASRT is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# ASRT is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ASRT. If not, see . +# ============================================================================ + """ @author: nl8590687 """ + import platform as plat import os import time diff --git a/SpeechModel251_limitless.py b/SpeechModel251_limitless.py index 42e9277..79b1a4c 100644 --- a/SpeechModel251_limitless.py +++ b/SpeechModel251_limitless.py @@ -1,5 +1,23 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- +# +# Copyright 2016-2099 Ailemon.net +# +# This file is part of ASRT Speech Recognition Tool. +# +# ASRT is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# ASRT is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ASRT. If not, see . +# ============================================================================ + """ @author: nl8590687 一个对于单一音频时间长度不作限制的版本,正在测试 diff --git a/SpeechModel251_p.py b/SpeechModel251_p.py index 61c3001..00d6617 100644 --- a/SpeechModel251_p.py +++ b/SpeechModel251_p.py @@ -1,5 +1,23 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- +# +# Copyright 2016-2099 Ailemon.net +# +# This file is part of ASRT Speech Recognition Tool. +# +# ASRT is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# ASRT is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ASRT. If not, see . +# ============================================================================ + """ @author: nl8590687 """ diff --git a/SpeechModel252.py b/SpeechModel252.py index 90fc151..0e0ee4e 100644 --- a/SpeechModel252.py +++ b/SpeechModel252.py @@ -1,5 +1,23 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- +# +# Copyright 2016-2099 Ailemon.net +# +# This file is part of ASRT Speech Recognition Tool. +# +# ASRT is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# ASRT is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ASRT. If not, see . +# ============================================================================ + """ @author: nl8590687 """ diff --git a/SpeechModel26.py b/SpeechModel26.py index e83c59a..849aba8 100644 --- a/SpeechModel26.py +++ b/SpeechModel26.py @@ -1,5 +1,23 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- +# +# Copyright 2016-2099 Ailemon.net +# +# This file is part of ASRT Speech Recognition Tool. +# +# ASRT is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# ASRT is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ASRT. If not, see . +# ============================================================================ + """ @author: nl8590687 """ diff --git a/SpeechModel261.py b/SpeechModel261.py index ae0fd72..6ef2998 100644 --- a/SpeechModel261.py +++ b/SpeechModel261.py @@ -1,5 +1,23 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- +# +# Copyright 2016-2099 Ailemon.net +# +# This file is part of ASRT Speech Recognition Tool. +# +# ASRT is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# ASRT is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ASRT. If not, see . +# ============================================================================ + """ @author: nl8590687 """ diff --git a/SpeechModel261_p.py b/SpeechModel261_p.py index 0d401b0..2e66f91 100644 --- a/SpeechModel261_p.py +++ b/SpeechModel261_p.py @@ -1,5 +1,23 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- +# +# Copyright 2016-2099 Ailemon.net +# +# This file is part of ASRT Speech Recognition Tool. +# +# ASRT is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# ASRT is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ASRT. If not, see . +# ============================================================================ + """ @author: nl8590687 """ diff --git a/asrserver.py b/asrserver.py index f671544..273f2fb 100644 --- a/asrserver.py +++ b/asrserver.py @@ -1,16 +1,36 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- +# +# Copyright 2016-2099 Ailemon.net +# +# This file is part of ASRT Speech Recognition Tool. +# +# ASRT is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# ASRT is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ASRT. If not, see . +# ============================================================================ + """ @author: nl8590687 语音识别API的HTTP服务器程序 - """ + import http.server import urllib +import socket import keras from SpeechModel251 import ModelSpeech from LanguageModel import ModelLanguage + datapath = './' modelpath = 'model_speech/' ms = ModelSpeech(datapath) @@ -19,127 +39,115 @@ ms.LoadModel(modelpath + 'm251/speech_model251_e_0_step_12000.model') ml = ModelLanguage('model_language') ml.LoadModel() -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(buf,encoding="utf-8") - self.wfile.write(buf) - - def do_POST(self): - ''' - 处理通过POST方式传递过来并接收的语音数据 - 通过语音模型和语言模型计算得到语音识别结果并返回 - ''' - path = self.path - print(path) - #获取post提交的数据 - datas = self.rfile.read(int(self.headers['content-length'])) - #datas = urllib.unquote(datas).decode("utf-8", 'ignore') - datas = datas.decode('utf-8') - datas_split = datas.split('&') - token = '' - fs = 0 - wavs = [] - #type = 'wavfilebytes' # wavfilebytes or python-list - - 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 - #elif('type' == key): - # type = value - else: - print(key, value) - - if(token != 'qwertasd'): - buf = '403' - print(buf) - buf = bytes(buf,encoding="utf-8") - self.wfile.write(buf) - return - - #if('python-list' == type): - if(len(wavs)>0): - r = self.recognize([wavs], fs) - else: - r = '' - #else: - # r = self.recognize_from_file('') - - if(token == 'qwertasd'): - #buf = '成功\n'+'wavs:\n'+str(wavs)+'\nfs:\n'+str(fs) - buf = r - else: - buf = '403' - - #print(datas) - - self._set_response() - - #buf = ' \n \n\nPost page\n \nPost Data:%s
Path:%s\n \n'%(datas,self.path) - print(buf) - buf = bytes(buf,encoding="utf-8") - self.wfile.write(buf) - - def recognize(self, wavs, fs): - r='' - try: - r_speech = ms.RecognizeSpeech(wavs, fs) - print(r_speech) - str_pinyin = r_speech - r = ml.SpeechToText(str_pinyin) - except: - r='' - print('[*Message] Server raise a bug. ') - return r - pass - - def recognize_from_file(self, filename): - pass -import socket +class ASRTHTTPHandle(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(buf,encoding="utf-8") + self.wfile.write(buf) + + def do_POST(self): + ''' + 处理通过POST方式传递过来并接收的语音数据 + 通过语音模型和语言模型计算得到语音识别结果并返回 + ''' + path = self.path + print(path) + #获取post提交的数据 + datas = self.rfile.read(int(self.headers['content-length'])) + #datas = urllib.unquote(datas).decode("utf-8", 'ignore') + 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 + #elif('type' == key): + # type = value + else: + print(key, value) + + if(token != 'qwertasd'): + buf = '403' + print(buf) + buf = bytes(buf,encoding="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(buf,encoding="utf-8") + self.wfile.write(buf) + + def recognize(self, wavs, fs): + r='' + try: + r_speech = ms.RecognizeSpeech(wavs, fs) + print(r_speech) + str_pinyin = r_speech + r = ml.SpeechToText(str_pinyin) + except Exception as ex: + r='' + print('[*Message] Server raise a bug. ', ex) + return r + pass + + def recognize_from_file(self, filename): + pass + class HTTPServerV6(http.server.HTTPServer): - address_family = socket.AF_INET6 + address_family = socket.AF_INET6 + def start_server(ip, port): - - if(':' in ip): - http_server = HTTPServerV6((ip, port), TestHTTPHandle) - else: - http_server = http.server.HTTPServer((ip, int(port)), TestHTTPHandle) - - print('服务器已开启') - - try: - http_server.serve_forever() #设置一直监听并接收请求 - except KeyboardInterrupt: - pass - http_server.server_close() - print('HTTP server closed') - + if(':' in ip): + http_server = HTTPServerV6((ip, port), ASRTHTTPHandle) + else: + http_server = http.server.HTTPServer((ip, int(port)), ASRTHTTPHandle) + + print('服务器已开启') + + try: + http_server.serve_forever() #设置一直监听并接收请求 + except KeyboardInterrupt: + pass + http_server.server_close() + print('HTTP server closed') + + if __name__ == '__main__': - start_server('', 20000) # For IPv4 Network Only - #start_server('::', 20000) # For IPv6 Network - - - - + start_server('', 20000) # For IPv4 Network Only + #start_server('::', 20000) # For IPv6 Network diff --git a/general_function/file_dict.py b/general_function/file_dict.py index 8e40e3f..4db206e 100644 --- a/general_function/file_dict.py +++ b/general_function/file_dict.py @@ -1,8 +1,27 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- +# +# Copyright 2016-2099 Ailemon.net +# +# This file is part of ASRT Speech Recognition Tool. +# +# ASRT is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# ASRT is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ASRT. If not, see . +# ============================================================================ + ''' 获取符号字典列表的程序 ''' + import platform as plat def GetSymbolList(datapath): diff --git a/general_function/file_wav.py b/general_function/file_wav.py index 42dd271..61cbac5 100644 --- a/general_function/file_wav.py +++ b/general_function/file_wav.py @@ -1,5 +1,22 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- +# +# Copyright 2016-2099 Ailemon.net +# +# This file is part of ASRT Speech Recognition Tool. +# +# ASRT is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# ASRT is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ASRT. If not, see . +# ============================================================================ import os import wave diff --git a/general_function/gen_func.py b/general_function/gen_func.py index 9eb64d6..d499684 100644 --- a/general_function/gen_func.py +++ b/general_function/gen_func.py @@ -1,5 +1,22 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- +# +# Copyright 2016-2099 Ailemon.net +# +# This file is part of ASRT Speech Recognition Tool. +# +# ASRT is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# ASRT is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ASRT. If not, see . +# ============================================================================ ''' 一些通用函数 diff --git a/general_function/muti_gpu.py b/general_function/muti_gpu.py index c7505d9..f70b353 100644 --- a/general_function/muti_gpu.py +++ b/general_function/muti_gpu.py @@ -1,5 +1,23 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- +# +# Copyright 2016-2099 Ailemon.net +# +# This file is part of ASRT Speech Recognition Tool. +# +# ASRT is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# ASRT is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ASRT. If not, see . +# ============================================================================ + ''' 感谢原作者的无私奉献 来自: diff --git a/readdata24.py b/readdata24.py index 8df5883..3966d96 100644 --- a/readdata24.py +++ b/readdata24.py @@ -1,5 +1,22 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- +# +# Copyright 2016-2099 Ailemon.net +# +# This file is part of ASRT Speech Recognition Tool. +# +# ASRT is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# ASRT is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ASRT. If not, see . +# ============================================================================ import platform as plat import os diff --git a/readdata24_limitless.py b/readdata24_limitless.py index b161659..540093f 100644 --- a/readdata24_limitless.py +++ b/readdata24_limitless.py @@ -1,5 +1,23 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- +# +# Copyright 2016-2099 Ailemon.net +# +# This file is part of ASRT Speech Recognition Tool. +# +# ASRT is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# ASRT is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ASRT. If not, see . +# ============================================================================ + ''' @author: nl8590687 一个对于单一音频时间长度不作限制的版本,正在测试 diff --git a/speech_recorder.py b/speech_recorder.py index 3cb5e46..d111c3a 100644 --- a/speech_recorder.py +++ b/speech_recorder.py @@ -1,3 +1,23 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# Copyright 2016-2099 Ailemon.net +# +# This file is part of ASRT Speech Recognition Tool. +# +# ASRT is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# ASRT is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ASRT. If not, see . +# ============================================================================ + import pyaudio import wave diff --git a/test.py b/test.py index f7722b6..f4668fa 100644 --- a/test.py +++ b/test.py @@ -1,5 +1,23 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- +# +# Copyright 2016-2099 Ailemon.net +# +# This file is part of ASRT Speech Recognition Tool. +# +# ASRT is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# ASRT is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ASRT. If not, see . +# ============================================================================ + """ @author: nl8590687 用于测试整个一套语音识别系统的程序 @@ -16,7 +34,7 @@ modelpath = 'model_speech' system_type = plat.system() # 由于不同的系统的文件路径表示不一样,需要进行判断 if(system_type == 'Windows'): - datapath = 'D:\\语音数据集' + datapath = 'Z:\\SpeechData' modelpath = modelpath + '\\' elif(system_type == 'Linux'): datapath = 'dataset' @@ -29,7 +47,7 @@ else: ms = ModelSpeech(datapath) #ms.LoadModel(modelpath + 'm22_2\\0\\speech_model22_e_0_step_257000.model') -ms.LoadModel(modelpath + 'm251\\speech_model251_e_0_step_12000.model') +ms.LoadModel(modelpath + 'm251\\speech_model251_e_0_step_625000.model') #ms.TestModel(datapath, str_dataset='test', data_count = 64, out_report = True) r = ms.RecognizeSpeech_FromFile('D:\\语音数据集\\ST-CMDS-20170001_1-OS\\20170001P00241I0052.wav') diff --git a/testClient.py b/testClient.py index 015bf5f..58f8d46 100644 --- a/testClient.py +++ b/testClient.py @@ -1,5 +1,22 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- +# +# Copyright 2016-2099 Ailemon.net +# +# This file is part of ASRT Speech Recognition Tool. +# +# ASRT is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# ASRT is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ASRT. If not, see . +# ============================================================================ ''' @author: nl8590687 @@ -11,10 +28,9 @@ import requests from general_function.file_wav import * url = 'http://127.0.0.1:20000/' - token = 'qwertasd' -wavsignal,fs=read_wav_data('D:\\语音数据集\\ST-CMDS-20170001_1-OS\\20170001P00241I0052.wav') +wavsignal,fs=read_wav_data('X:\\语音数据集\\data_thchs30\\train\\A11_0.wav') #print(wavsignal,fs) diff --git a/test_mspeech.py b/test_mspeech.py index 9b136bd..bbfc1a6 100644 --- a/test_mspeech.py +++ b/test_mspeech.py @@ -1,5 +1,23 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- +# +# Copyright 2016-2099 Ailemon.net +# +# This file is part of ASRT Speech Recognition Tool. +# +# ASRT is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# ASRT is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ASRT. If not, see . +# ============================================================================ + """ @author: nl8590687 用于测试语音识别系统语音模型的程序 diff --git a/train_mspeech.py b/train_mspeech.py index fdcf55f..85e9bf9 100644 --- a/train_mspeech.py +++ b/train_mspeech.py @@ -1,5 +1,23 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- +# +# Copyright 2016-2099 Ailemon.net +# +# This file is part of ASRT Speech Recognition Tool. +# +# ASRT is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# ASRT is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ASRT. If not, see . +# ============================================================================ + """ @author: nl8590687 用于训练语音识别系统语音模型的程序