Convert an audio stream to a wav file

1
def getStream(frec, duration):
    NF = int(BITRATE* duration)
    RF = NF % BITRATE
    WD = ''
    for x in range(NF):
        WD = WD+chr(int(math.sin(x/(BITRATE/frec)/math.pi))*127+128))


    for x in range(RF):
        WD = WD+chr(128)

    return WD


file = open("sound.wav", "wb")
file.write(getStream(440, 2))

When I open the file it appears in windows player:

Windows Media Player can not play the file. The Player may not support the file type or codec used to compress the file.

    
asked by Hector Seguro 01.06.2016 в 04:21
source

0 answers