1818from absl import logging
1919
2020#pylint: disable=no-name-in-module
21- import tensorflow as tf
22- from tensorflow .contrib . framework . python .ops import audio_ops as contrib_audio
21+ import delta . compat as tf
22+ from tensorflow .python .ops import gen_audio_ops as audio_ops
2323
2424from delta import utils
25+ from delta .utils .hparam import HParams
2526from delta .layers .ops import py_x_ops
2627
2728
@@ -36,7 +37,7 @@ def speech_params(sr=16000,
3637 cmvn = False ,
3738 cmvn_path = '' ):
3839 ''' speech feat params '''
39- p = tf . contrib . training . HParams ()
40+ p = HParams ()
4041 p .add_hparam ("audio_sample_rate" , sr )
4142 if dither :
4243 p .add_hparam ("audio_dither" , 1.0 / np .iinfo (np .int16 ).max )
@@ -68,7 +69,7 @@ def read_wav(wavfile, params):
6869 '''
6970 contents = tf .read_file (wavfile )
7071 #pylint: disable=no-member
71- waveforms = contrib_audio .decode_wav (
72+ waveforms = tf . audio .decode_wav (
7273 contents ,
7374 desired_channels = params .audio_desired_channels ,
7475 desired_samples = params .audio_desired_samples ,
@@ -103,7 +104,7 @@ def powspec_feat(samples,
103104 del preemph
104105
105106 #pylint: disable=no-member
106- feat = contrib_audio .audio_spectrogram (
107+ feat = audio_ops .audio_spectrogram (
107108 samples ,
108109 window_size = winlen * sr ,
109110 stride = winstep * sr ,
@@ -303,7 +304,7 @@ def _loop_body(time, inputs, output_tas):
303304 loop_vars = (time , waveforms , output_tas )
304305
305306 parallel_iterations = 10
306- shape_invariants = tf .contrib . framework . nest .map_structure (
307+ shape_invariants = tf .nest .map_structure (
307308 lambda t : tf .TensorShape (None ), loop_vars )
308309
309310 (time , inputs , output_tas ) = tf .while_loop (
@@ -361,7 +362,7 @@ def _loop_body(time, end_time, context, left_context, right_context,
361362 loop_vars = (time , T , context , left_context , right_context , output_tas )
362363
363364 parallel_iterations = 10
364- shape_invariants = tf .contrib . framework . nest .map_structure (
365+ shape_invariants = tf .nest .map_structure (
365366 lambda t : tf .TensorShape (None ), loop_vars )
366367
367368 (time , end_time , context , left_context , right_context ,
0 commit comments