Created
April 9, 2023 19:26
-
-
Save blueBye/a6cf3b64f74ce6a7146bf6a8c40452d6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import wavio | |
rate = 44100 # samples per second | |
T = 1 # sample duration (seconds) | |
f = 44.0 # sound frequency (Hz) | |
t = np.linspace(0, T, int(T*rate/10), endpoint=False) | |
result = [] | |
data = "101101000000110011010001010010110000111000001101010011010000010010110011000011101000100001011000010010000010101100010010100011" | |
for d in data: | |
result.append(int(d) * t) | |
t = np.reshape(result, [1, -1]) | |
x = np.sin(2*np.pi*f*t)[0] | |
wavio.write("sine.wav", x, rate, sampwidth=3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment