I suppose you use a wave library , right?
The docs say:
wave.open (file [, mode])
If the file is a string, open the file with this name, otherwise treat it as a file matched for search.
This means that you must do something in accordance with:
>>> import wave >>> from StringIO import StringIO >>> file_on_disk = open('myfile.wav', 'rb') >>> file_in_memory = StringIO(file_on_disk.read()) >>> file_on_disk.seek(0) >>> file_in_memory.seek(0) >>> file_on_disk.read() == file_in_memory.read() True >>> wave.open(file_in_memory, 'rb') <wave.Wave_read instance at 0x1d6ab00>
EDIT (see comments): Just in case, your problem is not only with reading a file from memory, but also with playing it from python in general ...
Tu option uses pymedia
import time, wave, pymedia.audio.sound as sound f= wave.open( 'YOUR FILE NAME', 'rb' )
[source: pymedia tutorial (for brevity, I skipped their explanatory comments]
source share