所以我一直在尝试一个涉及音频的项目,到目前为止,我尝试过的每一个库都以某种方式损坏,我认为最后的手段可能是声音设备,因为它似乎有一些我想要的其他有趣的属性试用。我基本上复制粘贴了他们在他们的网站上提供的示例代码,并提出了一个错误清单。我的代码非常简单,我添加的只是一个输入命令,以确保它会在这种情况下发出声音。如果任何其他库可能工作,或者只是一个愚蠢的错误,任何帮助都会很棒,谢谢!
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.