我使用 github codespace 所提供的远程桌面搭建了服务。在一系列操作以后,我使用了 pulseaudio 来推流,并在 https://meowlegemeow-turbo-barnacle-5wwrw9vxvgxf4pr7-8001.preview.app.github.dev/ 推了一个实时的 PCM 音频流。
因为 codespace 不能时刻保持开启,所以并不是所有时刻这个网址都能打开。
现在我该用什么方法播放它?我尝试着用以下的办法爬下来,但事实上没有效果:
def get_content():
headers = {}
resp = requests.get(
"https://meowlegemeow-turbo-barnacle-5wwrw9vxvgxf4pr7-8001.preview.app.github.dev", verify=False, headers=headers)
print(resp.headers)
for i in resp.iter_content(chunk_size=1024):
print(i)
with wave.open('1.wav', 'wb') as wavfile:
wavfile.setparams((1, 2, 16000, 0, 'NONE', 'NONE'))
wavfile.writeframes(i)
play()
>>> {'Content-Length': '0', 'Date': 'Wed, 05 Jul 2023 09:17:54 GMT', 'Server': 'Kestrel'}
请求头已经省略。