Exemple #1
0
    def recognize(self, wavs, fs):
        datapath = 'data/'
        modelpath = 'model_speech/'
        ms = ModelSpeech(datapath)
        ms.LoadModel(modelpath + 'speech_model22_e_0_step_6500.model')

        r_speech = ms.RecognizeSpeech(wavs, fs)

        ml = ModelLanguage('model_language')
        ml.LoadModel()
        str_pinyin = r_speech
        r = ml.SpeechToText(str_pinyin)
        return r
        pass
    print('*[Message] Unknown System\n')
    datapath = 'dataset'
    modelpath = modelpath + '/'

ms = ModelSpeech(datapath)

#ms.LoadModel(modelpath + 'm22_2\\0\\speech_model22_e_0_step_257000.model')
ms.LoadModel(modelpath + 'm22_2/0/speech_model22_e_0_step_257000.model')

#ms.TestModel(datapath, str_dataset='test', data_count = 64, out_report = True)
r = ms.RecognizeSpeech_FromFile(
    'E:\语音数据集\ST-CMDS-20170001_1-OS\\20170001P00241I0052.wav')
#r = ms.RecognizeSpeech_FromFile('E:\\VS2015解决方案\\wav文件读写样例\\wav文件读写样例\\bin\\Debug\\1.wav')
#r = ms.RecognizeSpeech_FromFile('/home/nl/01.wav')
#r = ms.RecognizeSpeech_FromFile('C:\\Users\\nl\\Desktop\\01.wav')
#r = ms.RecognizeSpeech_FromFile('E:\语音数据集\ST-CMDS-20170001_1-OS\\20170001P00241I0053.wav')
#r = ms.RecognizeSpeech_FromFile('E:\\语音数据集\\ST-CMDS-20170001_1-OS\\20170001P00020I0087.wav')
#r = ms.RecognizeSpeech_FromFile('E:\\语音数据集\\wav\\train\\A11\\A11_167.WAV')
#r = ms.RecognizeSpeech_FromFile('E:\\语音数据集\\wav\\test\\D4\\D4_750.wav')
print('*[提示] 语音识别结果:\n', r)

ml = ModelLanguage('model_language')
ml.LoadModel()

#str_pinyin = ['zhe4','zhen1','shi4','ji2', 'hao3','de5']
#str_pinyin = ['jin1', 'tian1', 'shi4', 'xing1', 'qi1', 'san1']
#str_pinyin = ['ni3', 'hao3','a1']
str_pinyin = r
r = ml.SpeechToText(str_pinyin)
print('语音转文字结果:\n', r)