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
Copy file name to clipboardexpand all lines: .github/ISSUE_TEMPLATE.md
+2
Original file line number
Diff line number
Diff line change
@@ -36,4 +36,6 @@ My **PyAudio library version** is <INSERT VERSION HERE> / I don't have PyAudio i
36
36
37
37
My **microphones** are: (You can check this by running `python -c "import speech_recognition as sr;print(sr.Microphone.list_microphone_names())"`.)
38
38
39
+
My **working microphones** are: (You can check this by running `python -c "import speech_recognition as sr;print(sr.Microphone.list_working_microphones())"`.)
40
+
39
41
I **installed PocketSphinx from** <INSERTSOURCEHERE>. (For example, from the Debian repositories, from Homebrew, or from the source code.)
Copy file name to clipboardexpand all lines: README.rst
+1-1
Original file line number
Diff line number
Diff line change
@@ -278,7 +278,7 @@ To install/reinstall the library locally, run ``python setup.py install`` in the
278
278
279
279
Before a release, the version number is bumped in ``README.rst`` and ``speech_recognition/__init__.py``. Version tags are then created using ``git config gpg.program gpg2 && git config user.signingkey DB45F6C431DE7C2DCD99FF7904882258A4063489 && git tag -s VERSION_GOES_HERE -m "Version VERSION_GOES_HERE"``.
280
280
281
-
Releases are done by running ``make-release.sh`` to build the Python source packages, sign them, and upload them to PyPI.
281
+
Releases are done by running ``make-release.sh VERSION_GOES_HERE`` to build the Python source packages, sign them, and upload them to PyPI.
Copy file name to clipboardexpand all lines: reference/library-reference.rst
+18-1
Original file line number
Diff line number
Diff line change
@@ -31,7 +31,7 @@ Instances of this class are context managers, and are designed to be used with `
31
31
32
32
Returns a list of the names of all available microphones. For microphones where the name can't be retrieved, the list entry contains ``None`` instead.
33
33
34
-
The index of each microphone's name is the same as its device index when creating a ``Microphone`` instance - indices in this list can be used as values of ``device_index``.
34
+
The index of each microphone's name in the returned list is the same as its device index when creating a ``Microphone`` instance - if you want to use the microphone at index 3 in the returned list, use ``Microphone(device_index=3)``.
35
35
36
36
To create a ``Microphone`` instance by name:
37
37
@@ -42,6 +42,23 @@ To create a ``Microphone`` instance by name:
42
42
if microphone_name =="HDA Intel HDMI: 0 (hw:0,3)":
Returns a dictionary mapping device indices to microphone names, for microphones that are currently hearing sounds. When using this function, ensure that your microphone is unmuted and make some noise at it to ensure it will be detected as working.
49
+
50
+
Each key in the returned dictionary can be passed to the ``Microphone`` constructor to use that microphone. For example, if the return value is ``{3: "HDA Intel PCH: ALC3232 Analog (hw:1,0)"}``, you can do ``Microphone(device_index=3)`` to use that microphone.
51
+
52
+
To create a ``Microphone`` instance for the first working microphone:
53
+
54
+
.. code:: python
55
+
56
+
for device_index in Microphone.list_working_microphones():
assertisinstance(device_info.get("defaultSampleRate"), (float, int)) anddevice_info["defaultSampleRate"] >0, "Invalid device info returned from PyAudio: {}".format(device_info)
88
88
sample_rate=int(device_info["defaultSampleRate"])
89
-
exceptException:
89
+
finally:
90
90
audio.terminate()
91
-
raise
92
91
93
92
self.device_index=device_index
94
93
self.format=self.pyaudio_module.paInt16# 16-bit int sampling
@@ -118,7 +117,7 @@ def list_microphone_names():
118
117
"""
119
118
Returns a list of the names of all available microphones. For microphones where the name can't be retrieved, the list entry contains ``None`` instead.
120
119
121
-
The index of each microphone's name is the same as its device index when creating a ``Microphone`` instance - indices in this list can be used as values of ``device_index``.
120
+
The index of each microphone's name in the returned list is the same as its device index when creating a ``Microphone`` instance - if you want to use the microphone at index 3 in the returned list, use ``Microphone(device_index=3)``.
Returns a dictionary mapping device indices to microphone names, for microphones that are currently hearing sounds. When using this function, ensure that your microphone is unmuted and make some noise at it to ensure it will be detected as working.
136
+
137
+
Each key in the returned dictionary can be passed to the ``Microphone`` constructor to use that microphone. For example, if the return value is ``{3: "HDA Intel PCH: ALC3232 Analog (hw:1,0)"}``, you can do ``Microphone(device_index=3)`` to use that microphone.
assertisinstance(device_info.get("defaultSampleRate"), (float, int)) anddevice_info["defaultSampleRate"] >0, "Invalid device info returned from PyAudio: {}".format(device_info)
0 commit comments