我試圖使用pyo庫播放聲音。使用Pyo在Python中播放聲音
下面的代碼:
from psychopy import sound, logging, core
logging.console.setLevel(logging.DEBUG)
from pyo import *
s = Server()
s.setInputDevice(4)
s.setOutputDevice(4)
s.boot()
s.start()
print "output", pa_get_output_devices()
print "input", pa_get_input_devices()
play_audio1 = sound.SoundPyo(value = 'LRsound.wav', stereo = True)
play_audio1.play()
core.wait(1) # wait so the sound can play
返回此輸出:
pyo version 0.8.0 (uses single precision)
Portmidi warning: could not open midi output 0 (Microsoft MIDI Mapper): PortMidi: `Host error'
output (['Microsoft Sound Mapper - Output', 'Speakers/Headphones (Realtek ', 'Primary Sound Driver', 'Speakers/Headphones (Realtek High Definition Audio)', 'Realtek ASIO', 'Speakers/Headphones (Realtek High Definition Audio)'], [0, 1, 2, 3, 4, 5])
input (['Realtek ASIO'], [4])
Server not booted. The Server must be booted! portaudio error in Pa_OpenStream: Illegal combination of I/O devices Portaudio error: Illegal combination of I/O devicesportaudio error in Pa_AbortStream: Invalid stream pointer portaudio error in Pa_CloseStream: Invalid stream pointer
正如你可以從代碼,我已經嘗試確保輸入和輸出設備是輸出看到相同。
這是由於有關非法組合I/O設備的消息。誠然,你也可以看到我的嘗試失敗了。帶或不帶Server()
代碼塊時會出現相同的錯誤消息。
我在PsychoPy中運行了上面的代碼。當我在Spyder中運行相同的代碼時,它實際上並沒有通過:
play_audio1 = sound.SoundPyo(value = 'LRsound.wav', stereo = True)
它只是掛起了無所事事。
任何想法爲什麼pyo不是在玩python,因爲它應該?關於如何修復它的任何想法?
謝謝你的時間。
我曾嘗試過這種解決方案,但沒有奏效。我最終使用PyGame來滿足我的音頻需求。 (還是)感謝你的建議。 – Docconcoct