You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -10,16 +11,120 @@ This fork will allow you to use the WASAPI device as loopback using **PyAudio**.
10
11
11
12
</div>
12
13
14
+
<br /><br /><br /><br />
13
15
16
+
## For whom?
14
17
18
+
If you want to record sound from your speakers in python, then this is the fork for you.
19
+
20
+
> PyAudioW(*indows|ASAPI*)Patch come only with WMME, DirectX and WASAPI support
21
+
> if you need more -> create an issue
22
+
23
+
## How
24
+
25
+
The Windows Audio Session API ([WASAPI](https://docs.microsoft.com/en-us/windows/win32/coreaudio/wasapi)) allows you to use output devices (that support this API) in loopback mode. At the time of release, it was impossible to achieve this using the original version of PyAudio.
26
+
27
+
> Note: Now WASAPI loopback devices are duplicated at the end of the list as virtual devices. That is, to record from speakers, you need to use not just a WASAPI device, but its loopback analogue. All loopback devices are **input devices**.
28
+
29
+
## How to use
30
+
31
+
*Read -> Install -> Enjoy!*
32
+
33
+
### Installation
34
+
35
+
```bash
36
+
pip install
37
+
```
38
+
39
+
### In code
40
+
41
+
With new features:
42
+
43
+
```python
44
+
import pyaudiowpatch as pyaudio
45
+
46
+
with pyaudio.PyAudio() as p:
47
+
# Open PyA manager via context manager
48
+
with p.open(...) as stream:
49
+
# Open audio stream via context manager
50
+
# Do some staf
51
+
...
52
+
```
53
+
54
+
Or in original PyAudio way:
55
+
56
+
```python
57
+
import pyaudiowpatch as pyaudio
58
+
59
+
p = pyaudio.PyAudio()
60
+
stream = p.open(...)
61
+
# Do some staf
62
+
63
+
stream.stop_stream()
64
+
stream.close()
65
+
66
+
# close PyAudio
67
+
p.terminate()
68
+
```
69
+
70
+
### Difference with PyAudio
71
+
72
+
- The behavior of all standard methods is unchanged
73
+
- Added several *life-improving* methods
74
+
- Fixed problem with name encoding
75
+
76
+
#### More detailed
77
+
- new methods:
78
+
-[`get_host_api_info_generator`](https://github.com/s0d3s/PyAudioWPatch/blob/964afaed7dc03b6dd097f0c22d8a286663516544/src/pyaudiowpatch/__init__.py#L1066) - Iterate over all Host APIs
79
+
-[`get_device_info_generator`](https://github.com/s0d3s/PyAudioWPatch/blob/964afaed7dc03b6dd097f0c22d8a286663516544/src/pyaudiowpatch/__init__.py#L1080) - Iterate over all devices
80
+
-[`get_device_info_generator_by_host_api`](https://github.com/s0d3s/PyAudioWPatch/blob/964afaed7dc03b6dd097f0c22d8a286663516544/src/pyaudiowpatch/__init__.py#L1093) - Iterate over all devices, by specific Host API(index/type)
81
+
-[`get_loopback_device_info_generator`](https://github.com/s0d3s/PyAudioWPatch/blob/964afaed7dc03b6dd097f0c22d8a286663516544/src/pyaudiowpatch/__init__.py#L1117) - Iterate over all devices(with loopback mode)
82
+
-[`print_detailed_system_info`](https://github.com/s0d3s/PyAudioWPatch/blob/964afaed7dc03b6dd097f0c22d8a286663516544/src/pyaudiowpatch/__init__.py#L1133) - Print some info about Host Api and devices
83
+
<!---
84
+
- [`get_host_api_info_generator`](src/pyaudiowpatch/__init__.py#L1066) - Iterate over all Host APIs
85
+
- [`get_device_info_generator`](src/pyaudiowpatch/__init__.py#L1080) - Iterate over all devices
86
+
- [`get_device_info_generator_by_host_api`](src/pyaudiowpatch/__init__.py#L1093) - Iterate over all devices, by specific Host API(index/type)
87
+
- [`get_loopback_device_info_generator`](src/pyaudiowpatch/__init__.py#L1117) - Iterate over all devices(with loopback mode)
88
+
- [`print_detailed_system_info`](src/pyaudiowpatch/__init__.py#L1133) - Print some info about Host Api and devices-->
89
+
90
+
- new features:
91
+
- Context manager support, for PyAudio(manager) and Stream classes
92
+
- Run `python -m pyaudiowpatch` to get list of devices(like `print_detailed_system_info` call)
93
+
94
+
#### Examples:
95
+
-[Play sine, using \'new context manager'](https://github.com/s0d3s/PyAudioWPatch/blob/964afaed7dc03b6dd097f0c22d8a286663516544/examples/pawp_play_sine_using_context_manger.py)
96
+
-[Record from audio from default speakers](https://github.com/s0d3s/PyAudioWPatch/blob/964afaed7dc03b6dd097f0c22d8a286663516544/examples/pawp_record_wasapi_loopback.py)
0 commit comments