Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!usr/bin/env python
- #coding=utf-8
- import pyaudio
- import numpy as np
- import soundfile as sf
- audio = pyaudio.PyAudio()
- stream = audio.open(format=pyaudio.paFloat32,
- channels=2,
- rate=48000,
- output=True,
- )
- with open('piano2.wav', 'r') as f:
- while True:
- dataa, samplerate = sf.read(f)
- data = dataa.astype(np.float32).tostring()
- stream.write(data)
- ##################################################################################
- C:\Python27\eqso>aanikoe.py
- File "C:\Python27\eqso\aanikoe.py", line 16
- while 1 < 2
- ^
- SyntaxError: invalid syntax
- C:\Python27\eqso>aanikoe.py
- Traceback (most recent call last):
- File "C:\Python27\eqso\aanikoe.py", line 17, in <module>
- dataa, samplerate = sf.read(f)
- File "C:\Python27\lib\site-packages\soundfile.py", line 373, in read
- subtype, endian, format, closefd) as f:
- File "C:\Python27\lib\site-packages\soundfile.py", line 740, in __init__
- self._file = self._open(file, mode_int, closefd)
- File "C:\Python27\lib\site-packages\soundfile.py", line 1265, in _open
- "Error opening {0!r}: ".format(self.name))
- File "C:\Python27\lib\site-packages\soundfile.py", line 1455, in _error_check
- raise RuntimeError(prefix + _ffi.string(err_str).decode('utf-8', 'replace'))
- 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