Пример #1
0
 def testZeroSampleRateInvalid(self):
     with self.cached_session() as sess:
         encode_op = ffmpeg.encode_audio([[0.0], [1.0]],
                                         file_format='wav',
                                         samples_per_second=0)
         with six.assertRaisesRegex(self, Exception, 'must be positive'):
             sess.run(encode_op)
Пример #2
0
 def testRoundTripWithPlaceholderSampleRate(self):
     with self.cached_session():
         placeholder = array_ops.placeholder(dtypes.int32)
         audio_op = ffmpeg.decode_audio(self._contents,
                                        file_format='wav',
                                        samples_per_second=placeholder,
                                        channel_count=1)
         encode_op = ffmpeg.encode_audio(audio_op,
                                         file_format='wav',
                                         samples_per_second=placeholder)
         encoded_contents = encode_op.eval(feed_dict={placeholder: 10000})
         self._compareWavFiles(self._contents, encoded_contents)
Пример #3
0
 def testRoundTrip(self):
     """Reads a wav file, writes it, and compares them."""
     with self.cached_session():
         audio_op = ffmpeg.decode_audio(self._contents,
                                        file_format='wav',
                                        samples_per_second=10000,
                                        channel_count=1)
         encode_op = ffmpeg.encode_audio(audio_op,
                                         file_format='wav',
                                         samples_per_second=10000)
         encoded_contents = encode_op.eval()
         self._compareWavFiles(self._contents, encoded_contents)
Пример #4
0
 def testFloatingPointSampleRateInvalid(self):
     with self.cached_session():
         with self.assertRaises(TypeError):
             ffmpeg.encode_audio([[0.0], [1.0]],
                                 file_format='wav',
                                 samples_per_second=12345.678)