0

So I have been trying to work on a project that involves audio, so far every single library I have tried has broken in one way or another, I figured last resort could be Sound Device because it seems to have some other interesting properties I wanted to try out. I basically copy-pasted the example code they gave on their site and came up with a laundry list of errors. My code is pretty straight forward, all I added was an Input command to make sure it would make the sound under that one condition. If any other libraries might work, or if there is just a dumb mistake, any help would be amazing, thank you!

import sounddevice as sd
import soundfile as sf

fileC = 'PianoC.wav'
UI = input("Press C")
if UI == "c":
    data,fs = sf.read(fileC,dtype ='float32')
    sd.play(data,fs)
    Status = sd.wait 

Traceback (most recent call last):
  File "C:\Users\**\AppData\Local\Programs\Python\Python38\key.py", line 7, in <module>
    data,fs = sf.read(fileC,dtype ='float32')
  File "C:\Users\**\AppData\Local\Programs\Python\Python38\lib\site-packages\soundfile.py", line 256, in read
    with SoundFile(file, 'r', samplerate, channels,
  File "C:\Users\**\AppData\Local\Programs\Python\Python38\lib\site-packages\soundfile.py", line 629, in __init__
    self._file = self._open(file, mode_int, closefd)
  File "C:\Users\**\AppData\Local\Programs\Python\Python38\lib\site-packages\soundfile.py", line 1183, in _open
    _error_check(_snd.sf_error(file_ptr),
  File "C:\Users\**\AppData\Local\Programs\Python\Python38\lib\site-packages\soundfile.py", line 1357, in _error_check
    raise RuntimeError(prefix + _ffi.string(err_str).decode('utf-8', 'replace'))
RuntimeError: Error opening 'PianoC.wav': System error.
ForceBru
  • 43,482
  • 10
  • 63
  • 98

0 Answers0