Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
324 views
in Technique[技术] by (71.8m points)

winapi - Redirect audio output to input stream - python-sounddevice

I'm using the sounddevice library for Python. So far I was able to do some basic stuff with audio files through this library, like playing back a WAV format file using this code from one of the tutorials:

#!/usr/bin/env python3
import sounddevice as sd
import soundfile as sf

try:
    data, fs = sf.read('[path to audio file]', dtype='float32')
    sd.play(data, fs, device=None)
    status = sd.wait()
except KeyboardInterrupt:
    print("Keyboard interrupt")
except Exception as e:
    print("Internal exception")

However, I need to redirect that audio output to the system's microphone input instead of the speakers, and I'm not sure how to do that with this library since there isn't a lot of clear documentation on this. Is there a way to do this with sounddevice? I would like to avoid directly interacting with the OS sound drivers, since ideally this should be cross-platform.

Thanks!

Edit: It seems like it's not possible to make this fully cross-platform, so ideally I would like to be able to use this with Windows and the WSAPI.

question from:https://stackoverflow.com/questions/65895838/redirect-audio-output-to-input-stream-python-sounddevice

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...