def samples_to_file(samples, rate, file_out, fmt='', dtype='int16'):
 (file_fmt, data_fmt) = _get_pyo_codes(fmt, dtype, file_out)
 if (type(samples) == np.ndarray):
  samples = samples.tolist()
 if (type(samples) != list):
  raise TypeError('samples should be a list or np.array')
 try:
  pyo.savefile(samples, path=file_out, sr=int(rate), channels=1, fileformat=file_fmt, sampletype=data_fmt)
 except Exception:
  msg = 'could not save `{0}`; permissions or other issue?'
  raise IOError(msg.format(file_out))

def samples_to_file ( samples , rate , file_out , fmt = '' , dtype = 'int16' ) : ( file_fmt , data_fmt ) = _get_pyo_codes ( fmt , dtype , file_out ) if ( type ( samples ) == np . ndarray ) : samples = samples . tolist ( ) if ( type ( samples ) != list ) : raise TypeError ( 'samples should be a list or np.array' ) try : pyo . savefile ( samples , path = file_out , sr = int ( rate ) , channels = 1 , fileformat = file_fmt , sampletype = data_fmt ) except Exception : msg = 'could not save `{0}`; permissions or other issue?' raise IOError ( msg . format ( file_out ) )
write data to file .