# Config for Model Input PreProcess
#rknn.config(quantized_dtype='dynamic_fixed_point-8')
#rknn.config(quantized_dtype='asymmetric_quantized-u8')
rknn.config()
# Load TensorFlow Model
print('--> Loading model')
rknn.load_tensorflow(tf_pb='./my_frozen_graph.pb',
inputs=['Reshape'],
outputs=['labels_softmax'],
input_size_list=[[1,3920]])
print('done')
# Build Model
print('--> Building model')
#rknn.build(do_quantization=False, dataset='./dataset.txt', pre_compile=False)
rknn.build(do_quantization=False)
print('done')
# Export RKNN Model
#rknn.export_rknn('./speech_command_quantized.rknn')
rknn.export_rknn('./speech_new.rknn')
语音识别的运行时代码:
#!/usr/bin/env python3
import numpy as np
import re
import math
import random
import tensorflow as tf
from rknn.api import RKNN
import soundfile as sf
import cv2
import tensorflow as tf
from tensorflow.contrib.framework.python.ops import audio_ops as contrib_audio
from tensorflow.python.framework import graph_util
def load_labels(filename):
"""Read in labels, one label per line."""
return [line.rstrip() for line in tf.gfile.GFile(filename)]
# Load TensorFlow Model
print('--> Loading model')
ret = rknn.load_rknn(path='./speech_new.rknn')
if ret != 0:
print('load_rknn failed')
exit(ret)
print('load_rknn done')