lire du son en format natif avec python

2018-03-21 Thread asphjt--- via Python-list
Bonjour à tous,
En utilisant le module pyaudio pour enregistrer du son, j'ai une chaine de 
caractères de la forme 
b'\x01\x00\n\x00\x04\x00\xfe\xff\x04\x00\x0b\x00\n\x00\x07\x00'b'\x01\x00\xff\xff\x00\x00\xff\xff\x01\x00\n\x00\n\x00\n\x00
 qui correspond aux valeurs hexadécimales (je pense) du son brut, et j'aimerai 
pouvoir le lire sans passer par un encodage ou format de compression comme mp3, 
wav,...
J'ai lu que l'on pouvait le faire avec ossaudiodev, mais je n'arrive pas à le 
trouver, ni à l'installer depuis pyzo.
Si quelqu'un peut m'aider, merci à lui d'avance.
-- 
https://mail.python.org/mailman/listinfo/python-list


OSError: [Errno -9981] Input overflowed

2018-04-04 Thread asphjt--- via Python-list
Here is my code:

import pyaudio
tim=1
chunk = 8
FORMAT = pyaudio.paInt16
CHANNELS = 1
RATE = 5
p = pyaudio.PyAudio()
s = p.open(format = FORMAT,channels = CHANNELS,rate = RATE,input = 
True,output=True,frames_per_buffer = chunk)
d=[]
print((RATE // chunk) * tim)
for i in range(0, (RATE // chunk * tim)):
data = s.read(chunk)
d.append(data)
s.close()
p.terminate()


There is no problem, but if I want to use the variable data during the loop 
for, I have this error:

Traceback (most recent call last):
  File "", line 14, in 
data = s.read(chunk)
  File "c:\users\tissot\miniconda3\lib\site-packages\pyaudio.py", line 608, in 
read
return pa.read_stream(self._stream, num_frames, exception_on_overflow)
OSError: [Errno -9981] Input overflowed


for example if i want to print data with this code:

import pyaudio
tim=1
chunk = 8
FORMAT = pyaudio.paInt16
CHANNELS = 1
RATE = 5
p = pyaudio.PyAudio()
s = p.open(format = FORMAT,channels = CHANNELS,rate = RATE,input = 
True,output=True,frames_per_buffer = chunk)
d=[]
print((RATE // chunk) * tim)
for i in range(0, (RATE // chunk * tim)):
data = s.read(chunk)
d.append(data)
print(data)# here is the problem
s.close()
p.terminate()

In reality I would like to send it to my Arduino card as and when 
recording,(using: ser = serial.Serial('COM4', 115200)   ser.write(data) ) but I 
have the same error as when I display it on the screen.
If anyone knows an answer to this question, thank you in advance.
-- 
https://mail.python.org/mailman/listinfo/python-list