<commit_before>Notes on using PocketSphinx
===========================

Installing other languages
--------------------------

By default, SpeechRecognition's Sphinx functionality supports only US English. Additional language packs are also available, but not included due to the files being too large:

* `International French <https://drive.google.com/open?id=0Bw_EqP-hnaFNN2FlQ21RdnVZSVE>`__
* `Mandarin Chinese <https://drive.google.com/open?id=0Bw_EqP-hnaFNSWdqdm5maWZtTGc>`__
* `Italian <https://drive.google.com/open?id=0Bw_EqP-hnaFNSXUtMm8tRkdUejg>`__

To install a language pack, download the ZIP archives and extract them directly into the module install directory (you can find the module install directory by running ``python -c "import speech_recognition as sr, os.path as p; print(p.dirname(sr.__file__))"``).

Here is a simple Bash script to install all of them:

.. code:: bash

    #!/usr/bin/env bash
    SR_LIB=$(python -c "import speech_recognition as sr, os.path as p; print(p.dirname(sr.__file__))")
    sudo apt-get install --yes wget unzip
    sudo wget https://db.tt/tVNcZXao -O "$SR_LIB/fr-FR.zip"
    sudo unzip -o "$SR_LIB/fr-FR.zip" -d "$SR_LIB"
    sudo chmod --recursive a+r "$SR_LIB/fr-FR/"
    sudo wget https://db.tt/2YQVXmEk -O "$SR_LIB/zh-CN.zip"
    sudo unzip -o "$SR_LIB/zh-CN.zip" -d "$SR_LIB"
    sudo chmod --recursive a+r "$SR_LIB/zh-CN/"

Once installed, you can simply specify the language using the ``language`` parameter of ``recognizer_instance.recognize_sphinx``. For example, French would be specified with ``"fr-FR"`` and Mandarin with ``"zh-CN"``.

Building PocketSphinx-Python from source
----------------------------------------

For Windows, it is recommended to install the precompiled Wheel packages in the ``third-party`` directory. These are provided because building Pocketsphinx on Windows requires a lot of work, and can take hours to download and install all the surrounding software.
<commit_msg>Update Pocketsphinx install docs<commit_after>Notes on using PocketSphinx
===========================

Installing other languages
--------------------------

By default, SpeechRecognition's Sphinx functionality supports only US English. Additional language packs are also available, but not included due to the files being too large:

* `International French <https://drive.google.com/open?id=0Bw_EqP-hnaFNN2FlQ21RdnVZSVE>`__
* `Mandarin Chinese <https://drive.google.com/open?id=0Bw_EqP-hnaFNSWdqdm5maWZtTGc>`__
* `Italian <https://drive.google.com/open?id=0Bw_EqP-hnaFNSXUtMm8tRkdUejg>`__

To install a language pack, download the ZIP archives and extract them directly into the module install directory (you can find the module install directory by running ``python -c "import speech_recognition as sr, os.path as p; print(p.dirname(sr.__file__))"``).

Here is a simple Bash script to install all of them, assuming you've downloaded all three ZIP files into your current directory:

.. code:: bash

    #!/usr/bin/env bash
    SR_LIB=$(python -c "import speech_recognition as sr, os.path as p; print(p.dirname(sr.__file__))")
    sudo apt-get install --yes unzip
    sudo unzip -o fr-FR.zip -d "$SR_LIB"
    sudo chmod --recursive a+r "$SR_LIB/fr-FR/"
    sudo unzip -o zh-CN.zip -d "$SR_LIB"
    sudo chmod --recursive a+r "$SR_LIB/zh-CN/"
    sudo unzip -o it-IT.zip -d "$SR_LIB"
    sudo chmod --recursive a+r "$SR_LIB/it-IT/"

Once installed, you can simply specify the language using the ``language`` parameter of ``recognizer_instance.recognize_sphinx``. For example, French would be specified with ``"fr-FR"`` and Mandarin with ``"zh-CN"``.

Building PocketSphinx-Python from source
----------------------------------------

For Windows, it is recommended to install the precompiled Wheel packages in the ``third-party`` directory. These are provided because building Pocketsphinx on Windows requires a lot of work, and can take hours to download and install all the surrounding software.

{'fraction_non_alphanumeric': 0.1444809295276585, 'fraction_numerical': 0.004294013639808032, 'mean_word_length': 3.794188861985472, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2730349', 'n_tokens_mistral': 1284, 'n_tokens_neox': 1208, 'n_words': 434}