From 21bab7682d7f0babf83fb832b4f880249db5ac2e Mon Sep 17 00:00:00 2001 From: unix-axwell <30478004+unix-axwell@users.noreply.github.com> Date: Sun, 9 Mar 2025 20:02:21 +0000 Subject: [PATCH] Create B2AConv --- B2AConv | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 B2AConv diff --git a/B2AConv b/B2AConv new file mode 100644 index 0000000..e0e7caf --- /dev/null +++ b/B2AConv @@ -0,0 +1,76 @@ +import wave +import struct +import numpy as np +import os + +def data_to_audio(file_path, output_wav, freq_0=1000, freq_1=2000, sample_rate=44100, duration=0.05): + """ + Convert file data to audio (simple FSK-style encoding) + """ + with open(file_path, 'rb') as f: + data = f.read() + + # Prepare WAV file + wav_file = wave.open(output_wav, 'w') + wav_file.setnchannels(1) + wav_file.setsampwidth(2) + wav_file.setframerate(sample_rate) + + def write_tone(freq): + samples = int(sample_rate * duration) + for i in range(samples): + value = int(32767.0 * 0.5 * + struct.pack('