-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switching audio input/output device #4
Comments
Since there is no API reference for Python at this point, please refer to Audio Device Manager and Video Device Manager which is similar. Besides, Here is a naive example: >>> import agorartc
>>> rtc = agorartc.createRtcEngineBridge()
>>> eventHandler = agorartc.RtcEngineEventHandlerBase()
>>> rtc.initEventHandler(eventHandler)
0 (Success)
>>> rtc.initialize("your-appID", None, agorartc.AREA_CODE_GLOB & 0xFFFFFFFF) # If you do not have an App ID, see Appendix (https://github.com/AgoraIO-Community/Agora-Python-SDK#appendix).
0 (Success)
>>> audio_recording_device_manager, err = rtc.createAudioRecordingDeviceManager()
>>> err
0 (Success)
>>> audio_recording_device_manager.getCount() # Obtain the number of microphones.
2 (There are 2 microphones)
>>> audio_recording_device_manager.getDevice(0, '', '') # Obtain device information of the 1st microphone.
[0, 'default (MacBook Pro Microphone)', '83'] ([ERROR_CODE, device_name, device_id])
>>> audio_recording_device_manager.getDevice(1, '', '') # Obtain device information of the 2nd microphone.
[0, 'HD Pro Webcam C920', '88'] ([ERROR_CODE, device_name, device_id])
>>> audio_recording_device_manager.setDevice('88') # Set the 2nd microphone as the recording device.
[0, '88'] ([ERROR_CODE, device_id])
>>> rtc.release() |
Thanks! |
Following this pattern, after calling import agorartc
RTC = agorartc.createRtcEngineBridge()
eventHandler = agorartc.RtcEngineEventHandlerBase()
RTC.initEventHandler(eventHandler)
RTC.initialize(Clubhouse.AGORA_KEY, None, agorartc.AREA_CODE_GLOB & 0xFFFFFFFE)
audio_recording_device_manager, err = RTC.createAudioRecordingDeviceManager()
audio_count = audio_recording_device_manager.getCount()
for i in range(0, audio_count):
if "VB-Cable" in audio_recording_device_manager.getDevice(i, '', ''):
print("Set Audio input to: {}".format(audio_recording_device_manager.getDevice(i, '', '')) )
print(audio_recording_device_manager.setDevice(audio_recording_device_manager.getDevice(i, '', '')[2])) The second part of the code simply uses the number from the test device as the input for setDevice. |
@shayanb By the way, a typo in your code: |
Thanks @YiqingJackieHuang . yes, as soon as it gets to the
|
Hi, @shayanb. Please provide me with the crash report to find out the possible cause. The crash report can be found in Console app on macOS. |
Here you go:
|
Hi, @shayanb. I find out that Python 3.9 causes the problem while it runs properly on Python 3.8. Would you mind using py38 instead? I am going to dig deeper into the problem. As soon as I find it out, I will notify you. |
Thanks @YiqingJackieHuang , it seems to be working on Python 3.8.6 now. |
Hi, I'm trying to understand how to switch input and output device using python sdk
I can get audioDeviceManager, but I don't understand how to set, i.e. input device using setDevice.
The text was updated successfully, but these errors were encountered: