本文整理匯總了Python中pyaudio.get_sample_size方法的典型用法代碼示例。如果您正苦於以下問題:Python pyaudio.get_sample_size方法的具體用法?Python pyaudio.get_sample_size怎麽用?Python pyaudio.get_sample_size使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pyaudio
的用法示例。
在下文中一共展示了pyaudio.get_sample_size方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: predict_file
# 需要導入模塊: import pyaudio [as 別名]
# 或者: from pyaudio import get_sample_size [as 別名]
def predict_file(dec, pyaudio, path, frames, args, rate = 16000, format = pyaudio.paInt16, save = False):
wf = wave.open(path, 'wb')
wf.setnchannels(1)
wf.setsampwidth(pyaudio.get_sample_size(format))
wf.setframerate(rate)
#this code works for only for pulseaudio
#wf.writeframes(b''.join(frames))
wf.writeframes(frames)
wf.close()
results = dec.predict_file(path, feat_mode = args.feat_mode, feat_dim = args.feat_dim, three_d = args.three_d)
if save == False:
os.remove(path)
if args.predict_mode == 0:
task_outputs = dec.returnDiff(results)
elif args.predict_mode == 1:
task_outputs = dec.returnLabel(results)
else:
task_outputs = dec.returnClassDist(results)
return task_outputs
#main loop for speech emotion recognition
示例2: bytes_per_sample
# 需要導入模塊: import pyaudio [as 別名]
# 或者: from pyaudio import get_sample_size [as 別名]
def bytes_per_sample(self):
return pyaudio.get_sample_size(self.pyaudio_format)
示例3: __init__
# 需要導入模塊: import pyaudio [as 別名]
# 或者: from pyaudio import get_sample_size [as 別名]
def __init__(self, device_index = None):
assert device_index is None or isinstance(device_index, int), "Device index must be None or an integer"
if device_index is not None: # ensure device index is in range
audio = pyaudio.PyAudio(); count = audio.get_device_count(); audio.terminate() # obtain device count
assert 0 <= device_index < count, "Device index out of range"
self.device_index = device_index
self.format = pyaudio.paInt16 # 16-bit int sampling
self.SAMPLE_WIDTH = pyaudio.get_sample_size(self.format)
self.RATE = 16000 # sampling rate in Hertz
self.CHANNELS = 1 # mono audio
self.CHUNK = 1024 # number of frames stored in each buffer
self.audio = None
self.stream = None