Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from audio import *
- from sys import argv
- from PIL import Image
- import wave
- f = Image.open(argv[1])
- wav_bytes, duration_s = wav_bytes_from_spectrogram_image(f)
- wav_bytes = wav_bytes.read()
- print(duration_s)
- # Open a new wave file
- with wave.open('myfile.wav','wb') as wf:
- # Set the number of channels, sample width, and sample rate
- wf.setnchannels(1)
- wf.setsampwidth(2)
- wf.setframerate(44100)
- # Write the audio data to the file
- wf.writeframes(wav_bytes)
Advertisement
Add Comment
Please, Sign In to add comment