#!/usr/bin/pythonfromosimportenviron,pathfromglobimportglobimportosfrompocketsphinx.pocketsphinximport*fromsphinxbase.sphinxbaseimport*MODELDIR="/home/tania/trial/sylabble"DATADIR="/home/tania/trial/sylabble/wav/kannadatest_clstk"# Create a decoder with certain modelconfig=Decoder.default_config()config.set_string('-hmm',path.join(MODELDIR,'model_parameters/sylabble.cd_cont_200'))config.set_string('-lm',path.join(MODELDIR,'etc/sylabble.lm.DMP'))config.set_string('-dict',path.join(MODELDIR,'etc/sylabble.dic'))config.set_float('-beam',1e-80)config.set_float('-fwdflatbeam',1e-80)config.set_float('-fwdflatlw',10)config.set_float('-fwdflatwbeam',1e-40)config.set_float('-lpbeam',1e-80)config.set_float('-lponlybeam',1e-80)config.set_float('-lw',10)config.set_float('-pbeam',1e-80)config.set_float('-wbeam',1e-40)config.set_float('-wip',2e-01)#config.set_string('-logfn', "/dev/null")i=0# Decode streaming data.decoder=Decoder(config)whilei<2:decoder.start_utt()stream=open(path.join(DATADIR,'kan_0702.wav'),'rb')whileTrue:buf=stream.read()ifbuf:decoder.process_raw(buf,False,True)else:breaki=i+1decoder.end_utt()hypothesis=decoder.hyp()s=hypothesis.hypstr#print(s)z="".join(s.split())z=z.replace("$^"," ")z=z.replace("^"," ")z=z.replace("$"," ")z=z.replace("_","")z=z.strip()print(z)i=0DATADIR1="/home/tania/z1/kannada1-2"lm=NGramModel(config,decoder.get_logmath(),path.join(DATADIR1,'etc/kannada1-2.lm.DMP'))decoder.set_lm('kannada1-2',lm)decoder.set_search('kannada1-2')decoder.load_dict("/home/tania/z1/kannada1-2/etc/kannada1-2.dic",None,None)whilei<2:decoder.start_utt()stream=open(path.join(DATADIR,'kan_0702.wav'),'rb')whileTrue:buf=stream.read()ifbuf:decoder.process_raw(buf,False,True)else:breaki=i+1decoder.end_utt()hypothesis=decoder.hyp()s=hypothesis.hypstrprint(s)
In the above code i was able to set a new LM and load a new dict. How can i update the hmm model in the code from sylabble.cd_cont_200 to kannada1-2.cd_cont_200 without creating a new decoder object? Is it posibble?
Without changing the HMM model its still able to give proper results I'm not sure how
and the while loop i used the loop twice because in the first decoding i dont get the right result. i tried changing the changing the channel parameters too but i dont the right decoded sentence in first shot. Please help me out
Any idea as to how its getting the right results for word decoding from the sylabble based HMM? Is it because the HMM is phone based though i have made a sylabble based?
Last edit: Tania Mendonca 2017-04-17
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In the above code i was able to set a new LM and load a new dict. How can i update the hmm model in the code from sylabble.cd_cont_200 to kannada1-2.cd_cont_200 without creating a new decoder object? Is it posibble?
Without changing the HMM model its still able to give proper results I'm not sure how
and the while loop i used the loop twice because in the first decoding i dont get the right result. i tried changing the changing the channel parameters too but i dont the right decoded sentence in first shot. Please help me out
Last edit: Tania Mendonca 2017-04-17
Not possible.
Any idea as to how its getting the right results for word decoding from the sylabble based HMM? Is it because the HMM is phone based though i have made a sylabble based?
Last edit: Tania Mendonca 2017-04-17