Skip to content

Commit 9f3140a

Browse files
committed
Changing the default profanity filter to 0 and updating the documentation
1 parent d959c17 commit 9f3140a

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

reference/library-reference.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ Returns the most likely transcription if ``show_all`` is false (the default). Ot
210210

211211
Raises a ``speech_recognition.UnknownValueError`` exception if the speech is unintelligible. Raises a ``speech_recognition.RequestError`` exception if there are any issues with the Sphinx installation.
212212

213-
``recognizer_instance.recognize_google(audio_data: AudioData, key: Union[str, None] = None, language: str = "en-US", show_all: bool = False) -> Union[str, Dict[str, Any]]``
213+
``recognizer_instance.recognize_google(audio_data: AudioData, key: Union[str, None] = None, language: str = "en-US", , pfilter: Union[0, 1], show_all: bool = False) -> Union[str, Dict[str, Any]]``
214214
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
215215

216216
Performs speech recognition on ``audio_data`` (an ``AudioData`` instance), using the Google Speech Recognition API.
@@ -221,6 +221,8 @@ To obtain your own API key, simply follow the steps on the `API Keys <http://www
221221

222222
The recognition language is determined by ``language``, an IETF language tag like ``"en-US"`` or ``"en-GB"``, defaulting to US English. A list of supported language tags can be found `here <http://stackoverflow.com/questions/14257598/what-are-language-codes-for-voice-recognition-languages-in-chromes-implementati>`__. Basically, language codes can be just the language (``en``), or a language with a dialect (``en-US``).
223223

224+
The profanity filter level can be adjusted with ``pfilter``: 0 - No filter, 1 - Only shows the first character and replaces the rest with asterisks. The default is level 0.
225+
224226
Returns the most likely transcription if ``show_all`` is false (the default). Otherwise, returns the raw API response as a JSON dictionary.
225227

226228
Raises a ``speech_recognition.UnknownValueError`` exception if the speech is unintelligible. Raises a ``speech_recognition.RequestError`` exception if the speech recognition operation failed, if the key isn't valid, or if there is no internet connection.

speech_recognition/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,7 @@ def recognize_sphinx(self, audio_data, language="en-US", keyword_entries=None, g
842842
if hypothesis is not None: return hypothesis.hypstr
843843
raise UnknownValueError() # no transcriptions available
844844

845-
def recognize_google(self, audio_data, key=None, language="en-US", pfilter=1, show_all=False):
845+
def recognize_google(self, audio_data, key=None, language="en-US", pfilter=0, show_all=False):
846846
"""
847847
Performs speech recognition on ``audio_data`` (an ``AudioData`` instance), using the Google Speech Recognition API.
848848
@@ -852,7 +852,7 @@ def recognize_google(self, audio_data, key=None, language="en-US", pfilter=1, sh
852852
853853
The recognition language is determined by ``language``, an RFC5646 language tag like ``"en-US"`` (US English) or ``"fr-FR"`` (International French), defaulting to US English. A list of supported language tags can be found in this `StackOverflow answer <http://stackoverflow.com/a/14302134>`__.
854854
855-
The profanity filter level can be adjusted with ``pfilter``: 0 - No filter, 1 - Only shows the first character and replaces the rest with asterisks. The default is level 1.
855+
The profanity filter level can be adjusted with ``pfilter``: 0 - No filter, 1 - Only shows the first character and replaces the rest with asterisks. The default is level 0.
856856
857857
Returns the most likely transcription if ``show_all`` is false (the default). Otherwise, returns the raw API response as a JSON dictionary.
858858

0 commit comments

Comments
 (0)