當前位置: 首頁>>代碼示例>>Python>>正文


Python pyaudio.get_sample_size方法代碼示例

本文整理匯總了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 
開發者ID:batikim09,項目名稱:LIVE_SER,代碼行數:25,代碼來源:offline_ser.py

示例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) 
開發者ID:magenta,項目名稱:magenta,代碼行數:4,代碼來源:audio_recorder.py

示例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 
開發者ID:DelightRun,項目名稱:PyBaiduYuyin,代碼行數:16,代碼來源:__init__.py


注:本文中的pyaudio.get_sample_size方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。