fix: load method

This commit is contained in:
Félix Voituret
2019-11-06 18:18:30 +01:00
parent c23270a5df
commit 7f759e0695

View File

@@ -60,7 +60,7 @@ class FFMPEGProcessAudioAdapter(AudioAdapter):
raise IOError('No stream was found with ffprobe') raise IOError('No stream was found with ffprobe')
metadata = next( metadata = next(
stream stream
for stream in probe['stream'] for stream in probe['streams']
if stream['codec_type'] == 'audio') if stream['codec_type'] == 'audio')
n_channels = metadata['channels'] n_channels = metadata['channels']
if sample_rate is None: if sample_rate is None:
@@ -75,7 +75,7 @@ class FFMPEGProcessAudioAdapter(AudioAdapter):
.input(path, **input_kwargs) .input(path, **input_kwargs)
.output('-', format='f32le') .output('-', format='f32le')
.overwrite_output() .overwrite_output()
.run(quiet=True)) .run(capture_stdout=True, capture_stderr=True))
waveform = np.frombuffer(buffer, dtype='<f4').reshape(-1, n_channels) waveform = np.frombuffer(buffer, dtype='<f4').reshape(-1, n_channels)
if not waveform.dtype == np.dtype(dtype): if not waveform.dtype == np.dtype(dtype):
waveform = waveform.astype(dtype) waveform = waveform.astype(dtype)
@@ -112,8 +112,7 @@ class FFMPEGProcessAudioAdapter(AudioAdapter):
.output(path, format='f32le', **output_kwargs) .output(path, format='f32le', **output_kwargs)
.run_async(pipe_stdin=True)) .run_async(pipe_stdin=True))
try: try:
process.stdin.write( process.stdin.write(data.astype('<f4').tostring())
data.astype('<f4').tostring())
process.stdin.close() process.stdin.close()
process.wait() process.wait()
except IOError: except IOError: