如何使用python在没有WASAPI的情况下钩住输出音频?

2024-09-29 21:24:07 发布

您现在位置:Python中文网/ 问答频道 /正文

我现在正在使用pyaudio。 但是我的电脑没有WASAPI。 所以我不能使用环回

#Select Device
        for i in range(0, self.virtual_p.get_device_count()):
            info = self.virtual_p.get_device_info_by_index(i)
   
            if info['name'] == 'Line 1 (Virtual Audio Cable)' and \
                    self.virtual_p.get_host_api_info_by_index(info["hostApi"])["name"] == 'Windows WASAPI' and \
                    info['maxInputChannels'] == 0:
                device_id = i
                continue
            if info['name'].split('(')[0].strip() == self.default_device_name and \
                    self.virtual_p.get_host_api_info_by_index(info["hostApi"])["name"] == 'Windows WASAPI' and \
                    info['maxInputChannels'] == 0:
                device_id1 = i

这是我的音频设备列表

(base) C:\Users\Ivan>python -m sounddevice
   0 Microsoft Sound Mapper - Input, MME (2 in, 0 out)
>  1 Line 1 (Virtual Audio Cable), MME (8 in, 0 out)
   2 Microphone Array (Realtek(R) Au, MME (4 in, 0 out)
   3 AI Noise-cancelling Input (ASUS, MME (2 in, 0 out)
   4 Microsoft Sound Mapper - Output, MME (0 in, 2 out)
<  5 Speakers (Realtek(R) Audio), MME (0 in, 2 out)
   6 Speakers (Virtual Audio Cable), MME (0 in, 8 out)
   7 AI Noise-cancelling Output (ASU, MME (0 in, 2 out)
   8 Microphone (Realtek HD Audio Mic input), Windows WDM-KS (2 in, 0 out)
   9 Headphones (Realtek HD Audio 2nd output), Windows WDM-KS (0 in, 2 out)
  10 Microphone Array (Realtek HD Audio Mic Array input), Windows WDM-KS (4 in, 0 out)
  11 Speakers 1 (Realtek HD Audio output with HAP), Windows WDM-KS (0 in, 2 out)
  12 Speakers 2 (Realtek HD Audio output with HAP), Windows WDM-KS (0 in, 2 out)
  13 PC Speaker (Realtek HD Audio output with HAP), Windows WDM-KS (2 in, 0 out)
  14 Line Out (Virtual Cable 1), Windows WDM-KS (0 in, 8 out)
  15 Mic 1 (Virtual Cable 1), Windows WDM-KS (8 in, 0 out)
  16 Line 1 (Virtual Cable 1), Windows WDM-KS (8 in, 0 out)
  17 S/PDIF 1 (Virtual Cable 1), Windows WDM-KS (8 in, 0 out)
  18 Line (), Windows WDM-KS (2 in, 0 out)
  19 AI Noise-cancelling Input (Intelligo VAC (W)), Windows WDM-KS (2 in, 0 out)
  20 Line Out 1 (Intelligo VAC (W)), Windows WDM-KS (0 in, 2 out)
  21 System Virtual Line (Intelligo VAC (W)), Windows WDM-KS (2 in, 0 out)
  22 Line Out 2 (Intelligo VAC (W)), Windows WDM-KS (0 in, 2 out)
  23 Output (@System32\drivers\bthhfenum.sys,#4;%1 Hands-Free HF Audio%0
;(Darin's Galaxy S20 FE 5G)), Windows WDM-KS (0 in, 1 out)
  24 Input (@System32\drivers\bthhfenum.sys,#4;%1 Hands-Free HF Audio%0
;(Darin's Galaxy S20 FE 5G)), Windows WDM-KS (1 in, 0 out)

我找不到WASAPI。 请给我一个解决这些问题的方法


Tags: inselfinfodevicewindowslinevirtualout

热门问题