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


Python wave.Wave_read方法代碼示例

本文整理匯總了Python中wave.Wave_read方法的典型用法代碼示例。如果您正苦於以下問題:Python wave.Wave_read方法的具體用法?Python wave.Wave_read怎麽用?Python wave.Wave_read使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在wave的用法示例。


在下文中一共展示了wave.Wave_read方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: import wave [as 別名]
# 或者: from wave import Wave_read [as 別名]
def __init__(self, f):
        self._blockalign = None
        # can't use super in OldStyle 2.7 class
        wave.Wave_read.__init__(self, f) 
開發者ID:markreidvfx,項目名稱:pyaaf2,代碼行數:6,代碼來源:audio.py

示例2: is_valid_wav

# 需要導入模塊: import wave [as 別名]
# 或者: from wave import Wave_read [as 別名]
def is_valid_wav(filename):
    # check the sampling rate and number bits of the WAV
    try:
        wav_file = wave.Wave_read(filename)
    except:
        return False
    if wav_file.getframerate() != 16000 or wav_file.getsampwidth() != 2 or wav_file.getnchannels() != 1 \
        or wav_file.getcomptype() != 'NONE':
        return False
    return True 
開發者ID:MLSpeech,項目名稱:DeepFormants,代碼行數:12,代碼來源:utilities.py

示例3: build_data

# 需要導入模塊: import wave [as 別名]
# 或者: from wave import Wave_read [as 別名]
def build_data(wav,begin=None,end=None):
    wav_in_file = wave.Wave_read(wav)
    wav_in_num_samples = wav_in_file.getnframes()
    N = wav_in_file.getnframes()
    dstr = wav_in_file.readframes(N)
    data = np.fromstring(dstr, np.int16)
    if begin is not None and end is not None:
        #return data[begin*16000:end*16000] #numpy 1.11.0
        return data[np.int(begin*16000):np.int(end*16000)] #numpy 1.14.0
    X = []
    l = len(data)
    for i in range(0, l-100, 160):
        X.append(data[i:i + 480])
    return X 
開發者ID:MLSpeech,項目名稱:DeepFormants,代碼行數:16,代碼來源:extract_features.py

示例4: __init__

# 需要導入模塊: import wave [as 別名]
# 或者: from wave import Wave_read [as 別名]
def __init__(self, wav_reader_or_stream: Union[wave.Wave_read, BinaryIO], frames_per_sample: int) -> None:
        if isinstance(wav_reader_or_stream, io.RawIOBase):
            self.source = wave.open(wav_reader_or_stream, "r")   # type: wave.Wave_read
        else:
            assert isinstance(wav_reader_or_stream, wave.Wave_read)
            self.source = wav_reader_or_stream
        self.samplewidth = self.source.getsampwidth()
        self.samplerate = self.source.getframerate()
        self.nchannels = self.source.getnchannels()
        self.frames_per_sample = frames_per_sample
        self.filters = []           # type: List[SampleFilter]
        self.frames_filters = []    # type: List[FramesFilter]
        self.source.readframes(1)  # warm up the stream 
開發者ID:irmen,項目名稱:synthesizer,代碼行數:15,代碼來源:streaming.py

示例5: build_mock_wave

# 需要導入模塊: import wave [as 別名]
# 或者: from wave import Wave_read [as 別名]
def build_mock_wave(nchannels=2, sampwidth=2, framerate=44100, nframes=100,
                    comptype="NONE", compname="not compressed", bytes=b'\x4a'):
        mock_wave_read = MagicMock(spec=wave.Wave_read)
        mock_wave_read.getparams.return_value = (nchannels, sampwidth,
                                                 framerate, nframes, comptype,
                                                 compname)

        # Return some bytes
        def mock_readframes(frames):
            return bytes * sampwidth * frames * nchannels
        mock_wave_read.readframes = MagicMock(side_effect=mock_readframes)
        mock_wave = MagicMock(spec=wave)
        mock_wave.open.return_value = mock_wave_read
        return mock_wave 
開發者ID:cristoper,項目名稱:wav2vec,代碼行數:16,代碼來源:testwavedecoder.py

示例6: test_read_audio_3

# 需要導入模塊: import wave [as 別名]
# 或者: from wave import Wave_read [as 別名]
def test_read_audio_3(self):
        try:
            import wave
        except ImportError:
            unittest.TestCase.skipTest(self, "wave is not found in the libraries.")

        if self.data_dir_local is None:
            unittest.TestCase.skipTest(self, "DLPY_DATA_DIR_LOCAL is not set in the environment variables.")

        wave_reader, wave_params = read_audio(os.path.join(self.data_dir_local, "sample_16bit_16khz.wav"))
        self.assertIsInstance(wave_reader, wave.Wave_read)
        self.assertIsInstance(wave_params, tuple)
        self.assertIsNotNone(wave_reader)
        self.assertIsNotNone(wave_params)
        wave_reader.close() 
開發者ID:sassoftware,項目名稱:python-dlpy,代碼行數:17,代碼來源:test_speech.py

示例7: __init__

# 需要導入模塊: import wave [as 別名]
# 或者: from wave import Wave_read [as 別名]
def __init__(self, audio_reader, little_endian, samples_24_bit_pretending_to_be_32_bit):
            self.audio_reader = audio_reader # an audio file object (e.g., a `wave.Wave_read` instance)
            self.little_endian = little_endian # whether the audio data is little-endian (when working with big-endian things, we'll have to convert it to little-endian before we process it)
            self.samples_24_bit_pretending_to_be_32_bit = samples_24_bit_pretending_to_be_32_bit # this is true if the audio is 24-bit audio, but 24-bit audio isn't supported, so we have to pretend that this is 32-bit audio and convert it on the fly 
開發者ID:jacobajit,項目名稱:AlexaBot,代碼行數:6,代碼來源:pyDubMod.py


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