a
    ýÞ{bÙ  ã                   @   s   d Z G dd„ dƒZdS )aù  
Speech to Text
==============

.. versionadded:: 1.4.0

Speech Recognition facade.

In order to check that your device supports voice recognition use method
`exist`.

Variable `language` indicates which language will be used to match words from
 voice.

Use `start` to start voice recognition immediately and `stop` to stop.

.. note::
    Needed permissions for Android: `RECORD_AUDIO` (and `INTERNET` if you want
    online voice recognition API to be used)

.. note::
    On Android platform, after execute `start` method you can hear BEEP!
    Mute sound in order to disable it.

.. note::
    For Android implementation to work there has to be an application with
    `android.speech.RecognitionService` implementation present in the system.
    Mostly it's `com.google.android.googlequicksearchbox` or "Google"
    application (the search bar with the launcher widget).

Offline Speech Recognition on Android
-------------------------------------

Requires any application that provides an
`android.speech.RecognitionService` implementation to the other apps. One of
such applications is on a lot of devices preinstalled Google (quick search
box).

The API prefers offline recognition, but should be able to switch to online
alternative in case you don't have a language package installed (`INTERNET`
permission necessary).

You can enable offline speech recognition this way (Android 8.1):

* open the `Settings` app
* choose `Language & Input` / `Language & Keyboard` (Samsung might include it
  in the `General` category)
* choose `On-Screen keyboard` or `Voice search`
* choose `Google Keyboard`
* choose `Offline Speech recognition`
* download language package if you don't have one already

Simple Examples
---------------

To start listening::

    >>> from plyer import stt
    >>> stt.start()

To retrieve partial results while listening::

    >>> assert stt.listening
    >>> print(stt.partial_results)

To stop listening::

    >>> stt.stop()

To retrieve results after the listening stopped::

    >>> print(stt.results)
c                   @   s†   e Zd ZdZdZddgZg Zg Zg ZdZ	dZ
edd„ ƒZedd	„ ƒZejd
d	„ ƒZdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ ZdS )ÚSTTz 
    Speech to text facade.
    zen-USzpl-PLTFc                 C   s   | j S )zI
        Return list of supported languages used in recognition.
        )Ú_supported_languages©Úself© r   úa/Users/vegardjervell/Documents/master/model/venv/lib/python3.9/site-packages/plyer/facades/stt.pyÚsupported_languagesx   s    zSTT.supported_languagesc                 C   s   | j S )z*
        Return current language.
        )Ú	_languager   r   r   r   Úlanguage€   s    zSTT.languagec                 C   s   || j v r|| _dS )aè  
        Set current language.

        Value can not be set if it's not supported. See `supported_languages`
        to get what language you can set.

        .. note::
           We obviously can't check each language, therefore if you find
           that a specific language is available to you and the only limitation
           is our check for the internally defined `supported_languages`, feel
           free to open a pull request for adding your language to the list.
        N)r   r   )r   Úlangr   r   r   r	   ˆ   s    
c                 C   s   g | _ g | _|  ¡  d| _dS )z"
        Start listening.
        TN)ÚresultsÚpartial_resultsÚ_startÚ	listeningr   r   r   r   Ústart›   s    z	STT.startc                 C   s   |   ¡  d| _dS )z!
        Stop listening.
        FN)Ú_stopr   r   r   r   r   Ústop¥   s    zSTT.stopc                 C   s   |   ¡ S )zH
        Returns a boolean for speech recognition availability.
        )Ú_existr   r   r   r   Úexist­   s    z	STT.existc                 C   s   t ‚d S ©N©ÚNotImplementedErrorr   r   r   r   r   µ   s    z
STT._startc                 C   s   t ‚d S r   r   r   r   r   r   r   ¸   s    z	STT._stopc                 C   s   t ‚d S r   r   r   r   r   r   r   »   s    z
STT._existN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   Úerrorsr   Zprefer_offliner   Úpropertyr   r	   Úsetterr   r   r   r   r   r   r   r   r   r   r   L   s,   þ



r   N)r   r   r   r   r   r   Ú<module>   s   K