From 0ada7ea4adde26bedfb0fc9fd1a8cae0fbfe2ffc Mon Sep 17 00:00:00 2001 From: a2un Date: Sun, 15 Oct 2017 08:51:06 +0530 Subject: [PATCH] added a block def and cmusphinx test --- blockchain.py | 17 ++++++++++++++++- test.py | 5 +++++ test1.py | 21 +++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 test.py create mode 100644 test1.py diff --git a/blockchain.py b/blockchain.py index 8ed63e2..f6468b6 100644 --- a/blockchain.py +++ b/blockchain.py @@ -12,4 +12,19 @@ def hash(block): pass @property def last_block(self): - pass \ No newline at end of file + pass + + +def main(): + + block = { + "index":1, + "timestamp":3423423423423.234 + "transactions":{ + "sender":"kychashS", + "recipient":"kychashR", + "amount":"5" + }, + "proof": 324251234234, + "previous_hash":'2clhkghf3q42342345odapasuropdhfjkldshfy' + } \ No newline at end of file diff --git a/test.py b/test.py new file mode 100644 index 0000000..a556e1f --- /dev/null +++ b/test.py @@ -0,0 +1,5 @@ +from pocketsphinx import AudioFile + +audio = AudioFile(lm=False, keyphrase='forward', kws_threshold=1e+20) +for phrase in audio: + print(phrase.segments(detailed=True)) # => "[('forward', -617, 63, 121)]" \ No newline at end of file diff --git a/test1.py b/test1.py new file mode 100644 index 0000000..44e2612 --- /dev/null +++ b/test1.py @@ -0,0 +1,21 @@ +import os +from pocketsphinx import DefaultConfig, Decoder, get_model_path, get_data_path + +model_path = get_model_path() +data_path = get_data_path() + +# Create a decoder with a certain model +config = DefaultConfig() +config.set_string('-hmm', os.path.join(model_path, 'en-us')) +config.set_string('-lm', os.path.join(model_path, 'en-us.lm.bin')) +config.set_string('-dict', os.path.join(model_path, 'cmudict-en-us.dict')) +decoder = Decoder(config) + +# Decode streaming data +buf = bytearray(1024) +with open(os.path.join(data_path, 'goforward.raw'), 'rb') as f: + decoder.start_utt() + while f.readinto(buf): + decoder.process_raw(buf, False, False) + decoder.end_utt() +print('Best hypothesis segments:', [seg.word for seg in decoder.seg()]) \ No newline at end of file