Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import wave
- import array
- def wav_to_raw(input_wav, output_raw):
- with wave.open(input_wav, 'rb') as wav_file:
- # Получаем параметры аудио
- sample_width = wav_file.getsampwidth()
- frame_rate = wav_file.getframerate()
- # Читаем все аудиоданные
- audio_data = wav_file.readframes(wav_file.getnframes())
- # Преобразуем байты в массив
- audio_array = array.array('h', audio_data)
- # Записываем данные в файл RAW
- with open(output_raw, 'wb') as raw_file:
- audio_array.tofile(raw_file)
- # Пример использования
- input_wav_file = 'websdr_recording_start_2024-01-16T17_17_03Z_140.1kHz.wav'
- output_raw_file = 'output.raw'
- wav_to_raw(input_wav_file, output_raw_file)
Advertisement
Add Comment
Please, Sign In to add comment