since 2010-12-04
http://people.csail.mit.edu/hubert/pyaudio/
http://people.csail.mit.edu/hubert/pyaudio/docs/ ドキュメント
v19 の blocking-mode audio I/O のみサポートしている。
pyaudio-0.2.4.py27.exe
以下 nvdajp の _jtalk_core.py の一部として書いた。16bit short int 16000Hz mono のバイト列を受け取る。
出力終了の検出がうまくできないので time.sleep している。
def pa_play(data): # requires pyaudio (PortAudio wrapper) # http://people.csail.mit.edu/hubert/pyaudio/ import time import pyaudio p = pyaudio.PyAudio() stream = p.open(format = p.get_format_from_width(2), channels = 1, rate = 16000, output = True) size = len(data) pos = 0 # byte count while pos < size: a = stream.get_write_available() * 2 o = data[pos:pos+a] stream.write(o) pos += a time.sleep(float(size) / 2 / 16000) stream.close() p.terminate()
下記がうまく入らない:
$ sudo dpkg -i python-pyaudio_0.2.4-1_i386.deb Selecting previously deselected package python-pyaudio. (Reading database ... 441812 files and directories currently installed.) Unpacking python-pyaudio (from .../python-pyaudio_0.2.4-1_i386.deb) ... dpkg: dependency problems prevent configuration of python-pyaudio: python-pyaudio depends on python-support (>= 0.90.0); however: Version of python-support on system is 0.8.7ubuntu4. dpkg: error processing python-pyaudio (--install): dependency problems - leaving unconfigured Processing triggers for doc-base ... Processing 1 added doc-base file(s)... Registering documents with scrollkeeper... Errors were encountered while processing: python-pyaudio
ソースから入れるべき?