Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2018
429
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. #!usr/bin/env python
  2. #coding=utf-8
  3.  
  4. import pyaudio
  5. import numpy as np
  6. import soundfile as sf
  7.  
  8. audio = pyaudio.PyAudio()
  9. stream = audio.open(format=pyaudio.paFloat32,
  10. channels=2,
  11. rate=48000,
  12. output=True,
  13. )
  14.  
  15. with open('piano2.wav', 'r') as f:
  16. while True:
  17. dataa, samplerate = sf.read(f)
  18. data = dataa.astype(np.float32).tostring()
  19. stream.write(data)
  20. ##################################################################################
  21.  
  22. C:\Python27\eqso>aanikoe.py
  23. File "C:\Python27\eqso\aanikoe.py", line 16
  24. while 1 < 2
  25. ^
  26. SyntaxError: invalid syntax
  27.  
  28. C:\Python27\eqso>aanikoe.py
  29. Traceback (most recent call last):
  30. File "C:\Python27\eqso\aanikoe.py", line 17, in <module>
  31. dataa, samplerate = sf.read(f)
  32. File "C:\Python27\lib\site-packages\soundfile.py", line 373, in read
  33. subtype, endian, format, closefd) as f:
  34. File "C:\Python27\lib\site-packages\soundfile.py", line 740, in __init__
  35. self._file = self._open(file, mode_int, closefd)
  36. File "C:\Python27\lib\site-packages\soundfile.py", line 1265, in _open
  37. "Error opening {0!r}: ".format(self.name))
  38. File "C:\Python27\lib\site-packages\soundfile.py", line 1455, in _error_check
  39. raise RuntimeError(prefix + _ffi.string(err_str).decode('utf-8', 'replace'))
  40. RuntimeError: Error opening <open file 'piano2.wav', mode 'r' at 0x000000000AF464B0>: File contains data in an unknown format.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement